Any user can read other customers' orders via the API
Description
The orders endpoint returns an order for any ID it is given. It checks that the caller is logged in, but not that the order belongs to them.
Impact
Any registered user can read every customer's orders, including names, delivery addresses and order history, by changing a number in the request.
Evidence
GET /api/orders/10482 HTTP/1.1
Host: shop.example.com
Authorization: Bearer <token of user B>HTTP/1.1 200 OK
Content-Type: application/json
{ "id": 10482, "customer": "user A", "address": "[redacted]", "items": [ … ] }Reproduction
- Log in as user A and place an order; note its ID.
- Log in as user B in a separate session.
- Request user A's order ID with user B's token.
- The API returns user A's order instead of 403 Forbidden.
Remediation
Check ownership on the server for every object request: load the order only where its owner matches the authenticated user, and return 404 otherwise. Apply the same check to every endpoint that takes an object ID.
Retest
Fixed · retested. The endpoint now returns 404 for orders that belong to another user.