fix(transport): validate redirect targets to prevent SSRF and protocol confusion (#2700) - #2725
Open
teddiesloco wants to merge 1 commit into
Open
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
teddiesloco
force-pushed
the
fix/client-redirect-ssrf
branch
from
August 26, 2026 14:27
b901a78 to
6d699d0
Compare
teddiesloco
force-pushed
the
fix/client-redirect-ssrf
branch
from
August 27, 2026 05:31
6d699d0 to
1e07b6a
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.
Summary
Fixes #2700 (mirroring the client security hardening from python-sdk #3358).
Under default
fetchbehavior,redirect: "follow"causes client transports to silently follow 3xx responses into internal loopback endpoints (127.0.0.0/8,localhost), cloud instance metadata (169.254.169.254,metadata.google.internal), and private subnets (RFC 1918).This PR introduces proactive redirect target validation in
createFetchWithInit:isSafeRedirectTarget/isPrivateOrLoopbackHost.allowLoopbackRedirectsoption for local dev and testing suites.redirect: 'manual'orredirect: 'error'.Motivation and Context
Fixes a security vulnerability where malicious MCP servers can redirect client requests into internal infrastructure or cloud metadata services.
How Has This Been Tested?
packages/core-internal/test/shared/transport.test.tsasserting:127.0.0.1,[::1],169.254.169.254, RFC 1918).allowLoopbackRedirects: true.1440/1440tests passed incore-internal,797/797tests passed inclient.pnpm -r typecheckclean.Breaking Changes
None.
Types of changes
Checklist