Out-of-bounds write in the Brotli decoder's internal input buffer · Brotli C library 1.0.3–<1.0.10, 1.1.0–<1.1.1, 1.2.0–<1.2.1 · fixed in 1.0.10 / 1.1.1 / 1.2.1 and Node.js 22.23.4 / 24.22.1 / 26.12.1. Everything below is measured on local builds of Brotli 1.2.0 and 1.2.1, not quoted from third-party tooling.
The bug fires when a block-length counter reaches 0 while the meta-block declared only one
block type. BrotliDecoderStateMetablockBegin() resets every counter to
2²⁴ at the start of each meta-block, so the drain has to happen inside
one meta-block — and a negative meta_block_remaining_len is rejected by
WriteRingBuffer, so the drain may not cost anything. A static-dictionary copy
whose transform returns 0 does exactly that:
BrotliTransformDictionaryWord() returns idx (bytes written), not the
transformed length, and transform 34 (OMIT_FIRST_4, empty affixes) returns 0.
/* per command: insert 0, copy 4, explicit distance */ pos += len; /* +0 */ s->meta_block_remaining_len -= len; /* -0 */ --s->block_length[1]; /* the counter we are draining */ --s->block_length[2]; /* ...and the distance counter too */
| parameter | value | why |
|---|---|---|
| transform | 34 | OMIT_FIRST_4, empty prefix and suffix → returns 0 for a 4-byte word |
| copy length | 4 | i ≥ 4 is required to enter the dictionary word path |
| distance | 34818 | = ((34 ≪ 10) + 1) + 1, pins transform_idx at 34 while max_distance is 0 |
| distance postfix | 3 | alphabet 400; spreads each extra bit over 8 distances → 11 bits per command |
| commands | 2²⁴ × 11 bit | = 23 068 672 bytes of payload, enough to drain exactly once |
| MLEN | 1 | nothing is produced, so nothing is consumed |
buffer_length field — but the ceiling is not
An attacker byte at index i lands at decoder-state offset 72 + i.
BROTLI_FAST_INPUT_SLACK = 28 means both fill loops only run while fewer than 28
input bytes remain, so at most 27 bytes are ever written. Drag the slider — this is the
measured behaviour, not a sketch.
3F at index 8 so the next index becomes 64
before → after the OOB write ringbuffer 0x51b000000080 → 0x51b000000080 ringbuffer_end 0x51b000000480 → 0x51b000000480 htree_command 0x521000002908 → 0x521000002908
The release that carried the fix added no regression test and no CHANGELOG entry, so the malformed-stream shape had to be reconstructed from the code — which is what the payload generator in this repo does.
| reading | NVD / CNA | Node.js | Imperva |
|---|---|---|---|
| severity | 9.2 CRITICAL | HIGH | HIGH |
| reported by | — | OpenAI Codex Security (Khai Tran, Sylvie Mayer) | Matteo Collina |
| fixed by | — | mcollina, aduh95 | Antoine du Hamel |