
CVE-2026-111497 — Node.js Brotli Decoder OOB Write: Deep Analysis & Structural Unreachability Proof. MLEN_MAX = BLOCK_SIZE_CAP = 2^24 makes RCE structurally unreachable.
CVE-2026-111497 — Node.js Brotli Decoder OOB Write: Deep Analysis & Structural Unreachability Proof
Key Finding · Analysis · PoC Tools · Detection · Lab · Writeup
Independent security research into CVE-2026-111497, a High-severity OOB write in the Brotli decoder bundled with Node.js (deps/brotli). While the code bug is real — the BROTLI_SAFE macro silently drops the return value on the fast decoding path — we prove the vulnerable code path is structurally unreachable from any Brotli stream, valid or malformed.
The Brotli specification caps MLEN (metablock uncompressed length) at exactly 2^24 = 16,777,216, which is identical to BROTLI_BLOCK_SIZE_CAP, the initial block_length when NBLTYPES = 1. This means the block-switch trigger condition (block_length == 0 with NBLTYPES ≤ 1) can never fire during stream processing — the metablock ends before the counter is exhausted.
Practical impact: DoS (infinite CPU loop) via header corruption, not RCE.
Author: Qi Deng | Writeup: Substack | Date: 2026-10-22
| Field | Value |
|---|---|
| CVE | CVE-2026-111497 |
| CWE | CWE-787 (Out-of-bounds Write), CWE-252 (Unchecked Return Value) |
| CVSS 4.0 | 9.2 (Critical) — disputed: we argue High is more accurate |
| Vendor Rating | High (Node.js), no CVSS vector published |
| Component | deps/brotli/c/dec/decode.c (Google Brotli decoder) |
| Upstream Fix | google/brotli@0ed4268a |
| Reporter | Matteo Collina |
| Affected | Node.js < 22.23.4, < 24.22.1, < 26.12.1; Brotli < 1.0.10, < 1.1.1, < 1.2.1 |
The vulnerability is real but structurally unreachable.
Max MLEN (RFC 7932, 6 nibbles) = 2^24 = 16,777,216
BROTLI_BLOCK_SIZE_CAP (state.h) = 1<<24 = 16,777,216
═══════════
Exactly equal — by design
When NBLTYPES = 1:
block_length initializes to 16,777,216i and block_length reach 0 simultaneouslyblock_length is decremented, by which point i = 0 and the loop exits cleanlyThis is not a coincidence — it's a deliberate design constraint in the Brotli specification that prevents the single-block-type fast path from ever needing a block switch.
See analysis/structural_proof.md for the full formal argument with source code traces.
BROTLI_SAFE drops return value// decode.c:1890 — the VULNERABLE macro
#define BROTLI_SAFE(METHOD)
{
if (safe) {
if (!Safe##METHOD) { // safe path: CHECKS return
result = BROTLI_DECODER_NEEDS_MORE_INPUT;
goto saveStateAndReturn;
}
} else {
METHOD; // fast path: DROPS return
}
}
Three block-switch sites call through this macro:
BROTLI_SAFE(DecodeLiteralBlockSwitch(s)); — line 2243BROTLI_SAFE(DecodeCommandBlockSwitch(s)); — line 1941BROTLI_SAFE(DecodeDistanceBlockSwitch(s)); — line 2049All three wrappers return void, making the return value unrecoverable:
static void BROTLI_NOINLINE DecodeLiteralBlockSwitch(BrotliDecoderState* s) {
DecodeLiteralBlockSwitchInternal(0, s); // BROTLI_BOOL return → void
}
DecodeBlockTypeAndLength() returns BROTLI_FALSE when max_block_type ≤ 1:
static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength(
int safe, BrotliDecoderState* s, int tree_type) {
brotli_reg_t max_block_type = s->num_block_types[tree_type];
// ...
if (max_block_type <= 1) {
return BROTLI_FALSE; // ← format error, but fast path ignores this
}
// ... read new block type and length (never reached) ...
}
This function is called when block_length[tree_type] == 0. But with NBLTYPES = 1, block_length starts at BROTLI_BLOCK_SIZE_CAP (16M), and MLEN caps at the same value. The counter reaches 0 only at the exact end of the metablock, where the loop exits before re-checking.
Upstream commit 0ed4268a ("Detect and report invalid stream earlier"):
DecodeBlockTypeAndLength return type from BROTLI_BOOL to BrotliDecoderErrorCodeBROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH (-17) for the format errorBROTLI_SAFE_WITH_STATUS macro that checks the return on both paths:#define BROTLI_SAFE_WITH_STATUS(METHOD)
{
BrotliDecoderErrorCode status;
if (safe) { status = Safe##METHOD; }
else { status = METHOD; } // fast path: NOW CHECKS return
if (status != BROTLI_DECODER_SUCCESS) {
result = status;
goto saveStateAndReturn;
}
}
If an attacker could somehow trigger the block switch with NBLTYPES = 1:
block_length[i] == 0 with NBLTYPES ≤ 1
↓
DecodeBlockTypeAndLength returns BROTLI_FALSE (ignored)
↓
block_type_rb[] not updated → stale values
↓
Stale block_type_rb → OOB read on context_map
↓
Garbage htree pointer → corrupted Huffman decode
↓
Corrupted distance_code → wrong ring buffer offset
↓
memmove16(copy_dst, copy_src) at controlled offset
↓
16-byte OOB write on heap
Primitive characteristics:
| Property | Value |
|---|---|
| Write size | Fixed 16 bytes (memmove16) |
| Write offset | Ring buffer base + pos, influenced by corrupted distance_code |
| Write content | 16 bytes from ring buffer at copy_src, partially attacker-influenced |
| Ring buffer slack | 542 bytes (kRingBufferWriteAheadSlack) |
| PoC Repository | Result | Reason |
|---|---|---|
| CaterMaoZi/CVE-2026-111497-POC | 1200+ fuzz iterations, 0 crashes | MLEN = BLOCK_SIZE_CAP prevents trigger |
| dimasma0305/CVE-2026-111497-POC | "Not portable to ASLR-enabled Node.js" | Used non-PIE harness with lowered BLOCK_SIZE_CAP |
| TheFool-TAROT | DoS only; local RCE only without ASLR | Required --predictable flag + separate info leak (CVE-2024-21524) |