fix(http): enforce Origin validation semantics - #1192
Open
lucarlig wants to merge 1 commit into
Open
Conversation
lucarlig
marked this pull request as ready for review
August 19, 2026 08:33
Author
lucarlig
force-pushed
the
user/luca/spec-compliant-origin-validation
branch
from
August 20, 2026 10:39
8b00146 to
12d2c84
Compare
Author
|
Updated to address CI:
|
Member
|
Thanks, @lucarlig. The fix itself looks correct. One process note: we're between major releases right now. v3.2 is next and is planned as a minor release, so marking this Could you rework this as a non-breaking change? Keep the current default as is, and put the spec-compliant behavior behind an opt-in, such as |
lucarlig
force-pushed
the
user/luca/spec-compliant-origin-validation
branch
from
August 30, 2026 09:44
12d2c84 to
86ba129
Compare
lucarlig
force-pushed
the
user/luca/spec-compliant-origin-validation
branch
from
August 30, 2026 10:06
86ba129 to
a5a7a19
Compare
Author
|
thank you for the review @DaleSeo. Makes sense, I changed it as requested. |
Return HTTP 403 for malformed and non-UTF-8 Origin headers when validation is enabled. Add enforce_origin_validation() for strict empty-allowlist validation while preserving the legacy default and non-empty allowlist behavior. Configure the conformance server to opt in explicitly. Signed-off-by: lucarlig <luca.carlig@ibm.com>
lucarlig
force-pushed
the
user/luca/spec-compliant-origin-validation
branch
from
August 30, 2026 15:13
a5a7a19 to
8e69952
Compare
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.
Adds opt-in strict Origin validation while preserving the existing default and non-empty allowlist behavior.
Motivation and Context
When Origin validation is enabled, malformed and non-UTF-8
Originheaders currently return HTTP 400 instead of the specification-required HTTP 403.This change adds
enforce_origin_validation()so servers can reject every present Origin when the allowlist is empty without changing the current default. Requests without anOriginheader continue to pass. The conformance server opts into strict validation explicitly.Closes #1191 and includes the malformed-Origin fix from #1188.
How Has This Been Tested?
cargo fmt --all -- --checkTests cover allowed, disallowed, absent, malformed, and non-UTF-8 Origins; enforced empty allowlists; explicit disabling; and legacy compatibility paths.
Breaking Changes
None. Strict empty-allowlist validation is opt-in. Existing default and non-empty allowlist behavior are preserved.
When validation is enabled, malformed and non-UTF-8 Origins now return HTTP 403 instead of HTTP 400.
Types of changes
Checklist
Additional context
Existing Origin port-matching behavior is intentionally unchanged because the MCP specification does not define allowlist matching semantics.