Access to another customer’s orders through the API
What we found
A logged-in user can read another user’s order by changing the order number in the URL. The server checks that the user is logged in but not that the order belongs to them.
Steps to reproduce
- Log in as test customer A and open one of their orders. The request is GET /api/orders/10482.
- Log in as test customer B in a separate browser session.
- With customer B’s token, send the same request for order 10482.
- The server returns 200 with customer A’s name, address and items. The expected response is 404.
Request and response (sensitive values redacted)
GET /api/orders/10482 HTTP/1.1Host: api.shop.exampleAuthorization: Bearer [customer B token] HTTP/1.1 200 OKContent-Type: application/json {"id":10482,"customer":"[redacted]","address":"[redacted]","items":[…]}Business impact
Unauthorized access to other customers’ orders can expose names, delivery addresses and order details. How much is exposed depends on how many orders can be reached.
How to fix
- In the order handler, look the order up by both its ID and the logged-in user’s ID, for example WHERE id = ? AND customer_id = ?.
- If no order matches, return 404, the same response as for an order that does not exist.
- Apply the same check to every endpoint that takes an order ID.
- Add an automated test that logs in as one user, requests another user’s order and expects 404.