-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"### The field is on the class. Two of five branches read it.\n\n`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:\n\n```java\npublic HttpContentDecompressor(boolean strict, int maxAllocation) {\n this.strict = strict;\n this.maxAllocation = checkPositiveOrZero(maxAllocation, \"maxAllocation\");\n}\n```\n\nThe 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:\n\n```java\nprotected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception {\n Channel channel = ctx.channel();\n if (GZIP.contentEqualsIgnoreCase(contentEncoding) ||\n X_GZIP.contentEqualsIgnoreCase(contentEncoding)) {\n return EmbeddedChannel.builder()\n .channelId(channel.id())\n .hasDisconnect(channel.metadata().hasDisconnect())\n .config(channel.config())\n .handlers(ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP, maxAllocation))\n .build();\n }\n if (DEFLATE.contentEqualsIgnoreCase(contentEncoding) ||\n X_DEFLATE.contentEqualsIgnoreCase(contentEncoding)) {\n final ZlibWrapper wrapper = strict ? ZlibWrapper.ZLIB : ZlibWrapper.ZLIB_OR_NONE;\n return EmbeddedChannel.builder()\n .channelId(channel.id())\n .hasDisconnect(channel.metadata().hasDisconnect())\n .config(channel.config())\n .handlers(ZlibCodecFactory.newZlibDecoder(wrapper, maxAllocation))\n .build();\n }\n if (Brotli.isAvailable() && BR.contentEqualsIgnoreCase(contentEncoding)) {\n return EmbeddedChannel.builder()\n .channelId(channel.id())\n .hasDisconnect(channel.metadata().hasDisconnect())\n .config(channel.config())\n .handlers(new BrotliDecoder())\n .build();\n }\n\n if (SNAPPY.contentEqualsIgnoreCase(contentEncoding)) {\n return EmbeddedChannel.builder()\n .channelId(channel.id())\n .hasDisconnect(channel.metadata().hasDisconnect())\n .config(channel.config())\n .handlers(new SnappyFrameDecoder())\n .build();\n }\n\n if (Zstd.isAvailable() && ZSTD.contentEqualsIgnoreCase(contentEncoding)) {\n return EmbeddedChannel.builder()\n .channelId(channel.id())\n .hasDisconnect(channel.metadata().hasDisconnect())\n .config(channel.config())\n .handlers(new ZstdDecoder())\n .build();\n }\n\n // 'identity' or unsupported\n return null;\n}\n```\n\nThe 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.\n\nAn 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.\n\n### ZstdDecoder shipped with `maximumAllocationSize`. The zstd branch never typed it.\n\n`ZstdDecoder` in `codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecoder.java` has two public constructors:\n\n```java\npublic ZstdDecoder() {\n this(4 * 1024 * 1024);\n}\n\npublic ZstdDecoder(int maximumAllocationSize) {\n this.maximumAllocationSize = ObjectUtil.checkPositiveOrZero(maximumAllocationSize, \"maximumAllocationSize\");\n this.maxForwardBytes = maximumAllocationSize > 0 ? maximumAllocationSize : DEFAULT_MAX_FORWARD_BYTES;\n}\n```\n\nThe 1-arg constructor pre-existed the CVE. The `maximumAllocationSize` field is read inside `decode()` to bound the per-frame allocation:\n\n```java\noutBuffer = ctx.alloc().heapBuffer((int) (maximumAllocationSize == 0 ?\n uncompressedLength : Math.min(maximumAllocationSize, uncompressedLength)));\n```\n\nThe 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.\n\n### The fix is in `BrotliDecoder` and the HTTP/2 dispatcher. It is not in `HttpContentDecompressor`.\n\nThe 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`:\n\n```\ncodec-compression/.../BrotliDecoder.java | 18 +-\ncodec-http2/.../DelegatingDecompressorFrameListener.java | 8 +-\ncodec/http2/.../DataCompressionHttp2Test.java | 288 +-\npom.xml | 2 +-\n```\n\nFour 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:\n\n```diff\n- public BrotliDecoder(int inputBufferSize) {\n+ public BrotliDecoder(int inputBufferSize, int outputBufferSize) {\n this.inputBufferSize = ObjectUtil.checkPositive(inputBufferSize, \"inputBufferSize\");\n+ this.outputBufferSize = ObjectUtil.checkPositive(outputBufferSize, \"outputBufferSize\");\n }\n\n private void forwardOutput(ChannelHandlerContext ctx) {\n- ByteBuffer nativeBuffer = decoder.pull();\n+ ByteBuffer nativeBuffer = decoder.pull(outputBufferSize);\n```\n\nThe diff in `DelegatingDecompressorFrameListener.java`, the HTTP/2 sibling of `HttpContentDecompressor`, changes two call sites:\n\n```diff\n- .handlers(new BrotliDecoder())\n+ .handlers(new BrotliDecoder(maxAllocation))\n```\n\n```diff\n- .handlers(new ZstdDecoder())\n+ .handlers(new ZstdDecoder(maxAllocation))\n```\n\nThe 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`:\n\n```\n$ git show netty-4.2.13.Final:codec-http/.../HttpContentDecompressor.java \\\n | grep -n \"new BrotliDecoder\\|new SnappyFrameDecoder\\|new ZstdDecoder\"\n120: .handlers(new BrotliDecoder())\n129: .handlers(new SnappyFrameDecoder())\n138: .handlers(new ZstdDecoder())\n```\n\nThe 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.\n\nThe 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`:\n\n```\nSome compression codecs will output buffers up to 64 KiB in size,\neven if {@code maxAllocation} is configured lower.\n```\n\nThe javadoc is in the HTTP/2 file. It applies to the HTTP/1 file too. The HTTP/1 file does not say so.\n\n### Snappy is on the advisory. Snappy is not in the fix.\n\nThe 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:\n\n> Snappy is specified to at most produce 64 KiB blocks, and do not permit easily changing this, so we skip it.\n\nThe 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.\n\n### Three of five branches. The patch did not change the count.\n\nThis is the [parallel-implementation-gap](https://nefariousplan.com/patterns/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.\n\nThe pattern has shown up [across packages in one monorepo](https://nefariousplan.com/posts/astro-shipped-two-image-endpoints), [across runtimes in one server](https://nefariousplan.com/posts/mlflow-basic-auth-only-gated-flask), [across upload-versus-download directions in one module](https://nefariousplan.com/posts/mcp-atlassian-the-patch-guarded-the-writes), [across two branches of one function](https://nefariousplan.com/posts/axios-maxcontentlength-was-inside-the-buffer-loop), [across sibling methods on one Java controller class](https://nefariousplan.com/posts/jeecgboot-mlogin-validatecaptcha-sibling-method), [across exported keys of one object literal](https://nefariousplan.com/posts/nocobase-cve-2026-41641-checksql-two-of-three-actions), and [across nine independent component modules in one vendor's monorepo](https://nefariousplan.com/posts/camel-cve-2026-40858-same-five-lines-eight-components). 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.\n\nThe [Axios exhibit](https://nefariousplan.com/posts/axios-maxcontentlength-was-inside-the-buffer-loop) 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.\n\nThe 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.\n\nPoC: [GHSA-f6hv-jmp6-3vwv](https://github.com/netty/netty/security/advisories/GHSA-f6hv-jmp6-3vwv)","closing_line":"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.","hook_md":"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.","post_id":379,"slug":"netty-cve-2026-42587-two-of-five-branches","title":"CVE-2026-42587: Netty's HttpContentDecompressor Wires maxAllocation Through Two of Five Branches","type":"initial","unreadable_sentence":"Two of five branches passed `maxAllocation` through. The patch did not change the count."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCalKH/wAKCRDeZjl4jgkQ Jgh7AQCjF7cwt2e1vEJ0A+Vid3S62rw3CNBdC1hBpG1D0aVmNAD+Kv7EX/tJ5TnI DmJ6X0YhmGTGy27xTdReSYvs9qiS2AU= =A41z -----END PGP SIGNATURE-----