Security best practices: SSRF section does not cover local stdio-to-HTTP bridges acting as OAuth clients
What's broken?
The spec doesn't cover a case it clearly should
Where in the spec or docs?
https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices#server-side-request-forgery-ssrf
Security Best Practices, section "Server-Side Request Forgery (SSRF)". Source file: docs/docs/draft/tutorials/security/security_best_practices.mdx. The spot is the end of "DNS Resolution Considerations", right before "SSRF Against Authorization Servers".
What should happen?
The SSRF section should name the local stdio-to-HTTP bridge as a client that runs OAuth discovery on the user's machine. It should say that the section's mitigations apply to it. Proposed subsection below, ready to drop in after "DNS Resolution Considerations". It is 34 lines; nothing existing changes.
#### Local Bridges Acting as Clients
A local bridge that turns a stdio connection into Streamable HTTP runs
the whole OAuth client role on the user's machine. The client in this
section is then the bridge rather than the application the user sees. The
bridge reads `WWW-Authenticate` and fetches the protected resource
metadata. It picks an authorization server from `authorization_servers`.
Then it sends the token request to the `token_endpoint` named in that
server's metadata. The remote server controls each of those values. The bridge makes the requests from inside the user's network.
The mitigations above are written for clients deployed to a server. A
bridge on a laptop or a CI runner needs the same mitigations. The
reachable targets differ in two ways. Loopback and link-local addresses are now
the user's own services and, on a cloud-hosted development machine, the
instance metadata endpoint. A bridge is also usually started from a host
application's configuration, so the user never sees the URLs it was sent
to.
**Bridge Authors**
Bridge authors **SHOULD**:
- Apply the HTTPS, private-range and redirect checks of this section
before every discovery fetch and before the token request
- Record the destinations they chose where the user can inspect them
**Hosts That Launch a Bridge**
Hosts that start a bridge from their own configuration flows **SHOULD**:
- Pin it to a reviewed version
- Prefer a native remote transport where they have one, so that the host
itself performs the client-side validation
What actually happens?
The mitigation text reads: "MCP clients deployed to a server MUST consider SSRF risks and implement appropriate mitigations when fetching OAuth-related URLs." A local stdio-to-HTTP bridge runs that same discovery from the user's machine, and nothing in that setup is deployed to a server. It takes resource_metadata, authorization_servers and the token endpoint from the remote server and then sends its requests wherever they point, including the token request. The page does not cover that case. Host applications start such bridges from their configuration flows, for users who never see those URLs.
Anything else?
Why I think it is needed. Five CVE records exist for one such bridge, mcp-remote on npm: CVE-2026-51994, -51995, -51996, -51997 and -52001. MITRE published them on 24 September 2026; the CNA text gives 0.1.16 through 0.1.38 as affected. I reported them. On 15 October I ran the current release, 0.15.1, against loopback canaries with the procedure in my research record. It still followed the server-selected discovery paths of the first two records. Evidence, procedures and limits: https://github.com/playb0t/mcp-remote-oauth-security.
On the channel: the repository lets only collaborators open pull requests at the moment, so this comes as a documentation issue with the text inline. If a maintainer prefers it as a PR, I will open one the moment a fork is allowed to. Happy to move it under another heading or trim it if the docs team prefers a shorter note.
AI disclosure: I drafted this with AI assistance (Claude Code) from my own research notes and reviewed every sentence; the evidence and the rationale are mine.
+1, and two things the new subsection could address (draft security_best_practices.mdx at 86f6e0c):
-
The authorisation spec says "Implementations using an STDIO transport SHOULD NOT follow this specification, and instead retrieve credentials from the environment." (basic/authorization L21-22). A bridge author could read that as exempting a stdio-launched bridge. It may help to say the bridge's upstream side is an HTTP transport and the SSRF guidance applies to it.
-
The "Enforce HTTPS" bullet says "Reject
http://URLs except for loopback addresses (localhost,127.0.0.1,::1) during development" (L424). On a laptop, loopback is exactly the target, so a bridge following this text word for word would still fetch server-supplied http://localhost discovery URLs. I think the section should say the loopback exemption does not cover URLs supplied by the remote server.
Also worth cross-linking "stdio Transport Security in Proxy Scenarios" (L747). That covers a local proxy spawning servers, the other direction, and the two are easy to mix up.
Thanks, Sattyam. All three land. Two of them are better fixed in the bullets you quoted than in my subsection, so I have reshaped the proposal. It is now three one-clause edits to existing lines plus a subsection about a third of the earlier length. That changes what I said in the opening post about nothing existing changing. The bullets are where the fix belongs.
Line 415. This is the only sentence in the section that scopes SSRF to server deployments. The SHOULD blocks below it are already unqualified.
MCP clients deployed to a server MUST consider SSRF risks and implement appropriate mitigations when fetching OAuth-related URLs.
becomes
MCP clients MUST consider SSRF risks and implement appropriate mitigations when fetching OAuth-related URLs, including a local bridge that performs OAuth discovery on the user's machine on behalf of another client (see Local Bridges Acting as Clients).
Line 424. Your loopback point, in the bullet itself.
- Reject
http://URLs except for loopback addresses (localhost,127.0.0.1,::1) during development
becomes
- Reject
http://URLs except for loopback addresses (localhost,127.0.0.1,::1) during development, when the user has explicitly enabled this; a loopback URL supplied by the server does not qualify
Line 441. The same clause in the private-range list.
- Loopback:
127.0.0.0/8,::1(except when explicitly allowed for development)
becomes
- Loopback:
127.0.0.0/8,::1(except when the user has explicitly allowed it for development; never because the server supplied a loopback URL)
Your first point, the STDIO line in the authorization spec, is now a sentence in the subsection. That guidance describes the bridge's stdio side, not the HTTP requests it makes itself. The cross-link to the proxy section is in, one sentence. The subsection follows the shape of "SSRF Against Authorization Servers" next to it: two paragraphs, "apply equally", links out. The two bullets for hosts that launch a bridge are gone from it. They are about supply chain, not SSRF. If the maintainers want them, they belong under "Local MCP Server Compromise".
Subsection, a drop-in after "DNS Resolution Considerations":
#### Local Bridges Acting as Clients
SSRF risks are not limited to clients deployed to a server. A local
bridge that accepts a stdio connection from one MCP client and connects
to a remote server over an HTTP transport performs OAuth discovery on
the user's machine: it fetches the URL sources listed above and sends
the token request to the `token_endpoint` from Authorization Server
Metadata, each chosen by the remote server, from inside the user's
network. On that side the bridge is the MCP client this section
addresses. The
[authorization specification](/specification/draft/basic/authorization)'s
guidance that STDIO implementations retrieve credentials from the
environment describes the bridge's stdio side, not the HTTP requests it
makes itself.
The mitigations described above apply equally to such a bridge, with two
differences in what is reachable. Loopback and link-local addresses are
the user's own services and, on a cloud development machine, cloud
metadata endpoints. The bridge is started from a client's configuration,
so the user does not see the URLs it was sent. A bridge **SHOULD** reject
a loopback or private-range URL received from the remote server through
a discovery header, a metadata document or a redirect; the development
allowances above apply only when the user configured a local server as
the initial target. A bridge **SHOULD** also record the destinations it
chose where the user can inspect them. This is the
opposite direction from
[stdio Transport Security in Proxy Scenarios](#stdio-transport-security-in-proxy-scenarios),
where a local proxy spawns servers over stdio.
If a maintainer wants this as a PR once forks can open one, I'll do that the same day.
The Local Server Security guide (#3072, merged 5 October) already lists the case this issue is about. I had not read it when I opened this. Item 5 of "Threats This Guide Addresses" says, in part:
Local bridges that connect stdio clients to remote servers have had critical flaws triggered by nothing more than connecting to a malicious endpoint
That clause has no link. The guide points to the Security Best Practices page at the top. The SSRF section there still scopes its only MUST to clients deployed to a server. So a reader who follows the guide to that section arrives at a MUST that stops short of the bridge the guide just named.
Two edits would close that gap. In the guide, item 5 gets a link to the bridge subsection once it exists. In the SSRF section, the three clause edits and the subsection from my comment above. The five mcp-remote records in the opening post are one public citation for the "critical flaws" the guide mentions. Item 5 would then have a source.
If a fork PR is accepted now, both edits fit in one. Say the word.
The reshaped bullets close most of what I was going to raise, so this is narrower than my first read. Two things the new text still leaves open, both inside the bridge-as-client framing.
-
token_endpointis the one attacker-selected value that receives a secret, and the bullets check where it is, not who named it. Once the address passes the HTTPS and private-range checks, the authorization code and refresh token go to whatever host the metadata named, and that metadata came from anauthorization_serversentry the resource server chose. This is a credential-exposure path rather than an SSRF path, so address validation cannot close it. A line requiring the token endpoint to be same-origin with the issuer that published the metadata, or an explicit user confirmation when it is not, closes it. The bridge is where this matters most, because the user never sees the endpoint it chose. -
Proxy configuration is the transport the destination check does not see. "Use Egress Proxies" is scoped to server-side deployments; on a laptop or CI runner the same effect arrives as
HTTPS_PROXYorALL_PROXYin the environment, read by the default transport after the URL has been validated. A bridge that checks the URL and then hands it to that transport can still be routed to an internal address. Adding proxy environment variables to the "record the destinations" bullet, so the user can inspect what the bridge actually connects through, covers it in one clause.
Two bullets already cover what I would otherwise have asked for, so I would leave them alone: "validating each hop" under Validate Redirect Targets is per-hop re-validation, and the DNS TOCTOU bullets cover pinning resolution between check and use.
The mcp-remote CVE record is the concrete case for keeping bridges in scope rather than a separate note, so I would keep the actor framing as the lead.
Supporting the reshaped proposal (the three clause edits plus the shorter subsection), and adding one point that sits next to the token endpoint concern already raised here, in a form that could be a single clause.
The address checks validate where the token request goes. They do not validate the relationship between the token endpoint and the authorization server the user believes they are dealing with. A resource server selects an entry from authorization_servers; that server's metadata then names the token_endpoint. If nothing binds the two, a metadata document can point the bridge at a token endpoint on an unrelated origin, and the bridge will deliver the authorization code and any refresh token there. On a server deployment a user might at least see the authorization interaction. Through a bridge launched from a host's configuration, nobody sees the endpoint choice at all, which is the audience confusion at the heart of this issue: the bridge acts for the user, but the audience for its credentials is chosen by the remote side.
Suggested clause, in the style of the other edits, for the bridge subsection or the token-request bullet:
A bridge MUST verify that the
token_endpointis same-origin with theissuerin the authorization server metadata it was taken from, and MUST NOT send an authorization code or refresh token to a token endpoint on a different origin without explicit user confirmation.
Recording the chosen authorization server and token endpoint alongside the destination logging already proposed would make the check auditable after the fact.
Happy to draft this as exact diff text against the current page, aligned with the three edits above, if the maintainers want it in that form.
— Eshaan Jain, independent researcher (IEEE Senior Member)
A same-origin MUST is not an OAuth requirement. RFC 8414 §3.3 requires the returned issuer to exactly match the issuer identifier the metadata URL was built from. It says nothing about the origin of token_endpoint, and real deployments split the two: Google's metadata has issuer https://accounts.google.com and token endpoint https://oauth2.googleapis.com/token. Under the proposed rule that is a different origin.
Same-origin alone does not establish that credentials are going to the intended authorization server. An attacker-controlled issuer that names a token endpoint on its own origin passes the check. For mix-up, RFC 9700 §4.4.2.1 describes a defense that binds the authorization request to the issuer and checks the issuer in the authorization response. A confirmation prompt does not replace that.
This issue is about one gap: the SSRF section scopes its only MUST to clients deployed to a server, and a local bridge falls outside that wording.
AI disclosure: drafted with Claude Code, reviewed by me.
You are right, and the Google example settles it. Same-origin is not the invariant, and a MUST there would break legitimate deployments. I withdraw that formulation.
The concern I was reaching for is narrower. The bridge's credential audience is whatever the metadata says, so the binding that matters is between the metadata and the issuer it was fetched for: RFC 8414 §3.3 issuer matching on the metadata document itself, and the RFC 9700 §4.4 issuer check in the authorization response as the mix-up defence. Where I would still put a clause: a bridge MUST NOT act on a token endpoint from a metadata document whose issuer does not match the issuer identifier the discovery started from, and SHOULD log the token endpoint it used. That keeps the SSRF scoping fix, which is the heart of this issue, free of the over-broad rule.
Happy to draft that as a replacement clause if it is useful.
Eshaan Jain, independent researcher (IEEE Senior Member)
Thanks, that keeps the issue on one gap. On the remaining clause: RFC 8414 §3.3 already covers it and goes further. If the returned issuer is not identical to the identifier the metadata URL was built from, the whole document must not be used, not only its token_endpoint. A pointer to that section is enough here; a new MUST limited to the token endpoint would be narrower than the rule it restates.
Logging is already in the proposed subsection: "A bridge SHOULD also record the destinations it chose where the user can inspect them." The token endpoint is one of those destinations.
AI disclosure: drafted with Claude Code, reviewed by me.
Thanks, that settles the remaining clause. You are right that a pointer to RFC 8414 §3.3 is the right size here. The section already says the whole document must not be used when the issuer does not match, so a token endpoint only MUST would restate a weaker version of that rule. I will drop the replacement clause.
One small addition I would still offer, as a sentence rather than a clause: name the failure mode explicitly, so a reader implementing the check knows a mismatch means discard the metadata document, not just the token endpoint. Happy to put that in as a short PR against the subsection if you want it.
Eshaan Jain, independent researcher (IEEE Senior Member)