Skip to content

Conversation

@ben-fornefeld
Copy link
Member

@ben-fornefeld ben-fornefeld commented Nov 11, 2025

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.

  • Team resolution/backend:
    • TeamIdOrSlugSchema now accepts any string (removed slug regex) alongside uuid.
    • getTeamIdFromSegment verifies UUIDs against teams table and ensures they aren’t treated as IDs when they match a slug; retains slug lookup and uses server-only.
  • Logging:
    • Adds warning logs in app/dashboard/[teamIdOrSlug]/layout.tsx when team cannot be resolved (with serialized error).
    • Adds warning logs in withTeamIdResolution middleware for invalid teamIdOrSlug and unauthorized access.

Written by Cursor Bugbot for commit bbb083f. This will update automatically on new commits. Configure here.

@ben-fornefeld ben-fornefeld self-assigned this Nov 11, 2025
@ben-fornefeld ben-fornefeld added the bug Something isn't working label Nov 11, 2025
@vercel
Copy link

vercel bot commented Nov 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web Ready Ready Preview Comment Nov 11, 2025 9:32pm
web-juliett Ready Ready Preview Comment Nov 11, 2025 9:32pm

}

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
Copy link

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.

Fix in Cursor Fix in Web

Copy link
Member Author

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

@ben-fornefeld ben-fornefeld changed the title hfix: Simplify teamIdOrSlug schema validation HotFix: Simplify teamIdOrSlug schema validation Nov 11, 2025
@ben-fornefeld ben-fornefeld merged commit fc3b1a4 into main Nov 11, 2025
6 checks passed
@ben-fornefeld ben-fornefeld deleted the hfix-uuid-validation branch November 11, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants