fix(http)!: enforce Origin validation semantics - #1192
Open
lucarlig wants to merge 1 commit into
Open
Conversation
Return HTTP 403 for malformed Origin headers and treat an empty allowlist as denying every present Origin. Preserve disable_allowed_origins() as the explicit validation opt-out. Signed-off-by: lucarlig <luca.carlig@ibm.com>
lucarlig
marked this pull request as ready for review
August 19, 2026 08:33
Author
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.
Enforces the MCP 2026-07-28 Origin-validation requirements while retaining an explicit opt-out for deployments that intentionally accept arbitrary Origins.
Motivation and Context
The MCP 2026-07-28 Streamable HTTP specification requires servers to validate every present
Originheader and return HTTP 403 Forbidden when it is invalid.RMCP currently skips validation when
allowed_originsis empty and returns HTTP 400 for malformed or non-UTF-8 values. This change:allowed_originslist as allowing no present Origin valuesdisable_allowed_origins()as the explicit validation opt-outRequests without an
Originheader continue to pass, so non-browser MCP clients are unaffected.Closes #1191.
How Has This Been Tested?
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-features— 783 passed, 24 ignoredlocalmatrixBreaking Changes
Browser requests carrying an
Originheader no longer pass under the default empty allowlist. Deployments must configure accepted origins withwith_allowed_origins(...)or explicitly opt out withdisable_allowed_origins().Requests without an
Originheader are unchanged.Types of changes
Checklist
Additional context
Existing Origin port-matching behavior is intentionally unchanged because the MCP specification does not define allowlist matching semantics.