-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add SSRF protection for HTTP client redirects #2106
Copy link
Copy link
Closed
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Metadata
Metadata
Assignees
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Summary
The SDK creates
httpx.AsyncClientwithfollow_redirects=Truebut no redirect validation. A malicious MCP server can redirect requests to internal network addresses (http://localhost,http://169.254.169.254,http://metadata.google.internal), enabling SSRF attacks.Location
src/mcp/shared/_httpx_utils.py— the shared httpx client factory.Proposed Fix
RedirectPolicypresets:BLOCK_SCHEME_DOWNGRADE(default) — block HTTPS→HTTP redirectsENFORCE_HTTPS(strict) — only allow HTTPS destinationsALLOW_ALL(legacy) — current behavior, no restrictions