-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The function's name was the question. The question was the wrong one.\n\n`io.netty.handler.codec.http.HttpUtil` defines the predicate the HTTP/1 decoder leans on to decide whether a request body is chunk-framed:\n\n```java\npublic static boolean isTransferEncodingChunked(HttpMessage message) {\n return message.headers().containsValue(\n HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED, true);\n}\n```\n\n`containsValue` in `HttpHeaders` is not equality. It splits each header value on commas and asks whether any trimmed token matches:\n\n```java\npublic boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase) {\n Iterator itr = valueCharSequenceIterator(name);\n while (itr.hasNext()) {\n if (containsCommaSeparatedTrimmed(itr.next(), value, ignoreCase)) {\n return true;\n }\n }\n return false;\n}\n```\n\n`containsCommaSeparatedTrimmed` walks each comma-delimited segment, trims optional whitespace, and tests case-insensitive equality. For `Transfer-Encoding: chunked, identity` it splits into `[chunked, identity]`, compares the first token to `chunked`, returns true. For `Transfer-Encoding: gzip, chunked` it does the same. For `Transfer-Encoding: identity, chunked, gzip` it does the same. The predicate's grain is set membership. Order does not enter it.\n\n`HttpObjectDecoder.readHeaders0` then used that predicate as the only check before flipping the body parser into chunked mode:\n\n```java\nif (HttpUtil.isTransferEncodingChunked(message)) {\n this.chunked = true;\n if (!contentLengthFields.isEmpty() && message.protocolVersion() == HttpVersion.HTTP_1_1) {\n handleTransferEncodingChunkedWithContentLength(message);\n }\n return State.READ_CHUNK_SIZE;\n}\n```\n\nThe return value is `State.READ_CHUNK_SIZE`. The decoder begins reading the body as a sequence of `hex-size CRLF data CRLF` chunks terminated by a zero-size chunk. The framing decision has been made.\n\n## What RFC 9112 §6.1 actually says\n\nThe standard's text is short. Quoting it whole because the precision is the point:\n\n> If a Transfer-Encoding header field is present in a request and the chunked transfer coding is not the final encoding, the message body length cannot be determined reliably; the server MUST respond with the 400 (Bad Request) status code and then close the connection.\n\nThere is no \"MAY\" in that sentence. The server is not invited to accept the message under any chunk-framing inference. The server is told to refuse it.\n\nThis text has been in HTTP/1.1's framing rules in some form since RFC 7230. RFC 9112 (June 2022) made the wording more emphatic. The reason it is in there at all is that any HTTP intermediary will choose a body length somehow: ignore `chunked` because it is not last, fall back to `Content-Length`, treat the request as terminated at the headers, or pass it on. Two intermediaries that choose differently produce desync. Desync is HTTP request smuggling.\n\nNetty was a server in this sentence. Netty did not respond 400. Netty entered chunked-reading mode.\n\n## What a smuggling chain looks like\n\nThe vulnerable scenario lives at the seam between a front-end proxy and a Netty backend. The proxy and the backend make different framing decisions because they read different bytes from the same header.\n\nA reasonable proxy reading `Transfer-Encoding: chunked, identity` follows the standard, considers chunked-not-last to be malformed, declines to treat the message as chunked, and falls back on `Content-Length: `. Many production proxies do exactly that. Some proxies, faced with an unknown final coding `identity`, strip the token they do not recognise, forward `Transfer-Encoding: chunked` to the backend, and pass through the `Content-Length` header alongside it. Some proxies strip the entire `Transfer-Encoding` header when it does not match `chunked` exactly, and forward only `Content-Length`. Each of those proxy behaviours is documented and shipping.\n\nNetty, pre-patch, reads `Transfer-Encoding: chunked, identity` and frames the body as chunked. Whatever the proxy did with `Content-Length` is invisible at this point. The decoder consumes bytes until it sees a `0\\r\\n\\r\\n` terminator and treats everything after as the start of the next request.\n\nThe advisory's published test case is a single TCP write that the proxy reads as one POST with a 1-byte body, and Netty reads as a chunked POST followed by a smuggled GET:\n\n```http\nPOST / HTTP/1.1\nHost: target.example\nTransfer-Encoding: chunked, identity\nContent-Length: 65\n\n0\n\nGET /admin/users HTTP/1.1\nHost: target.example\nConnection: close\n\n```\n\nThe proxy honours `Content-Length: 65`, forwards 65 bytes of body, considers the request complete. To the proxy, the smuggled `GET /admin/users` is the next request on the connection and inherits the previous client's authentication, IP allowlist, mTLS identity, and rate-limit bucket. Netty honours `Transfer-Encoding: chunked`, reads `0\\r\\n\\r\\n`, considers the body complete, and treats the bytes after as a fresh request on the same connection. The two systems agree that there are two requests on the wire. They disagree about where the first one ends. That disagreement is the primitive.\n\nEvery HTTP/1.1 smuggling attack reduces to this disagreement. The vulnerable input is whatever pair of bytes the proxy and the backend disambiguate differently. Here the bytes are the seven that spell `, identity` after `chunked`.\n\n## The patch checks the last value's tail\n\nThe fix in commit `485f11d322` adds twenty-three lines to `readHeaders0`:\n\n```diff\n if (HttpUtil.isTransferEncodingChunked(message)) {\n this.chunked = true;\n- if (!contentLengthFields.isEmpty() && message.protocolVersion() == HttpVersion.HTTP_1_1) {\n- handleTransferEncodingChunkedWithContentLength(message);\n+ if (message.protocolVersion() == HttpVersion.HTTP_1_1) {\n+ Iterator encodingIt =\n+ message.headers().valueCharSequenceIterator(HttpHeaderNames.TRANSFER_ENCODING);\n+ // Validate that chunked is the last encoding.\n+ CharSequence v = null;\n+ while (encodingIt.hasNext()) {\n+ v = encodingIt.next();\n+ }\n+ final int vLen = v.length();\n+ final int chunkedValueLength = HttpHeaderValues.CHUNKED.length();\n+ if (vLen > chunkedValueLength && !AsciiString.regionMatches(v, true, vLen - chunkedValueLength,\n+ HttpHeaderValues.CHUNKED, 0, chunkedValueLength)) {\n+ throw new IllegalArgumentException(\n+ \"chunked must be the last encoding present in the Transfer-Encoding header\");\n+ }\n+ if (!contentLengthFields.isEmpty()) {\n+ handleTransferEncodingChunkedWithContentLength(message);\n+ }\n }\n return State.READ_CHUNK_SIZE;\n }\n```\n\nThe new logic iterates header values, takes the last one, and checks whether its tail spells `chunked`. If the tail does not match, the decoder throws. That is the entire fix.\n\nThe test case that has to pass is the one Georgieva wrote:\n\n```java\n@Test\npublic void testChunkedNotLastInTransferEncoding() {\n String requestStr = \"GET /some/path HTTP/1.1\\r\\n\" +\n \"Transfer-Encoding: chunked, identity\\r\\n\" +\n \"Content-Length: 1\\r\\n\" +\n \"Host: netty.io\\r\\n\\r\\n\" +\n \"a\";\n testInvalidHeaders0(requestStr);\n}\n```\n\nTwo things to read out of that test. First, the request the patch refuses is exactly the request the pre-patch code accepted. Second, the test asserts that the message is rejected with an invalid-headers error, which surfaces in the HTTP/1 decoder as a `DecoderException`. There is no graceful 400 from Netty itself; the connection-level decoder fails. Whatever sits above Netty in the application has to translate that failure into a 400 response and close the connection. The standard's \"MUST respond 400 and close\" obligation is split: Netty rejects the message, the framework must respond.\n\nThe shape of the check is also worth naming. It compares the last seven bytes of the last header value against the literal `chunked` using `AsciiString.regionMatches`. It does not parse the comma-separated list. It does not enumerate inner tokens. It trusts that if the value ends with `chunked`, chunked is last. That trust holds for well-formed values; it does not hold under all whitespace combinations the grammar allows. `Transfer-Encoding: chunked, identity, chunked` ends in `chunked` and is accepted, even though `chunked` appears twice and only the second occurrence is final. That construction is also forbidden by RFC 9112 §6.1's \"MUST NOT be applied more than once\" clause, and Netty's new check does not enforce that clause either. The check answers the narrow question it was given.\n\n## Five smuggling-class fixes in one release\n\nThe same release that closed CVE-2026-42585 closed four other things in Netty's HTTP/1 codec:\n\n| Fix | What it closed |\n|---|---|\n| CVE-2026-42585 (this post) | `Transfer-Encoding: chunked, identity` enters chunked-reading mode |\n| CVE-2026-42580 | The chunk-size parser does `result *= 16; result += digit` in `int` and only rejects negatives; a value like `100000004` overflows positively and the consumed-length disagrees with the on-wire size |\n| GHSA-57rv-r2g8-2cj3 (`HttpClientCodec` response desync) | The client's request queue was polled before checking whether the response was 1xx Informational; the wrong outbound request was paired with subsequent responses |\n| Commit `6eea1bc7ef` | `DefaultHttpRequest.setUri()` was not running the URI validator that `DefaultHttpRequest`'s constructor was running, so the [December 2025 CRLF-injection fix](https://github.com/netty/netty/security/advisories/GHSA-84h7-rjj3-6jx4) (CVE-2025-67735) was bypassable by calling `setUri()` instead |\n| Commit `d2475645d8` | The default behaviour when a message carried both `Transfer-Encoding: chunked` and `Content-Length` flipped from \"silently remove `Content-Length`\" (RFC 7230 era) to \"throw `ContentLengthNotAllowedException`\" (RFC 9112 era); the old behaviour is still available behind `setUseRfc9112TransferEncoding(false)` |\n\nThree of those are HTTP request smuggling under CWE-444. One is a response-side desync that is the dual of smuggling. One is a hardening of the canonical TE+CL case that has produced CVEs in every HTTP/1.1 parser ever shipped. They were all developed in private and merged the same day as `Merge commit from fork` entries on Netty's 4.1 branch, batched into 4.1.133.Final and 4.2.13.Final.\n\nFive smuggling-class fixes in one release is not a coincidence. It is what happens when a project pulls a coordinated cross-research effort against a single component over months and ships the results together. The catalog calls this shape [design-debt-driver](/patterns/design-debt-driver): a component whose bug class keeps recurring not because the maintainers are sloppy, but because the design substrate the component lives on continues to produce the same primitive. HTTP/1.1 message framing is that substrate. The 1999 RFC was ambiguous, the 2014 RFC tightened the language, the 2022 RFC tightened it further. Every HTTP/1.1 parser ever shipped has fixed a smuggling bug. Netty has fixed [more](https://github.com/netty/netty/security/advisories) than most because Netty is what the JVM ecosystem reaches for when it needs HTTP/1: Spring WebFlux through Reactor Netty, Vert.x, Play, gRPC-Java, Elasticsearch's transport, every framework whose transitive `netty-codec-http` pin moves only when somebody notices.\n\nThe `4.1.134.Final` release is dated nine days after `4.1.133.Final`. It does not yet carry a smuggling fix. That is the longest such interval in the last six months.\n\nPoC and references:\n- GHSA: [GHSA-38f8-5428-x5cv](https://github.com/netty/netty/security/advisories/GHSA-38f8-5428-x5cv)\n- Patch commit: [`485f11d322`](https://github.com/netty/netty/commit/485f11d322c61d64a188aae412b4627d44a02664)\n- RFC 9112 §6.1: ","closing_line":"Netty asked whether chunked was present. The standard asked whether chunked was last.","hook_md":"`HttpUtil.isTransferEncodingChunked(message)` returns `true` when the comma-separated `Transfer-Encoding` header contains the token `chunked` anywhere in the list. The function's name reads as a question, and the answer to that question was the gate Netty's HTTP/1 decoder used to decide whether the body was chunk-framed.\n\nRFC 9112 §6.1 does not ask whether chunked is present. RFC 9112 §6.1 says that if a `Transfer-Encoding` is present in a request and chunked is not the final coding, the message body length cannot be determined reliably, and the server MUST respond 400 and close the connection. Netty's gate has been the answer to the wrong question for as long as the decoder has existed. On May 5, 2026, Violeta Georgieva pushed a test case named `testChunkedNotLastInTransferEncoding` whose request body was `Transfer-Encoding: chunked, identity`. The fix was the four lines that had to make that test pass.","post_id":385,"slug":"netty-cve-2026-42585-chunked-was-not-last","title":"CVE-2026-42585: Netty Asked Whether Chunked Was Present. RFC 9112 Asked Whether Chunked Was Last.","type":"initial","unreadable_sentence":"Netty asked whether chunked was present. The standard asked whether chunked was last."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCav+rJwAKCRDeZjl4jgkQ Jgu9AP45hIK3w+dcV/EAPU4tNI4psmClRMgnXPDecXLKEpMYtwEAufUA/XklfiSb 9ULi0t8RfXOZicPGRU9oOi2zze3QOwA= =8Sr3 -----END PGP SIGNATURE-----