Skip to content

fix: normalize roles claim to array before role check - #34

Open
yogeshchoudhary147 wants to merge 1 commit into
mainfrom
fix/role-claim-substring-bypass
Open

fix: normalize roles claim to array before role check#34
yogeshchoudhary147 wants to merge 1 commit into
mainfrom
fix/role-claim-substring-bypass

Conversation

@yogeshchoudhary147

Copy link
Copy Markdown
Contributor

Summary

  • Roles claim emitted as a plain string by an Auth0 Action caused defineRouteAuth and RequireRole to fall back to String.prototype.includes, allowing substring-based role bypass (e.g. billing-admin passing a check for admin)
  • Added normalizeRoles helper in both src/server/middleware.ts and src/client/components.tsx to coerce the claim to string[] before matching
  • Added regression tests covering exact-match string claim and substring-attack scenario in both middleware and component test files

Test plan

  • npm test passes (345 tests)
  • npm run typecheck passes
  • User with billing-admin role is denied access to route requiring admin
  • User with admin role as a string (not array) is granted access to route requiring admin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant