Node2Shell: From Brotli Data to Remote Code Execution
The Brotli decoder in Node.js treated an invalid block switch as a temporary need for more input, so the streaming decoder kept appending bytes to an eight-byte internal buffer and wrote past its end. An attacker who supplies Brotli data that an application decompresses with node:zlib could corrupt process memory, leading to a crash, disclosure of process memory, or remote code execution.
nodejs.org
Published on nodejs.org
Commercial support for versions past the Maintenance LTS phase is available through our OpenJS Ecosystem Sustainability Program partners
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the decoder's state machine classified an invalid block switch as 'need more input' rather than a fatal format error, so the streaming path kept appending to a fixed eight-byte buffer without bounds checking.
Impact
An attacker who can supply Brotli data that an application decompresses with node:zlib can corrupt process memory, which can lead to a crash, disclosure of process memory, or remote code execution.
What the attacker needed
Attacker controls Brotli data; victim app decompresses it with node:zlib
The fix
It was fixed in the October 2026 security releases for the 26.x, 24.x and 22.x lines.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Brotli is a compression format, like a zip file, that Node.js can unpack. The unpacking code had a small fixed-size scratch area, and when it met a malformed file it kept writing into that area instead of stopping, so it spilled over into neighbouring memory. That kind of spill can crash the program, leak what is in memory, or in the worst case let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.