Skip to content

fix: add auth + validation to user routes, restrict admin role in registration - #11562

Open
laurentketterle-hub wants to merge 1 commit into
SecureBananaLabs:mainfrom
laurentketterle-hub:fix/user-auth-validation
Open

fix: add auth + validation to user routes, restrict admin role in registration#11562
laurentketterle-hub wants to merge 1 commit into
SecureBananaLabs:mainfrom
laurentketterle-hub:fix/user-auth-validation

Conversation

@laurentketterle-hub

Copy link
Copy Markdown

Fixes

Closes #11561
Refs #11398

Changes

1. Created

  • Added with Zod validation for email, password, and role
  • Role restricted to or only (no )

2. Updated

  • now validates via before creating user

3. Updated

  • Added to both and routes
  • Prevents unauthenticated access to user listing and creation

4. Updated

  • role enum changed from to
  • Prevents privilege escalation during registration

Security Impact

  • Before: Anyone could with and gain admin access without authentication
  • Before: Anyone could and enumerate all registered users
  • After: Both endpoints require valid JWT authentication
  • After: User input is validated via Zod, role cannot be set to

Verification

…istration

- Add Zod validation (createUserSchema) for POST /api/users
- Add authMiddleware to GET and POST /api/users routes
- Remove 'admin' from registerSchema role options
- Create validators/user.js with proper schema

Fixes privilege escalation via unauthenticated POST /api/users
and data exposure via unauthenticated GET /api/users.
Refs SecureBananaLabs#11398, closes SecureBananaLabs#11561
github-actions Bot added a commit that referenced this pull request Aug 2, 2026
@laurentketterle-hub

Copy link
Copy Markdown
Author

I claim this bounty. PR ready for review.

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.

SECURITY: POST /api/users has no auth or validation — privilege escalation to admin

1 participant