T05 · Unauthorized Access and Privilege Escalation
- Location
EDGE_FUNCTION_SPEC.md:14- Finding
Rating Endpoint Specification Does Not Require Authenticated Participant Ownership Validation
- Content
View full analysis
Vulnerability Details
File Location:
EDGE_FUNCTION_SPEC.md, lines 14-72
Vulnerability Type: Missing object-level authorization before privileged database writes
Risk Level: HighVulnerable Code
json { "round_id": 112, "participant_id": 224, "ratings": [ {"proposition_id": 440, "grid_position": 100}, {"proposition_id": 441, "grid_position": 0}, {"proposition_id": 442, "grid_position": 75}, {"proposition_id": 443, "grid_position": 25} ] }markdown ## Server-Side Validations 1. **Phase check**: Round must be in "rating" phase 2. **One-time check**: Participant must NOT have already submitted for this round 3. **Binary check**: MUST contain at least one 100 and at least one 0 4. **Range check**: All values must be 0-100 5. **Own prop check**: Cannot rate own propositions 6. **Duplicate check**: No duplicate proposition_ids in arraymarkdown 1. Disable direct POST to `/rest/v1/grid_rankings` via RLS 2. Route all ratings through `/functions/v1/submit-ratings` 3. Edge Function performs all validations atomically 4. Insert to `grid_rankings` via supabaseAdmin clientTechnical Analysis
The API accepts a client-controlled
participant_id, but the documented server-side validation list does not require verification that this participant belongs to the user identified by the authenticated JWT. Checking whether a participant has submitted, owns a proposition, or supplied valid ratings is not equivalent to verifying ownership of the participant identity.The specification also states that the Edge Function writes through a
supabaseAdminclient. Such a service-role client bypasses row-level security. Consequently, authorization must be explicitly enforced before the privileged write occurs.The actual Edge Function source referenced by the specification is absent from the audited project, so an undocumented compensating ownersh ...[truncated 1441 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not accept
participant_idas an authoritative client-selected identity. - Validate the bearer JWT and obtain the user identity from the verified token.
- Resolve the participant server-side using the authenticated user ID and requested chat or round.
- Enforce that
participants.user_idequals the authenticatedauth.uid()before performing any write. - Reject requests where the participant is absent, belongs to another user, or is not a member of the relevant chat.
- Keep service-role credentials exclusively on the server and use them only after all authorization checks pass.
- Add negative tests that attempt to submit using another participant's ID.
- Add transaction-level protections so the ownership check, rating insertion, and one-time submission record are processed atomically.
- Include the actual Edge Function source in the project so its authorization behavior can be reviewed and tested.
- Do not accept
