Skip to content

fix: prevent privilege escalation via client-supplied role in request… - #1

Open
vishu9334 wants to merge 1 commit into
Autter-dev:mainfrom
vishu9334:fix/admin-role-trust
Open

vishu9334 wants to merge 1 commit into
Autter-dev:mainfrom
vishu9334:fix/admin-role-trust

Conversation

@vishu9334

@vishu9334 vishu9334 commented Sep 17, 2026

Copy link
Copy Markdown

What changed

  • Defined userPayloadSchema using Zod .strip() to whitelist safe user fields and drop unpermitted fields like role and isAdmin.
  • Updated POST /api/admin/users to parse requests through this schema so client payloads cannot grant admin access.
  • Updated src/app.test.ts from test.fails to test and added test coverage against alternative privilege escalation payloads.

Why

  • Addresses challenge challenges/admin-endpoint-trusts-client-provided-role.md.
  • Prevented privilege escalation where an unauthenticated client could set role: "admin" in the request body to gain admin rights.

Validation

  • npm test (all 4 tests passing)
  • npm run build

Risks

  • Separate Trust-Boundary Gap: POST /api/admin/users does not yet require caller authentication/authorization (requireAuth). Any unauthenticated client can still reach the endpoint.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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