Skip to content

feat(mcp): component_mcp validates the Origin header (Phase 5) - #260

Open
askdba wants to merge 1 commit into
mainfrom
feat/mcp-origin
Open

askdba wants to merge 1 commit into
mainfrom
feat/mcp-origin

Conversation

@askdba

@askdba askdba commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Phase 5 item from #256: Origin validation (MCP spec, against DNS rebinding).

Problem

The endpoint listens on 127.0.0.1. Through DNS rebinding, a web page can still make the user's browser send requests to it, and the browser then sends the page's Origin. The MCP Streamable HTTP transport spec says servers MUST validate Origin.

Change

  • New mcp_http.allowed_origins setting: read-only, a comma-separated list, empty by default.
  • A request whose Origin header isn't in the list gets 403, before the bearer token is checked.
  • Matching is exact and ASCII case-insensitive, with spaces around commas ignored. There's no prefix or wildcard matching.
  • Requests without Origin (non-browser clients such as Claude Desktop, Cursor, or curl) aren't affected.

Tests

scripts/test-mcp-endpoint.sh on mysql:26.10.0: 36 passed, 0 failed.

  • By default, a foreign origin and a localhost origin are both refused (403), even with a valid token.
  • With allowed_origins = 'http://localhost:6274, https://Inspector.example':
    • both listed origins pass, with case and space handling;
    • a prefix (http://localhost:62) is refused;
    • another origin is refused.

Docs: settings table, CHANGELOG.

Independent of #257, #258 and #259.

Part of #256.

🤖 Generated with Claude Code

The MCP Streamable HTTP transport requires servers to validate Origin
against DNS rebinding: a web page can make a browser send requests to
127.0.0.1, with the page's Origin. A request with an Origin header that
mcp_http.allowed_origins (new, read-only, default none; exact match, ASCII
case-insensitive) does not list now gets 403 before the token is checked.
Requests without Origin (non-browser clients) are not affected.

test-mcp-endpoint.sh: foreign and localhost origins refused by default,
listed origins pass (case, spaces), a prefix is refused. 36 checks.

Part of #256 (RFC 0001 Phase 5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1fecd90-d7e7-4869-bba8-4f8966eaf50f
Commits

Reviewing files that changed from the base of the PR and between ff59fea and abc5319.

Files selected for processing: 4
  • CHANGELOG.md
  • docs/MCP_COMPONENTS.md
  • scripts/test-mcp-endpoint.sh
  • src/mcp/endpoint/component_mcp.cc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T10:05:01.913829Z abc5319 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abc53199d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

req.send_reply(HttpStatusCode::MethodNotAllowed);
return;
}
if (!origin_ok(req.get_input_headers().find("Origin"))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Support browser preflights for allowlisted origins

When a browser client runs on a different origin, its MCP POST with Authorization and application/json triggers an OPTIONS preflight. The handler rejects non-POST methods before reaching this check and does not return CORS headers, so configuring the newly documented Inspector origin still cannot let that browser call the endpoint.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant