You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue [Security] Signup allows arbitrary role assignment including SUPER_ADMIN
Tier: 🟡 Medium
Description:
Problem: In src/modules/auth/auth.service.ts line 54, signup() accepts an optional role field from the request body: const assignedRole = input.role ? input.role : determineUserRole(input.email). The SignupBodySchema in auth.validation.ts allows role: z.enum(['SUPER_ADMIN', 'ADMIN', 'MANAGER', 'VIEWER', 'CUSTOMER']). This means any user can self-assign SUPER_ADMIN during signup.
Implementation: Remove the role field from SignupBodySchema, or restrict it to non-privileged roles only (e.g., VIEWER, CUSTOMER). Admin and super-admin roles should only be assigned through invitation or admin workflows.
Dependencies:
Depends on None
Acceptance Criteria:
Public signup does not allow SUPER_ADMIN or ADMIN role self-assignment.
Role is auto-determined by determineUserRole() or defaults to VIEWER.
Admin roles can only be assigned through POST /api/users/team or invitation flow.
Proper HTTP status codes and our standard JSON response wrapper are used.
Testing Requirements:
Test that signup with role: 'SUPER_ADMIN' is rejected or ignored.
Test that signup without a role defaults to VIEWER.
Unit tests written for the core logic (target 80%+ coverage).
PR Checklist:
Branch is named conventionally (e.g., security/issue-XX-signup-role).
npm run lint and npm run build pass with zero warnings.
Screenshot of passing Jest terminal logs is attached to the PR.
Domain: Identity
Issue [Security] Signup allows arbitrary role assignment including
SUPER_ADMINTier: 🟡 Medium
Description:
src/modules/auth/auth.service.tsline 54,signup()accepts an optionalrolefield from the request body:const assignedRole = input.role ? input.role : determineUserRole(input.email). TheSignupBodySchemainauth.validation.tsallowsrole: z.enum(['SUPER_ADMIN', 'ADMIN', 'MANAGER', 'VIEWER', 'CUSTOMER']). This means any user can self-assignSUPER_ADMINduring signup.rolefield fromSignupBodySchema, or restrict it to non-privileged roles only (e.g.,VIEWER,CUSTOMER). Admin and super-admin roles should only be assigned through invitation or admin workflows.Dependencies:
Acceptance Criteria:
SUPER_ADMINorADMINrole self-assignment.determineUserRole()or defaults toVIEWER.POST /api/users/teamor invitation flow.Testing Requirements:
role: 'SUPER_ADMIN'is rejected or ignored.VIEWER.PR Checklist:
security/issue-XX-signup-role).npm run lintandnpm run buildpass with zero warnings.