Blog / A01:2021 Broken Access Control
A01:2021 · Broken Access Control

A filter that stops early lets protected items through

The exclusion for do-not-disturb services only skips a leading run. Reorder the input so one ordinary service comes first, and every protected service after it gets processed.

caller controlsthe item ordercode dropsprotected…first ordinaryitem stops…later protecteditems…excluded servicesget refreshedATTACKER INPUTIMPACTcheck absent
Attack path · caller controls the item order → code drops protected items from the front → first ordinary item stops the drop → later protected items pass through → excluded services get refreshed

The exclusion for do-not-disturb services only skips a leading run. Reorder the input so one ordinary service comes first, and every protected service after it gets processed.

What goes wrong

The bug is a wrong choice of stream operation. The code wants to skip a set of protected services, so it uses a drop-while filter. That operation removes elements only until it hits the first one that does not match, then passes everything after it through untouched. Fine if the protected items are guaranteed to sit at the front. They are not, because the order comes from caller-controlled input.

Put one ordinary service at the head of the list and the drop stops immediately. Every protected service behind it flows into the loop and gets refreshed, which is the exact thing the exclusion was meant to prevent. The predicate looks correct in isolation. The semantics are wrong for an unordered set.

What you want is a filter that tests each element on its own, not one that gives up at the first non-match. Drop-while and take-while are for prefixes. Membership exclusion is a per-element test.

The pattern

Vulnerable
// intent: never refresh a protected service
protected = ["dnd-a", "dnd-b"]

order = requestControlledOrder()   // caller influences order
order
    .dropWhile(s => protected.contains(s))  // skips only the leading run
    .forEach(s => refresh(s))
Hardened
protected = ["dnd-a", "dnd-b"]

order = requestControlledOrder()
order
    .filter(s => !protected.contains(s))   // per-element test
    .forEach(s => refresh(s))
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

This is the kind of flaw that passes every unit test written against sorted input and breaks the moment a caller controls ordering. Call it a do-not-disturb set or a block list. If the exclusion is implemented as a prefix operation, someone will reorder their way around it. The fix is one word in the code and a real change in behavior. Read your stream pipelines for take-while and drop-while where you meant filter.

Check your own code