Reading an order without checking ownership
The GET /api/orders/:id endpoint returns an order by ID to any signed-in customer. This fictional scenario has no order ownership check.
Why it matters
Another customer can see the order items, recipient name and delivery address. Private data is exposed outside its owner's account.
When it occurs
A signed-in customer supplies the ID of another customer's order. This example does not establish whether the order can be changed or deleted.
Supporting evidence and reproduction steps
Illustrative evidence for this fictional example. A real report would include anonymized results from reviewing an agreed version of the project.
- Create test customers A and B with separate accounts.
- Create order #1042 for customer A.
- Request that order through the API as customer B.
- Compare the order owner with the user who received the response.
GET /api/orders/1042
User context: buyer_b
HTTP 200 OK
{
"id": 1042,
"customerId": "buyer_a",
"items": ["Sample product"],
"recipient": "Test recipient A",
"deliveryAddress": "Sample address A"
}Expected: access denied, with no other customer's order data. In the example: a successful response containing customer A's data. A matching order ID is not sufficient to authorize access.
How to verify the fix
| Scenario | Before the fix in this example | Acceptance criterion |
|---|---|---|
| A requests their own order | Access granted | Access remains available |
| B requests A's order | Another customer's data returned | Access denied, no data returned |
| Request without signing in | Access denied | Access remains denied |
| Request for a nonexistent order | Not checked | Agreed response without unnecessary information |
The exact denial status codes must be agreed in the API contract before making changes. A separate check must confirm that the response does not reveal whether another customer's order exists.