You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kestrel accepts arbitrary/unknown transfer-codings before a final chunked (TE: identity,chunked / anything,chunked) — surfaced to app, keep-alive; nginx/HAProxy reject-close [revisit of #43664 decision] #69577
Title: Kestrel accepts requests with arbitrary/unknown transfer-codings before a final "chunked" (TE: identity, chunked / gzip, chunked / anything, chunked) — surfaces raw value to the app and keeps the connection alive; nginx/HAProxy reject-close
Summary
Per the 2023 triage of #43664: "If there is an unknown value before 'chunked' the server/app should respond with a 501. We currently delegate that responsibility to middleware." I'd like to revisit that decision in light of the post-CVE-2025-55315 hardening posture, because the current behavior (verified today on 10.0.12 and 11.0.0-rc.1) is:
Transfer-Encoding: <ANY leading codings>, chunked is accepted — including identity, chunked, gzip, chunked, compress, chunked, deflate, chunked, split headers (TE: identity + TE: chunked), and fully unknown codings (foobar, chunked) — as long as the final element is chunked.
The body is decoded as plain chunked (app receives the de-chunked bytes).
The raw Transfer-Encoding value is surfaced to the application (Request.Headers.TransferEncoding == "identity, chunked").
The connection is kept alive and subsequent pipelined requests are processed.
Comparison (same bytes): nginx 1.31.5 → 501 + close; HAProxy 3.4.6 → 422 + close. RFC 9112 §6.1: "A server that receives a request message with a transfer coding it does not understand SHOULD respond with 501."
Why this matters post-55315
The desync primitive at the Kestrel level is confirmed: bytes following the terminating 0\r\n\r\n of such a request are framed as a new request (verified: a pipelined GET /SMUGGLED after TE: identity, chunked framing is parsed and served). The risk model is the standard one:
Kestrel as back-end: any intermediary that also accepts *, chunked but interprets the leading coding (older middleware, TE.TE-family configs) disagrees with Kestrel on the body boundary → request smuggling into the app.
Kestrel as front tier: ASP.NET apps commonly reverse-proxy (YARP et al.). Kestrel hands the app the raw Transfer-Encoding: identity, chunked header with a body that was actually decoded as plain chunked; a forwarder that forwards header+body inconsistently re-introduces the ambiguity downstream. Middleware that never opted into validation (i.e., the default) is exactly the "delegated responsibility" that never happens.
Posture consistency:Close connection after processing CL+TE #66671 closes the connection after CL+TE, and Harden chunked encoding parsing #68465 disabled chunked extensions outright rather than delegating — both treat parser leniency as server responsibility. Leaving leading transfer-codings unvalidated is the remaining member of that family.
Repro (raw socket, any Kestrel h1c/h1 endpoint)
POST /A HTTP/1.1\r\n
Host: h\r\n
Transfer-Encoding: foobar, chunked\r\n <- also: identity/gzip/compress/deflate
\r\n
5\r\nHELLO\r\n0\r\n\r\n
GET /MARKER HTTP/1.1\r\nHost: h\r\n\r\n
→ [200, 200], connection stays open, app sees Request.Headers["Transfer-Encoding"] == "foobar, chunked" and a 5-byte de-chunked body.
(TE: chunked, foobar — chunked non-final — is correctly rejected with 400, as is TE: identity alone.)
Ask
Reconsider validating the full transfer-coding list in Kestrel: reject (501 or 400) any request whose Transfer-Encoding contains a coding other than a final chunked — or at minimum unknown/unregistered codings — instead of delegating to middleware. Happy to share the raw-socket repro script.
Activity