Capping every piece on its own still leaves the total wide open. I fixed a small example of that in VectorCraft, an open source vector illustration app written in Rust: storytold/vectorcraft#4215 .
The problem
VectorCraft opens EMF and WMF files. Those formats store a drawing as a list of records, and some records carry a bitmap, which can wrap a whole PNG or JPEG.
Every bitmap had a cap: 2²⁶ pixels (8192 × 8192). Decoded into four byte RGBA pixels, that's 256 MB, from as little as about 65 KB of PNG. But there was no cap on the file. An audit by PierrunoYT in issue #3600 pointed out that a small file packed with such records could cost "minutes of CPU". The audit rated that "plausible", read from the source rather than run, and suggested a budget of 2²⁸ pixels per file.
It's like a phone plan that caps each download at 1 GB but has no monthly cap. No single download breaks the rules. A hundred of them still empty your wallet.
Why it happened
dib::decode read one bitmap and kept no state.…