Why this matters
Broken access control has topped the OWASP Top 10 since 2021. The most common form is an insecure direct object reference (IDOR): an endpoint loads a record by ID and returns it without checking that the caller is allowed to see it.
Authentication answers who are you. Authorization answers may you touch this specific thing. Many real breaches happen because only the first question was asked.
Your mission
The invoice handler on the right is used by a billing API. Customers report they can see invoices that are not theirs.
- Spot it. Name the weakness.
- Patch it. Edit the handler so customers only see their own invoices, admins see everything, and anonymous callers get a 401.
- Prove it. Run the checks. Hidden checks probe edge cases you didn't see.
Defensive patterns
- Check ownership on every object fetch, ideally in one shared place.
- Return the same response for "not found" and "not yours" so IDs cannot be probed.
- Compare roles exactly. Never trust loose string matching for privileges.