You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add length limit to userId parameter to mitigate DoS attack risk #7375
Is your feature request related to a problem? Please describe.
The userId parameter in the POST /api/v1/client/{environmentId}/displays endpoint lacks explicit length validation in the Zod schema.
While Next.js's default 4MB request body limit provides some protection, the current implementation allows user IDs up to 4MB (~4
million characters), which is far beyond any reasonable use case.
This creates several issues:
Unclear design intent: The code doesn't explicitly define what length of userId is expected
Database inefficiency: The ContactAttribute.value field is a TEXT type that can store up to ~1GB, allowing unnecessarily large data
Lack of defense in depth: The protection relies solely on framework defaults rather than explicit application-level validation
Future risk: If the framework configuration changes or the application is migrated, this could become a vulnerability
Normal user IDs (UUIDs, email addresses, custom IDs) are typically tens to hundreds of characters, not millions.
Describe the solution you'd like
Add explicit length validation to the userId parameter in the Zod schema with a reasonable maximum of 255 characters:
// packages/types/displays.ts
export const ZDisplayCreateInput = z.object({
environmentId: z.string().cuid2(),
surveyId: z.string().cuid2(),
userId: z.string().max(255, {
message: "User ID must not exceed 255 characters"
}).optional(),
responseId: z.string().cuid2().optional(),
});
Why 255 characters:
UUID: 36 characters
Email address: max 254 characters (RFC 5321)
Custom IDs: typically tens to hundreds of characters
Covers all common use cases while preventing abuse
Benefits:
Makes the expected userId format explicit in code
Implements defense in depth (application + framework level)
Improves database efficiency and query performance
Prevents potential issues during framework migration or configuration changes
Follows OWASP input validation best practices
Additional context
This same issue likely exists in other endpoints that accept userId parameters. A comprehensive review and fix across all relevant Zod schemas would be beneficial.
Activity
jobenjada commentedon Feb 27, 2026
hey @Iriko0606 thanks for raising this issue, we will get it resolved as soon as possible