Invoices from other customers can be read by changing the ID
- Endpoint
- GET /api/v2/invoices/{id}
- Weakness
- CWE-639, authorization bypass through a user-controlled key
Impact
Any signed-in user, including a read-only viewer, can download every invoice on the platform, with customer names, billing emails and amounts.
Reproduce it
Sign in as the viewer test account for Acme and request an invoice ID that belongs to a different company:
curl https://app.example.com/api/v2/invoices/48213 \
-H "Authorization: Bearer $VIEWER_TOKEN"
HTTP/1.1 200 OK
{"id": 48213, "tenant": "northwind", ...}Fix
Load the invoice through the signed-in user's tenant, for example Invoice.where(tenant: current_tenant).find(id), and return 404 when it doesn't match. Add a test that requests another tenant's invoice.