User data accessible without proper authorization
- Affected
- GET /api/users/{id}
What we found
The endpoint returns a full user record for any numeric id, as long as the request carries a valid session for any account.
Why it matters
Another user could read information belonging to a different account, including email address and billing details.
What could happen
A signed-in user increments the id in the URL and downloads the profile of every customer, one request at a time.
How to fix it
Check that the authenticated user is allowed to see the requested record before returning it. Do this on the server, on every request.
Fix with AI
Review the authorization logic protecting GET /api/users/:id. Ensure that the authenticated user can only read their own record, or records they are explicitly allowed to access (for example as a workspace admin). Add the ownership check on the server side before any database read. Return 404 (not 403) for records the caller is not allowed to see, so ids cannot be enumerated. Write a test that signs in as user A, requests user B's id, and asserts the request fails.
- CWE
- CWE-639: Authorization Bypass Through User-Controlled Key
- CVSS
- 7.5 (High)
- Request
- GET /api/users/1042 Cookie: session=<valid session for user 87>
- Response
- 200 OK { "id": 1042, "email": "…", "plan": "pro", "stripeCustomerId": "cus_…" }
- Evidence
- Two different user ids returned 200 with full records from the same session.
- Technical remediation
- Load the record scoped to the caller (WHERE id = ? AND owner_id = ?), or enforce a policy layer such as row-level security. Reject with 404 when no row matches.