Any user can export every customer's invoices through the old API
Illustrative example on a fictional app
- Severity
- Critical CVSS 3.1 base score 9.6
- Status
- Exploit confirmed · Chained attack (3 steps)
- Where
-
api.example.com:/api/v1/users/lookup,/api/v1/users/me,/api/v1/admin/export - Tested as
- Member of Company A (grey-box) · Environment: staging
What happened
A regular user can look up another company's ID, make themselves an admin through an old API version, then export that company's invoices.
Why it matters
One free account is all an attacker needs to download every customer's invoices, billing addresses and card details (last 4 digits).
Attack path
| Step | What Elapid did | Result | Rated on its own |
|---|---|---|---|
| 1 | Found /api/v1 referenced in the web app's JavaScript. Called /api/v1/users/lookup?email=… with no login | Returned the user ID and company ID (2041) | Low |
| 2 | Sent PATCH /api/v1/users/me with {"role": "admin"} as a Member | Role changed to admin | Medium |
| 3 | Called GET /api/v1/admin/export?company_id=2041 | Another company's 3,180 invoices returned | Medium |
| Together | Full cross-customer data breach | Critical (9.6) |
Each step shows what was sent, what the app should have returned, and what it actually returned.
GET /api/v1/users/lookup?email=billing@company-b.example HTTP/1.1
Host: api.example.comHTTP/1.1 200 OK
{"user_id": 55107, "company_id": 2041}Should get401 UnauthorizedGot200 OK
PATCH /api/v1/users/me HTTP/1.1
Host: api.example.com
Authorization: Bearer <member token>
Content-Type: application/json
{"role": "admin"}HTTP/1.1 200 OK
{"id": 8812, "email": "member@company-a.example", "role": "admin"}Should get403 ForbiddenGot200 OK
GET /api/v1/admin/export?company_id=2041 HTTP/1.1
Host: api.example.com
Authorization: Bearer <same token>HTTP/1.1 200 OK
{"company_id": 2041, "invoice_count": 3180, "invoices": [ … ]}Should get403 ForbiddenGot200 OK
Steps to reproduce
- Open the web app and note that its JavaScript calls
/api/v1. - Without signing in, call
/api/v1/users/lookup?email=<any customer email>. Note thecompany_id. - Sign in as any Member of Company A and copy the session token.
- Send
PATCH /api/v1/users/mewith{"role": "admin"}. The response shows"role": "admin". - Send
GET /api/v1/admin/export?company_id=<id from step 2>with the same token. The response contains the other company's invoices.
Safety note
The role change was made on the test account you provided and reverted after the test. Elapid kept only the first invoice record as evidence.
Fix now (minutes)
Turn off /api/v1 at your API gateway if nothing still uses it. This breaks the whole chain at once.
Fix the root causes (so it can't come back in v2 or v3)
Stop leaking IDs without a login. Require authentication on
/users/lookup, and return only what the screen needs.Never let users set their own role. Accept only an allow-list of fields in profile updates.
// Before: saves whatever the request sends, including "role" await User.update(req.user.id, req.body); // After: only the fields a user may change const { name, timezone } = req.body; await User.update(req.user.id, { name, timezone });Take the company from the session, not the request.
// Before const companyId = req.query.company_id; // After const companyId = req.user.companyId;Add a regression test to CI: a Member can't change their role, and an admin can't export another company's data.
Re-test: After your fix ships, Elapid re-runs all three steps automatically. The finding is marked Fix verified when each one is blocked.
| Standard | Reference |
|---|---|
| CWE |
|
| OWASP API Security Top 10 (2023) |
|
| CVSS 3.1 |
|
| MITRE ATT&CK |
|
| PCI DSS v4.0 |
|
| SOC 2 |
|
| ISO/IEC 27001:2022 |
|