Netty's HttpContentDecompressor accepts a maxAllocation parameter, stores it in a field, and reads it from two of five Content-Encoding branches. CVE-2026-42587 was tagged fixed in netty-4.2.13.Final on May 4, 2026. The file the advisory names by class is not in the fix commit's diff. The three branches that did not read the field at the start of the day still do not read the field at the end of the day.
CVE-2026-42587: Netty's HttpContentDecompressor Wires maxAllocation Through Two of Five Branches
vendor
pattern
cve
proof of concept
The field is on the class. Two of five branches read it.
HttpContentDecompressor in codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecompressor.java is a Netty channel handler that decompresses HTTP/1 request and response bodies according to the inbound Content-Encoding header. CVE-2026-42587 is what happens to the operator's maxAllocation setting when it lands on this dispatcher. The constructor takes a maxAllocation parameter and writes it into a field:
public HttpContentDecompressor(boolean strict, int maxAllocation) {
this.strict = strict;
this.maxAllocation = checkPositiveOrZero(maxAllocation, "maxAllocation");
}The field is read by newContentDecoder, the dispatcher called per request to pick a codec. The dispatcher is an if/else chain over the five supported encodings:
protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception {
Channel channel = ctx.channel();
if (GZIP.contentEqualsIgnoreCase(contentEncoding) ||
X_GZIP.contentEqualsIgnoreCase(contentEncoding)) {
return EmbeddedChannel.builder()
.channelId(channel.id())
.hasDisconnect(channel.metadata().hasDisconnect())
.config(channel.config())
.handlers(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP, maxAllocation))
.build();
}
if (DEFLATE.contentEqualsIgnoreCase(contentEncoding) ||
X_DEFLATE.contentEqualsIgnoreCase(contentEncoding)) {
final ZlibWrapper wrapper = strict ? ZlibWrapper.ZLIB : ZlibWrapper.ZLIB_OR_NONE;
return EmbeddedChannel.builder()
.channelId(channel.id())
.hasDisconnect(channel.metadata().hasDisconnect())
.config(channel.config())
.handlers(ZlibCodecFactory.newZlibDecoder(wrapper, maxAllocation))
.build();
}
if (Brotli.isAvailable() && BR.contentEqualsIgnoreCase(contentEncoding)) {
return EmbeddedChannel.builder()
.channelId(channel.id())
.hasDisconnect(channel.metadata().hasDisconnect())
.config(channel.config())
.handlers(new BrotliDecoder())
.build();
}
if (SNAPPY.contentEqualsIgnoreCase(contentEncoding)) {
return EmbeddedChannel.builder()
.channelId(channel.id())
.hasDisconnect(channel.metadata().hasDisconnect())
.config(channel.config())
.handlers(new SnappyFrameDecoder())
.build();
}
if (Zstd.isAvailable() && ZSTD.contentEqualsIgnoreCase(contentEncoding)) {
return EmbeddedChannel.builder()
.channelId(channel.id())
.hasDisconnect(channel.metadata().hasDisconnect())
.config(channel.config())
.handlers(new ZstdDecoder())
.build();
}
// 'identity' or unsupported
return null;
}The gzip and deflate branches pass maxAllocation into ZlibCodecFactory.newZlibDecoder. That is what the field is for. The other three branches construct decoders with no arguments at all: new BrotliDecoder(), new SnappyFrameDecoder(), new ZstdDecoder(). The field is declared three lines above. The other three branches do not reach for it.
An attacker who sends Content-Encoding: br against a service configured with new HttpContentDecompressor(1024) reaches a brotli decoder that has never heard the operator's number. The 1024 is a value on a field of an object whose dispatcher has selected a branch the field is not visible from. Same field, same class, same dispatcher; the branch the request lands in decides whether the cap exists.
ZstdDecoder shipped with maximumAllocationSize. The zstd branch never typed it.
ZstdDecoder in codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecoder.java has two public constructors:
public ZstdDecoder() {
this(4 * 1024 * 1024);
}
public ZstdDecoder(int maximumAllocationSize) {
this.maximumAllocationSize = ObjectUtil.checkPositiveOrZero(maximumAllocationSize, "maximumAllocationSize");
this.maxForwardBytes = maximumAllocationSize > 0 ? maximumAllocationSize : DEFAULT_MAX_FORWARD_BYTES;
}The 1-arg constructor pre-existed the CVE. The maximumAllocationSize field is read inside decode() to bound the per-frame allocation:
outBuffer = ctx.alloc().heapBuffer((int) (maximumAllocationSize == 0 ?
uncompressedLength : Math.min(maximumAllocationSize, uncompressedLength)));The cap exists on the decoder. The cap is parameterized. The dispatcher calls the constructor that defaults the cap to 4 MiB. The operator's setting and the constructor that would honor it are in the same package, and never meet.
The fix is in BrotliDecoder and the HTTP/2 dispatcher. It is not in HttpContentDecompressor.
The commit that closes CVE-2026-42587 is 1026c3a4, merged on May 4, 2026, six hours before netty-4.2.13.Final was released. Its git show --stat:
codec-compression/.../BrotliDecoder.java | 18 +-
codec-http2/.../DelegatingDecompressorFrameListener.java | 8 +-
codec/http2/.../DataCompressionHttp2Test.java | 288 +-
pom.xml | 2 +-Four files. The diff in BrotliDecoder.java adds a new constructor accepting outputBufferSize, passes it to decoder.pull(outputBufferSize), and uses it as the flush threshold:
- public BrotliDecoder(int inputBufferSize) {
+ public BrotliDecoder(int inputBufferSize, int outputBufferSize) {
this.inputBufferSize = ObjectUtil.checkPositive(inputBufferSize, "inputBufferSize");
+ this.outputBufferSize = ObjectUtil.checkPositive(outputBufferSize, "outputBufferSize");
}
private void forwardOutput(ChannelHandlerContext ctx) {
- ByteBuffer nativeBuffer = decoder.pull();
+ ByteBuffer nativeBuffer = decoder.pull(outputBufferSize);The diff in DelegatingDecompressorFrameListener.java, the HTTP/2 sibling of HttpContentDecompressor, changes two call sites:
- .handlers(new BrotliDecoder())
+ .handlers(new BrotliDecoder(maxAllocation))- .handlers(new ZstdDecoder())
+ .handlers(new ZstdDecoder(maxAllocation))The HTTP/2 dispatcher now wires the operator's maxAllocation through to brotli and zstd. The HTTP/1 dispatcher, HttpContentDecompressor, lives in the codec-http module. It is not in the four-line git show --stat above. At the release tag netty-4.2.13.Final:
$ git show netty-4.2.13.Final:codec-http/.../HttpContentDecompressor.java \
| grep -n "new BrotliDecoder\|new SnappyFrameDecoder\|new ZstdDecoder"
120: .handlers(new BrotliDecoder())
129: .handlers(new SnappyFrameDecoder())
138: .handlers(new ZstdDecoder())The class the CVE description names by name has the same three no-arg constructors at the patched release that it had the day before the patch. As of the tip of the 4.2 branch on May 20, 2026, sixteen days after the release, those three lines are still there.
The mechanical reason the HTTP/1 codepath isn't an open OOM anymore is the new constructor chain on BrotliDecoder: new BrotliDecoder() now resolves to this(8192, 64 * 1024), capping the per-pull native buffer at brotli's DEFAULT_MAX_FORWARD_BYTES. The unbounded decoder.pull() that produced the original allocation bomb has been bounded by a hardcoded 64 KiB. That is enough to defuse the advisory's "unbounded memory allocation" sentence. It is not enough to honor the operator's setting. An operator who configured maxAllocation = 1024 to clamp memory under a known-hostile pattern gets 64 KiB per pull and discovers that the configured number is documentation. The new javadoc admits this, in two sentences added to DelegatingDecompressorFrameListener:
Some compression codecs will output buffers up to 64 KiB in size,
even if {@code maxAllocation} is configured lower.The javadoc is in the HTTP/2 file. It applies to the HTTP/1 file too. The HTTP/1 file does not say so.
Snappy is on the advisory. Snappy is not in the fix.
The CVE-2026-42587 description lists three codecs as bypasses: brotli, zstd, snappy. The fix commit message lists two codecs as fixed: brotli, zstd. The third sentence of the commit message:
Snappy is specified to at most produce 64 KiB blocks, and do not permit easily changing this, so we skip it.
The advisory lists snappy because HttpContentDecompressor's snappy branch ignores maxAllocation. The commit waves snappy off because the format caps single blocks at 64 KiB regardless. Both statements are true. One of them is the wrong sentence to write into a security advisory. The advisory's reader sees a list of three bypasses and a release that closes the list; the codebase's reader sees a fix that closes two of three and a snappy branch that still calls a no-arg constructor in the file the advisory pointed at.
Three of five branches. The patch did not change the count.
This is the parallel-implementation-gap shape, and a particularly clean instance of it. The class has five branches that all expose the same client-facing contract: decompress the body according to Content-Encoding. Two branches gate. Three branches do not. The CVE names the three.
The pattern has shown up across packages in one monorepo, across runtimes in one server, across upload-versus-download directions in one module, across two branches of one function, across sibling methods on one Java controller class, across exported keys of one object literal, and across nine independent component modules in one vendor's monorepo. This exhibit is the across-codec-branches-in-one-dispatcher variant: the gate failing to copy across five if/else branches inside one method body on one class.
The Axios exhibit is the closest analogue. Axios's lib/adapters/http.js forks on responseType === 'stream'. The buffered branch attaches a byte counter to the chunk handler it had open and rides the maxContentLength check inside that counter. The streaming branch hands the readable to the caller and never had a counter to attach the check to. Where the counter was, the limit was; where the counter wasn't, the limit wasn't. Netty's gzip and deflate branches route through ZlibCodecFactory.newZlibDecoder(wrapper, maxAllocation), a factory whose signature makes the call site type the field name. Netty's brotli, snappy, and zstd branches route through direct new of the decoder class. The constructors that don't take the parameter make the field name nothing the call site is forced to remember. Five sibling branches in one method body, three of them written with a constructor that doesn't require the call site to even think about the field, the field declared three lines above.
The HTTP/2 patch is what the HTTP/1 patch would look like, line-for-line. new BrotliDecoder() becomes new BrotliDecoder(maxAllocation). new ZstdDecoder() becomes new ZstdDecoder(maxAllocation). The change is two lines in the dispatcher, and the constructor it would call is already there. The patch did not type those two lines into the file the advisory names.
PoC: GHSA-f6hv-jmp6-3vwv
Two of five branches passed maxAllocation through on May 3. Two of five branches pass maxAllocation through on May 21. The patch did not change the count.