Repository navigation
fix: block redirect header leaks - #936
Merged
Merged
Conversation
DaleSeo
marked this pull request as ready for review
June 27, 2026 03:51
jamadeo
approved these changes
Jul 1, 2026
This was referenced Jul 1, 2026
Closed
Closed
Merged
This was referenced Oct 15, 2026
Merged
gocamille
added a commit
to gocamille/rust-sdk
that referenced
this pull request
Oct 16, 2026
…treamable HTTP client
The default reqwest client used `Policy::none()`, so any redirect from an
MCP server failed with `UnexpectedServerResponse("HTTP 307: ...")`.
It now follows 307 and 308 when the target has the same origin as the
original request, up to 10 hops. Those keep the method and body, so the
JSON-RPC message and the session, auth and custom headers arrive intact.
301, 302 and 303 are still returned to the caller, because following them
turns the POST into a bodyless GET. Cross-origin redirects are still
returned too, which keeps the header-leak guard.
Refs modelcontextprotocol#936
Reported-by: Mo (@trickyfalcon)
DaleSeo
pushed a commit
that referenced
this pull request
Oct 19, 2026
…treamable HTTP client (#1367) * fix(transport): follow same-origin 307/308 redirects in the default Streamable HTTP client The default reqwest client used `Policy::none()`, so any redirect from an MCP server failed with `UnexpectedServerResponse("HTTP 307: ...")`. It now follows 307 and 308 when the target has the same origin as the original request, up to 10 hops. Those keep the method and body, so the JSON-RPC message and the session, auth and custom headers arrive intact. 301, 302 and 303 are still returned to the caller, because following them turns the POST into a bodyless GET. Cross-origin redirects are still returned too, which keeps the header-leak guard. Refs #936 Reported-by: Mo (@trickyfalcon) * docs(transport): describe redirect handling in default_http_client Document on `from_uri` and `from_config` which redirects the default client follows, that a 308 does not change the stored URI, and that a client passed to `with_client` keeps its own redirect policy. * docs(transport): move redirect rationale to same_origin_redirect_policy The rationale explains the policy, so it now sits on `same_origin_redirect_policy`, and the `default_http_client` doc points there instead of repeating the `from_uri` section. * test(transport): drop unused Default derive on CapturedRequest
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.
Motivation and Context
This fixes a security issue where the default reqwest-backed streamable HTTP transport could follow redirects while preserving caller-provided custom headers. Disabling automatic redirects keeps secrets such as custom API key headers scoped to the intended MCP server instead of replaying them to an attacker-controlled redirect target.
How Has This Been Tested?
Added a regression test
Breaking Changes
No
Types of changes
Checklist