-
Notifications
You must be signed in to change notification settings - Fork 48
HotFix: Simplify teamIdOrSlug schema validation #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| if (z.uuid().safeParse(segment).success) { | ||
| // FIXME: should check for the case if this is a slug which has the same format as a uuid, before returning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: UUID Format Confusion Leads to Authorization Bypass
When segment is a valid UUID format, the function returns it directly without verifying it exists as a team ID in the database. Since the schema now accepts any string as a slug, a team could have a slug that's UUID-formatted. This causes the function to incorrectly treat the slug as a team ID, potentially returning a non-existent team ID or bypassing authorization checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it won't bypass authorization. it would result in potentially invalid access denials to the dashboard
The previous TeamIdOrSlugSchema regex did not match the possible slugs in the database 100% of the time.
Note
Loosens teamIdOrSlug validation, verifies UUIDs against DB to avoid slug/ID collisions, and adds structured warning logs in dashboard and team middleware.
TeamIdOrSlugSchemanow accepts anystring(removed slug regex) alongsideuuid.getTeamIdFromSegmentverifies UUIDs againstteamstable and ensures they aren’t treated as IDs when they match a slug; retains slug lookup and usesserver-only.app/dashboard/[teamIdOrSlug]/layout.tsxwhen team cannot be resolved (with serialized error).withTeamIdResolutionmiddleware for invalidteamIdOrSlugand unauthorized access.Written by Cursor Bugbot for commit bbb083f. This will update automatically on new commits. Configure here.