GHSA-5h93-6whr-6q8j: Infoleak
Summary In affected versions, the SDK's Streamable HTTP and SSE client transports followed HTTP redirects to any host. If the configured MCP endpoint answered with a redirect to a different origin:
- custom headers set on the client (for example an X-API-Key credential) were sent to that origin, and - on a 307 or 308 redirect the request body was re-sent there too.
The SDK's OAuth client providers followed redirects on their own discovery, registration and token requests in the same way.
A lone Authorization bearer header was not exposed; the HTTP library already drops it on cross-origin redirects.
Anyone able to make an endpoint you trust redirect elsewhere (a stale redirect to a lapsed domain, a misrouted proxy rule, redirect logic an attacker can influence) could capture that material. A server that is itself malicious gains nothing this way; it already receives your requests directly.
Am I affected? Yes, if your code uses the SDK as an MCP client over HTTP through any of:
- streamablehttpclient (on 2.x also Client given an http:// or https:// URL) - streamablehttpclient or sseclient - ClientSessionGroup with HTTP server parameters - the internal createmcphttpclient helper
This includes an HTTP client you passed in yourself with followredirects=True.
Affected versions: 1.8.0 through 1.29.1, and 2.0.0 through 2.1.1.
Not affected:
- MCP servers - stdio clients - a client you supplied with followredirects left at its default of False
Fix Upgrade to mcp 1.30.0 (1.x) or 2.2.0 (2.x) or later; no code changes are needed.
The transports, and the OAuth providers' own requests, now follow a redirect only when it stays on the endpoint's origin (same scheme, host and port, or an http to https upgrade on the same host) and keeps the request method. Any other redirect is not followed and the request fails with an error naming the target (MCPError on 2.x, httpx.HTTPStatusError on 1.x), whichever HTTP client the transport uses. The internal createmcphttpclient helper no longer turns redirect following on, so code calling it directly now receives the redirect response instead.
If your client currently reaches its server through a redirect to another host, including a server that needs no credentials, it will stop connecting after the upgrade: set the endpoint URL to the redirect's target.
Until you can upgrade, supply your own HTTP client with followredirects left at False (httpclient= on streamablehttpclient; httpxclientfactory= on sseclient and streamablehttpclient; ClientSessionGroup has no such parameter). If a client may already have followed a redirect to a host you do not control, rotate the credentials it carried.
<details> <summary>If you genuinely need the old behaviour (unsupported)</summary>
This restores what this advisory fixes: redirects to any host are followed again, carrying your custom headers and, on 307/308, the request body, OAuth token requests included. Prefer setting the endpoint URL to the redirect's target. If you cannot, and you accept forwarding credentials to the redirect target, give the transport an HTTP client that follows redirects regardless of what the SDK asks for:
python import httpx2 # on 1.x: import httpx and subclass httpx.AsyncClient instead
class FollowRedirectsAnyway(httpx2.AsyncClient): """Follows redirects to ANY origin. Deliberately gives up the SDK's same-origin protection."""
async def send(self, request, , followredirects=False, kwargs): return await super().send(request, followredirects=True, kwargs)
httpclient = FollowRedirectsAnyway(timeout=httpx2.Timeout(30, read=300)) streamablehttpclient(url, httpclient=httpclient)
sseclient / streamablehttpclient take a factory instead: def clientfactory(headers=None, timeout=None, auth=None): return FollowRedirectsAnyway(headers=headers, auth=auth, timeout=timeout if timeout is not None else httpx2.Timeout(30, read=300)) sseclient(url, httpxclientfactory=clientfactory)
The redirect handling is then the HTTP library's own, as before the fix: a lone Authorization header is still dropped on cross-origin hops and 301/302/303 become GET. It is not something the SDK supports or tests.
</details>
---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/mcpto a version that resolves this vulnerability.Fixed in 1.30.0 - Upgrade
Upgrade
pip/mcpto a version that resolves this vulnerability.Fixed in 2.2.0 - Upgrade
Upgrade
mcpto a version that resolves this vulnerability.Fixed in 1.30.0 - Upgrade
Upgrade
mcpto a version that resolves this vulnerability.Fixed in 2.2.0 - Configuration
Until upgrading, supply an HTTP client with follow_redirects left at False; use http_client= for streamable_http_client and httpx_client_factory= for sse_client or streamablehttp_client.
MCP Streamable HTTP and SSE client transports follow_redirects = False - Configuration
If the server is reached through a redirect to another host, set the endpoint URL directly to the redirect target.
MCP client endpoint endpoint URL = redirect target - Operational
Rotate credentials carried by a client that may already have followed a redirect to a host you do not control.
Event History
Frequently Asked Questions
Which SDK usage patterns are exposed?
The affected paths are MCP clients using HTTP through streamable_http_client, streamablehttp_client, sse_client, ClientSessionGroup with HTTP server parameters, and, in 2.x, Client when given an HTTP or HTTPS URL. The SDK's OAuth client providers are also affected for discovery, registration, and token requests.
What does an attacker need to exploit this?
They need to cause an endpoint the client trusts to redirect requests to another origin. Examples include a stale redirect to a lapsed domain, a misrouted proxy rule, or redirect behavior the attacker can influence.
What information can be exposed on a cross-origin redirect?
Custom client headers, such as an X-API-Key credential, can be sent to the redirected host. For 307 or 308 redirects, the request body can also be resent there; a standalone Authorization bearer header is not exposed because the HTTP library drops it on cross-origin redirects.
Does connecting to a malicious MCP server itself trigger this issue?
No. A server that is already malicious does not gain additional access through this redirect behavior because it receives the client's requests directly.