Skip to content

fix: omit SSE CORS Origin values containing CR/LF/NUL - #52

Merged
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-9ae5
Jul 28, 2026
Merged

fix: omit SSE CORS Origin values containing CR/LF/NUL#52
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-9ae5

Conversation

@cursor

@cursor cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

SSE CORS reflected the request Origin into Access-Control-Allow-Origin without the custom-header CTL filter from #50. With default MCP-style http://host:* allowlists, an Origin like http://127.0.0.1:PORT\rX-Evil: 1 still matches after the port colon, so the CR is written onto the response wire (header injection).

Root cause

The SSE takeover path writes ACAO directly to the stream instead of going through write_custom_response_headers. Port-wildcard Origin matching only checks prefix + :, so embedded CR/NUL after the port is accepted.

Fix

  • Skip reflecting Origin when the value contains CR/LF/NUL (reuse is_unsafe_response_header).
  • Write SSE gate-deny custom headers via write_custom_response_headers (same filter as normal responses).
  • Regression test: wildcard allowlist + CR-injected Origin → no ACAO, no injected header.

Validation

NET_DISABLE_NETWORK_TESTS=0 tools/CB.sh debug test — new SSE CORS scenario passes; suite 609/609 tests passed (4 unrelated flaky assertions in posix/socket timeout tests).

Open in Web View Automation 

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: Kaius  Ruokonen <ruoka@users.noreply.github.com>
@ruoka
ruoka marked this pull request as ready for review July 28, 2026 06:39
@cursor

cursor Bot commented Jul 28, 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 ac7d686 into master Jul 28, 2026
4 checks passed
@ruoka
ruoka deleted the cursor/critical-bug-management-9ae5 branch July 28, 2026 06:39
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