Skip to content

fix: reject MCP requests from unapproved browser origins - #2657

Open
erichare wants to merge 3 commits into
mainfrom
fix/mcp-origin-allowlist
Open

erichare wants to merge 3 commits into
mainfrom
fix/mcp-origin-allowlist

Conversation

@erichare

@erichare erichare commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

Rejects MCP requests whose Origin header is not on the new stargate.jsonapi.mcp.allowed-origins allowlist, with HTTP 403 and a fixed JSON-RPC error containing a null id. The list is empty by default, and requests without an Origin header are unchanged. The check runs before CORS and authentication. Approved Origins can complete preflight and read WWW-Authenticate; approval never skips authentication. The localhost-only Quarkiverse check is disabled so the allowlist is the single policy.

Which issue(s) this PR fixes:

Part of #2630, which remains open. Public edge verification belongs to #2634, and the launch Origins are not yet recorded in #2624.

Verification

All 65 focused tests passed with 0 failures, 0 errors, and 0 skips. Formatter and XML checks also passed.

JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-21.jdk/Contents/Home ./mvnw -B -ntp test -Dtest='McpOriginFilterTest,McpOriginPolicyTest,McpOriginDefaultPolicyTest,McpProtocolTest' -Dsurefire.failIfNoSpecifiedTests=false

The full unit suite, packaged integration tests, and manual browser checks were not run after the latest change.

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

Add a Quarkus HTTP filter on the MCP endpoint that answers any request
with an Origin header not listed in stargate.jsonapi.mcp.allowed-origins
with HTTP 403 and a fixed JSON-RPC error. The list is empty by default.
Requests without an Origin header are unchanged. The filter runs before
CORS and authentication, answers preflight requests from approved
Origins and exposes WWW-Authenticate to them. The localhost-only
framework check is disabled so the allowlist is the single policy.
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 55.07%
This PR 55.08%
Delta 🟢 +0.01%
✅ Coverage improved!

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 55.08% -0.11% 🍏
Files changed 60.27% 🍏

File Coverage
McpOriginFilter.java 60.27% -39.73% 🍏

@erichare
erichare marked this pull request as ready for review October 23, 2026 22:03
@erichare
erichare requested a review from a team as a code owner October 23, 2026 22:03
@github-actions

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 73.04%
This PR 72.95%
Delta 🔴 -0.09%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 72.95% -0.16% 🍏
Files changed 41.41% ❌

File Coverage
McpOriginFilter.java 41% -58% ❌

@github-actions

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 74.35%
This PR 74.26%
Delta 🔴 -0.09%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 74.26% -0.16% 🍏
Files changed 41.41% ❌

File Coverage
McpOriginFilter.java 41% -58% ❌

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