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
// 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))protected = ["dnd-a", "dnd-b"]
order = requestControlledOrder()
order
.filter(s => !protected.contains(s)) // per-element test
.forEach(s => refresh(s))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.
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
- Search for drop-while and take-while used to enforce an exclusion or an allowlist.
- Confirm the input order cannot be influenced by the caller where prefix logic is used.
- Replace prefix operations with per-element filters for membership rules.
- Add a test that shuffles the input and asserts protected items are still skipped.