In a decode chain that decodes, then inflates, then parses, an unbounded inflate in the middle means the attack lands long before your validation ever runs.
What goes wrong
The payload arrives as an encoded string. The code decodes it, inflates the result, and only later parses and checks the structured content. The inflate step has no cap on compressed size, expanded size, or ratio.
That ordering is the whole problem. Every guard you wrote lives downstream of the decompression, so a bomb detonates before any of them get a vote. The attacker sends a short string, your pipeline faithfully expands it into a memory spike, and the validation that would have said no never runs.
The pattern
function readPayload(text) {
const packed = decodeTransport(text)
const raw = zlibInflate(packed) // no cap, runs before checks
const doc = parseCbor(raw)
return validate(doc) // too late to matter
}function readPayload(text) {
if (text.length > MAX_INPUT) throw new Error('input too large')
const packed = decodeTransport(text)
const raw = zlibInflateBounded(packed, MAX_OUTPUT) // capped inflate
const doc = parseCbor(raw, { maxDepth: 32 })
return validate(doc)
}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
Decode pipelines get built in the order the format demands, and security checks tend to get bolted onto the end where the data finally looks like an object. A resource attack does not care about your object. It cares about the most expensive step, and if that step runs early and unbounded, everything after it is decoration.
Walk your decode chain and find the step that can turn a little input into a lot of memory. That is where the bound goes, before the next stage ever sees the data.
Check your own code
- Find the most expensive step in each decode pipeline and bound it there.
- Cap inflate output before parsing, not after.
- Validate size at the very start of the chain.
- Test with a tiny input that expands past your memory budget.