Skip to content

fix: omit framing and CR/LF custom headers from HTTP responses - #50

Merged
ruoka merged 2 commits into
masterfrom
cursor/critical-bug-management-47c9
Jul 27, 2026
Merged

fix: omit framing and CR/LF custom headers from HTTP responses#50
ruoka merged 2 commits into
masterfrom
cursor/critical-bug-management-47c9

Conversation

@cursor

@cursor cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

http::server wrote handler custom_headers after its own Content-Length / Connection lines with no filtering (net-http_server.c++m response 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's Content-Length: <body> and a second content-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:

  • framing/hop-by-hop names: content-length, transfer-encoding, connection
  • any name/value containing CR, LF, or NUL

Safe 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 flaky connect_with_timeout / socket::wait_for assertions may fail in this sandbox.
Open in Web View Automation 

cursoragent and others added 2 commits July 27, 2026 17:48
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
ruoka force-pushed the cursor/critical-bug-management-47c9 branch from 424c3df to a87cb32 Compare July 27, 2026 14:49
@ruoka
ruoka marked this pull request as ready for review July 27, 2026 14:49
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown
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
ruoka merged commit 9e9450e into master Jul 27, 2026
@ruoka
ruoka deleted the cursor/critical-bug-management-47c9 branch July 27, 2026 14:49
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants