fix: omit framing and CR/LF custom headers from HTTP responses - #50
Merged
Conversation
http::server appended handler custom_headers after writing Content-Length and Connection. Echoing request Content-Length (copy-all headers) or values containing CR/LF/NUL produced duplicate framing or response splitting for proxies that prefer the last Content-Length. Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
http::server appended handler custom_headers after writing Content-Length and Connection. Echoing request Content-Length (copy-all headers) or values containing CR/LF/NUL produced duplicate framing or response splitting for proxies that prefer the last Content-Length. Also skip other hop-by-hop / framing-adjacent names (Upgrade, Keep-Alive, TE, Trailer(s), proxy-*). Co-authored-by: Cursor <cursoragent@cursor.com>
ruoka
force-pushed
the
cursor/critical-bug-management-47c9
branch
from
July 27, 2026 14:49
424c3df to
a87cb32
Compare
ruoka
marked this pull request as ready for review
July 27, 2026 14:49
Contributor
Author
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
ruoka
added a commit
that referenced
this pull request
Jul 27, 2026
Filter custom response headers for framing/hop-by-hop names and CR/LF/NUL before writing them after the server's Content-Length / Connection lines. Co-authored-by: Cursor <cursoragent@cursor.com>
ruoka
added a commit
that referenced
this pull request
Jul 28, 2026
SSE reflected request Origin into Access-Control-Allow-Origin without the custom-header CTL filter from #50. Default MCP-style http://host:* allowlists still match after an embedded CR, enabling response header injection. Gate-deny custom headers now use the same writer. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
http::serverwrote handlercustom_headersafter its ownContent-Length/Connectionlines with no filtering (net-http_server.c++mresponse path).Trigger: A handler that copies request headers into the response (pattern exercised in middleware tests) receives a GET/POST with
Content-Length: 0(or any CL ≠ body size). The response then contains both the server'sContent-Length: <body>and a secondcontent-length: <request CL>.Impact: Proxies that prefer the last Content-Length desynchronize from the real body (HTTP response smuggling / cache desync). Values containing CR/LF/NUL in custom headers similarly enable response splitting (including CORS Origin bare-CR reflection when the origin validator allows it).
Fix
Before writing custom response headers, skip:
content-length,transfer-encoding,connectionSafe custom headers (e.g.
x-ok) are still emitted.Test plan
NET_DISABLE_NETWORK_TESTS=0 tools/CB.sh debug test— new scenarios pass (omit echoed CL; omit CR/LF values). Unrelated flakyconnect_with_timeout/socket::wait_forassertions may fail in this sandbox.