Skip to content

[Security] Signup allows arbitrary role assignment including SUPER_ADMIN #261

Description

@devin-ai-integration

Domain: Identity


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.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions