Mission 01 · A01 Broken Access Control · ~20 min

The Invoice Leak

in Secure Coding Foundations

Fix codeeasy
Fix codeIn progress
0 / 400 pts

◎ Objective

Spot the weakness in The Invoice Leak, then patch the code until every check — hidden ones included — passes.

  1. spot — you are here
  2. patch — to do
  3. verify — to do

▶ nowSpot itSpot the weakness

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.

  1. Spot it. Name the weakness.
  2. Patch it. Edit the handler so customers only see their own invoices, admins see everything, and anonymous callers get a 401.
  3. 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.

Spot itSpot it

100 pts

Which weakness lets one customer read another customer's invoices?

Patch itPatch

200 pts + 100 verify bonus

This is the vulnerable code. Edit it right here so it closes the hole, then run the checks. Line 8: This line hands the invoice to whoever asks. Who is asking?

runs in an isolated container · no network

$ secx check access-control

  • ○ func Owner can read their own invoice
  • ○ func Missing invoice returns 404
  • ○ sec A user cannot read another user's invoice
  • ○ sec Anonymous requests are rejected with 401
  • ○ + hidden checks
Stuck? Reveal hintscosts points