Menu

SSRF checks for MCP clients: what to validate before you connect to a URL

2026-11-27MCP Checkup

An MCP client that lets a user paste a server URL, a gateway that proxies to remote MCP servers, a directory that checks them: each of these makes HTTP requests to addresses that someone else chose. That is server-side request forgery (SSRF) territory. The person typing the URL can point your code at 127.0.0.1, at your cloud's metadata service, or at a host on your private network, and your code will connect from inside.

MCP Checkup has the same problem at scale. Every request our probe sends to a server, the scheduled checks and the instant check on the home page alike, goes through one package, ssrf-guard. Its source and its README are public in mcpcheckup/checks. This post walks through the rules in that README, because they apply to any MCP client or gateway, not only to ours. Each rule has a test with the exact input that must be rejected.

1. Check the address after resolving the name, not the URL string

A blocklist that looks at the URL text misses almost everything. https://0x7f000001/, https://017700000001/ and https://127.1/ are all 127.0.0.1. A host name such as internal.example.com can resolve to 10.0.0.5. So the order is:

  1. Parse the URL with the WHATWG URL parser (new URL(...), the same one Node and Workers implement). It normalizes every obfuscated IPv4 form before you read .hostname, so you never write special cases for hex or octal.
  2. Resolve the name yourself, A and AAAA.
  3. Check every address you got back. If a name resolves to one public and one private address, reject the whole thing. "At least one address is public" is not good enough.
  4. Fail closed. A resolver that does not answer, a name that does not resolve (NXDOMAIN, or no A and AAAA records), or a DNS answer that does not decode cleanly is a rejection, never "no addresses, nothing to check".

Some names can be rejected before any lookup: localhost, local, internal and home.arpa with every name under them, any single-label name, and any name with an empty label.

2. IPv4: take the list from IANA, not from memory

Hand-written private-range lists are usually incomplete. ssrf-guard takes its list from the IANA IPv4 and IPv6 Special-Purpose Address Registries and rejects every entry marked Globally Reachable = False. On the IPv4 side that includes, among others:

Block What it is
0.0.0.0/8 "this network"
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 private use
100.64.0.0/10 carrier-grade NAT
127.0.0.0/8 loopback
169.254.0.0/16 link-local, where cloud metadata lives
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 documentation
198.18.0.0/15 benchmarking
240.0.0.0/4 reserved

Inside a rejected block, the most specific registry entry decides, so a small block marked Globally Reachable = True (for example 192.0.0.9/32) is allowed. The test suite pins the list, so it cannot grow or shrink unnoticed. Cloud metadata addresses get a reason of their own, 169.254.169.254 and AWS's IPv6 fd00:ec2::254, even though both already sit inside blocked ranges. That way a rejection says "cloud metadata", not just "link-local".

3. IPv6: allow 2000::/3 and nothing else

For IPv6, a list of blocked ranges is the wrong shape. ssrf-guard allows only global unicast, 2000::/3, and then applies the registry entries inside it. Everything outside 2000::/3 is rejected: ::1, ::, unique local fc00::/7, link-local fe80::/10, and space such as 4000::1 that IANA lists as reserved.

Some blocks inside or next to that space are rejected whole, whatever the registry says, because they hand the traffic on to an address you cannot see or check:

  • the NAT64 prefix 64:ff9b::/96,
  • 6to4 2002::/16 and Teredo 2001::/32,
  • the deprecated IPv4-compatible ::/96, so ::127.0.0.1 is rejected,
  • the deprecated site-local fec0::/10, and multicast ff00::/8 (with 224.0.0.0/4 on the IPv4 side).

One more case hides inside 2000::/3: an ISATAP interface identifier (RFC 5214) carries an IPv4 address in its low 64 bits. 2606:4700:4700:1:0:5efe:a00:1 embeds 10.0.0.1, so it is rejected as private use.

4. IPv4-mapped IPv6 is rejected whole

::ffff:0:0/96 is how an IPv6 socket writes an IPv4 address. ::ffff:127.0.0.1 reaches the IPv4 loopback, and new URL('http://[::ffff:127.0.0.1]/').hostname gives [::ffff:7f00:1], which a string match on 127. will not catch. The registry marks the whole block Globally Reachable = False, so ssrf-guard rejects all of it, ::ffff:8.8.8.8 included. When the embedded IPv4 address is itself blocked, the reason is kept: ::ffff:169.254.169.254 is rejected as cloud metadata. A public server has no reason to be reached through a mapped address, so nothing useful is lost.

5. Redirects: re-check every hop yourself

If you let fetch() follow redirects, your check covers only the first URL. The classic bypass: the user gives you a legitimate public host, and it answers with 302 to a name that resolves to 169.254.169.254.

  • Use redirect: 'manual' and follow hops yourself.
  • Resolve and validate each hop's host before you send that hop's request. In the ssrf-guard test for the attack above, hop 2's request is never sent at all.
  • Resolve a relative Location against the current hop's URL, not the original one.
  • Cap the number of hops.
  • Do not follow a redirect on a POST. Return it as the result. Replaying a POST body and headers to whatever host a Location names is how tokens leak.
  • When a chain crosses from one host to another, drop Authorization on every hop after that.

For an MCP client this matters more than it might seem. A Streamable HTTP request is a POST carrying a JSON-RPC body, and sometimes a bearer token.

6. DNS rebinding: pin the connection if you can, detect it if you cannot

Even with all of the above there is a gap. You resolve the name and check the answer, and then your HTTP library resolves it again to connect. A hostile nameserver can answer the first lookup with a public address and the second with a private one.

The real fix is to connect to the exact address you validated. On a runtime where you control the socket (a custom DNS lookup function, or an HTTP agent that dials a given IP while keeping the original host name for TLS), do that.

ssrf-guard runs on Cloudflare Workers, where fetch() does its own resolution and cf.resolveOverride only works for hosts inside your own zone. An MCP server is never in our zone, so we cannot pin. The README says so plainly, and so does this post: the package narrows this window and detects it, but does not close it. After every request it resolves the name again and compares the two answers. If they differ, our probe marks that run and does not sign it, so it is never presented as a normal result.

What still limits the damage is everything else on this list: HTTPS only, port 443 only, no credentials in the URL, and caps on requests, bytes and seconds.

7. The rest of the checklist

  • Scheme: https:// only. Reject http://, file://, ftp://, data:, blob: and gopher://.
  • Port: 443 only. A single allowed port is simpler and more complete than a list of dangerous ones, and real remote MCP servers run on 443.
  • No credentials in the URL: reject https://user:pass@host/.
  • Methods and headers: allow what MCP actually needs (GET, POST, and an allowlist of headers such as Content-Type, Accept, MCP-Protocol-Version, Mcp-Method, Mcp-Session-Id) and reject everything else before any network access.
  • Budgets: cap redirects, total time, number of requests and body size, for request and response alike.
  • Rate limits: an address check does not stop someone from using your service as a proxy against a public host. Only rate limits do that: per caller, per target host, and globally. ssrf-guard refuses to run without a rate-limit decision from its caller.
  • Do not echo what the target sent: hand your code a parsed result, not the raw response, and keep target bytes out of error messages.

None of this is specific to us. If your MCP client, gateway or agent framework connects to user-supplied URLs, the same checks apply. The code, tests and README are at github.com/mcpcheckup/checks. Our probe page describes what our probe sends to a server and how to recognize it.