Inflating attacker-controlled bytes with no size cap is a classic bomb. Doing it a second time in a side effect just doubles what the attacker gets for one payload.
What goes wrong
The decode inflates the caller's compressed bytes with no limit on the expanded size. A small, highly compressed input balloons into whatever the attacker chose. That alone is a denial of service.
This version does it twice. A side-effect block re-inflates the same input, presumably to read one property of the result, and pays the full decompression cost again. So the attacker's single small payload buys two large allocations. Even a modest bomb becomes twice the problem, and the second pass is pure waste.
The pattern
function inflate(bytes) {
const out = zlibInflate(bytes) // no output cap
// side effect re-inflates the same input
const again = zlibInflate(bytes)
logSize(again.length)
return out
}function inflate(bytes) {
const out = zlibInflateBounded(bytes, MAX_OUTPUT) // caps output
logSize(out.length) // reuse it, do not redo it
return out
}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
Decompression hides inside so many formats that people stop seeing it: an archive, a content encoding, a token, a saved document. Wherever attacker bytes get inflated, a bound on the output is the difference between a rejected request and a dead process. The double-inflate is a reminder to look at what you do with the result, because a careless second pass can erase whatever headroom you had.
Bound the output of every inflate, and compute anything you need from the result once. Re-running an expensive decode to fetch one field is a cost you can delete.
Check your own code
- Cap the decompressed output size on every inflate call.
- Inflate once and reuse the result instead of decoding again.
- Reject inputs whose expansion ratio crosses a threshold.
- Search for repeated decode calls on the same input in one function.