How to prevent SSRF in MCP servers
Every MCP server URL a person pastes in is a request your platform makes on their behalf. Here is how to make sure that request can only ever reach the public internet.

Prevent SSRF in MCP by checking every customer URL before connecting: allow https only, refuse credentials in the URL, resolve the name yourself and refuse it if any address is private, loopback, link-local or metadata, connect to the exact address you checked, and re-check every redirect hop.
Why MCP makes SSRF a bigger deal
Server-side request forgery is old. A server fetches a URL that an outsider controls, and the outsider points it at something only the server can reach: a metadata endpoint that hands out cloud credentials, an admin panel on a private network, or a database port on localhost.
MCP puts that pattern at the center of the product. Remote MCP servers are URLs, and a good agent platform lets people paste in any server they like. Each connect, each OAuth discovery request and each tool call is your platform making an outbound request to an address someone else chose. Add custom model endpoints, which are also URLs, and a single unchecked fetch can become a path into your own infrastructure.
Agents widen it further. A person might paste a malicious URL, but a model can also be talked into one by text it reads in a web page, an issue or an email. The defence has to live in code that the model cannot argue with.
Step 1: check the shape of the URL
- Allow https only. Plain http invites downgrade tricks and has no place in a production connector.
- Refuse any URL with a user name or password in it. Credentials in the authority section are a classic way to confuse parsers about which host is real.
- Parse numeric hosts as IP addresses. Hosts written as decimal, hex or octal numbers are still addresses, so https://2130706433/ must be treated as 127.0.0.1.
Step 2: block every non-public range
Blocking 127.0.0.1 and 169.254.169.254 is not enough. The list has to cover every range that is not the public internet, in both IPv4 and IPv6, including the IPv6 forms that wrap an IPv4 address.
Bello Bot's network guard is a useful reference list. IPv4: this network, 10/8, 100.64/10, 127/8, 169.254/16, 172.16/12, 192.0.0/24, 192.168/16, the documentation and benchmarking ranges, multicast, reserved, and the Azure host endpoint 168.63.129.16. IPv6: loopback and unspecified, IPv4-mapped and NAT64 forms of blocked IPv4 addresses, fc00::/7, fe80::/10, fec0::/10, multicast and documentation ranges.
Cloud metadata services sit inside those ranges in different places: AWS uses 169.254.169.254 and fd00:ec2::254, Alibaba uses 100.100.100.200, and Azure exposes a host endpoint at 168.63.129.16. A good list catches all of them by range rather than by name.
Step 3: defeat DNS rebinding
The most common SSRF bypass is a hostname that resolves to a public address when you check it and a private one when you connect. If your check and your connection do separate DNS lookups, an attacker controls the gap.
The fix is to resolve once and pin. Hostnames are resolved by the guard itself. If any address a name returns is private, the whole name is refused, and the connection goes to the exact address that was checked, so a second DNS answer cannot swap in an internal one.
Proxies break pinning, because a proxy resolves the name again on its own. Guarded clients should bypass any configured proxy and use a short connect timeout so a stalled target cannot tie up workers.
Step 4: re-check every redirect
A public URL can answer with a redirect to http://169.254.169.254/. If your HTTP client follows redirects automatically, every check above is skipped for the second hop. Turn automatic redirects off, follow them yourself, run the full check on each new URL, and stop after a small number of hops. Bello Bot stops at five.
Step 5: put the guard everywhere a URL enters
A guard that covers the connect call but not OAuth discovery is a guard with a door in it. It covers connectors, their OAuth endpoints, per-bot MCP servers and custom OpenAI-compatible model URLs. The only switch that opens it is a server setting for local development; no request or org setting can turn it on.
Keep exactly one way to relax it, make that a server setting rather than anything a request or an org can flip, and name it so nobody mistakes it for a production option.
Step 6: tell people what happened
A refused URL should say so in plain words, without echoing internal details. Bello Bot answers with one message: "This address isn't allowed. Use the server's public https URL." That tells the person what to fix and tells an attacker nothing about your network.
Test it like an attacker
- Loopback in every spelling: 127.0.0.1, 127.1, 2130706433, 0x7f000001 and [::1].
- Metadata in every form, including the IPv4-mapped and NAT64 IPv6 forms of 169.254.169.254.
- A name that resolves to both a public and a private address.
- A public URL that redirects to a private one, and a chain of six redirects.
- URLs with user info, plain http and a missing host.
- Check URLs with the MCP SSRF risk checker
- SSRF and the network guard, with a diagram
- Governing external MCP servers
Questions
Is blocking private IP ranges enough to stop SSRF?
No. You also need to resolve names yourself, connect to the checked address, refuse credentials in the URL and re-check redirects.
Why refuse plain http for MCP servers?
Production connectors carry tokens. Plain http exposes them in transit and invites downgrade tricks.
Does SSRF protection matter if only admins add servers?
Yes. Admins paste URLs from docs and chats, and models can be steered toward URLs by text they read.
Can I test my own URLs?
Yes. The free MCP SSRF risk checker runs the same checks in your browser.
Keep reading
MCP SSRF risk checker
Paste MCP server or model endpoint URLs, one per line, and see whether the Bello Bot network guard would let a bot reach them.

SSRF and the network guard
Every URL a customer can type, from MCP servers to custom model endpoints, goes through one guard before a byte leaves.

Securing MCP in production: SSRF, private addresses and approvals
How to secure MCP servers and clients in production: https only, DNS-pinned private address blocking, redirect checks, cloud metadata ranges, and a person approving each sensitive tool call.
Try Bello Bot with your team
Public beta. Bring your own model keys, invite your team, and approve what your bots do.