Details
Expected result: the canary logs [canary] GET /internal from 127.0.0.1, and the MCP response contains INTERNAL-SECRET: canary-hit for /internal in the tool's content[0].text.
Additional bypass vectors that work the same way:
http://[::1]:<port>/— plain IPv6 loopback.http://[::ffff:a9fe:1]/latest/meta-data/iam/security-credentials/— AWS EC2 metadata over the IPv4 stack.http://attacker.example/whereattacker.examplehas A/AAAA pointing at any private address — bypasses via defect (2), no IPv6 trick needed.
Impact
- Cross-tenant SSRF with full response body. Any client that can speak MCP to the HTTP transport can fetch arbitrary private-network URLs and receive the response body. AWS EC2 metadata, internal dashboards, loopback services, RFC1918 neighbours — all in scope.
- Pre-auth when `enableHttpServer` is set. No authentication layer exists on
/mcpor/sse; CORS is*. - DNS-rebinding / LAN-victim angle. Because
/mcpis CORS*and acceptsPOST, a victim who visits an attacker-controlled webpage while running open-webSearch locally will have their browser used to send tool-call requests, and the tool's response can be exfiltrated back via a simple XHR. - Exploitable over stdio too. Even with HTTP disabled, a compromised or prompt-injected MCP client can call
fetchWebContentagainst loopback on the host running the server — a realistic LLM-agent-abuse vector.
No meaningful mitigation in the call chain: only http:// and https:// schemes are accepted, but that is not a restriction for SSRF.
Suggested fix
Two changes, either of which individually closes most of the gap; both together close it fully.
- Normalize the hostname before IP checks, and perform a DNS resolution. Use the
ip-addresspackage or a similar canonicalizer, and reject anygetaddrinforesult whose IP falls in a private CIDR. Keep a bracket-stripping step for IPv6 literals before callingisIP().
```ts
import { lookup } from 'node:dns/promises';
import { Address4, Address6 } from 'ip-address';
function stripBrackets(h: string): string {
return h.startsWith('[') && h.endsWith(']') ? h.slice(1, -1) : h;
}
const BLOCKED_V6_CIDRS = [
'::1/128', '::/128',
'fc00::/7', 'fe80::/10',
'2001:db8::/32', '2002::/16', '64:ff9b::/96',
'100::/64', 'ff00::/8',
'::ffff:0:0/96', // IPv4-mapped — delegate to v4 check
];
function ipv6IsPrivate(addr6: Address6): boolean {
const v4 = addr6.to4();
if (v4 && v4.isValid()) return isPrivateIpv4(v4.address);
return BLOCKED_V6_CIDRS.some(cidr => addr6.isInSubnet(new Address6(cidr)));
}
export async function assertPublicHttpUrl(url: URL | string, label = 'URL') {
const parsed = typeof url === 'string' ? new URL(url) : url;
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') throw …;
const host = stripBrackets(parsed.hostname);
// Literal IP case.
const v = isIP(host);
if (v === 4 && isPrivateIpv4(host)) throw …;
if (v === 6 && ipv6IsPrivate(new Address6(host))) throw …;
if (v === 0) {
// Hostname — resolve and check every record.
const records = await lookup(host, { all: true, verbatim: true });
for (const r of records) {
if (r.family === 4 && isPrivateIpv4(r.address)) throw …;
if (r.family === 6 && ipv6IsPrivate(new Address6(r.address))) throw …;
}
}
}
```
- Dual-pin the connection. Even a perfect pre-connect check has TOCTOU gaps (DNS rebinding between check and
axios.get). Use a customundiciAgentwhoseconnecthook validates the actual connected socket IP viasocket.remoteAddress. That closes the rebinding window.
- Gate the HTTP transport. Require a bearer token (env var) on
/mcpand/sse, and restrict binding to127.0.0.1by default. CORS*plus no-auth on0.0.0.0is the same exposure profile as an unauthenticated open proxy.
Test vectors to add to the suite:
for (const url of [
'http://[::1]/', 'http://[::]/',
'http://[::ffff:127.0.0.1]/', 'http://[::ffff:7f00:1]/',
'http://[0:0:0:0:0:ffff:127.0.0.1]/',
'http://[0:0:0:0:0:0:0:1]/', 'http://[::0:1]/', 'http://[0:0::1]/',
'http://[::ffff:a00:1]/', 'http://[::ffff:c0a8:1]/', 'http://[::ffff:a9fe:1]/',
]) expect(isPublicHttpUrl(url)).toBe(false);