Securing MCP in production: SSRF, private addresses and approvals
The Model Context Protocol makes it easy to hand an agent a new tool. It also makes it easy to hand an attacker your internal network. These are the controls that matter, with the exact rules Bello Bot runs.

Treat every MCP server address as untrusted input. Allow https only, reject credentials in the URL, resolve the host yourself and require every address to be public, connect to the exact address you checked, and re-check every redirect hop. Block private, loopback, link-local and cloud metadata ranges in both IPv4 and IPv6. Then put a policy table and a person in front of sensitive tool calls. Bello Bot does all of this in src/netguard.rs, src/policy.rs and src/approvals.rs.
Why MCP widens the attack surface
An MCP client fetches whatever URL it is given: the server itself, its OAuth metadata, token and registration endpoints, and every redirect along the way. If a user, or a prompt-injected agent, can choose that URL, the client becomes a server-side request forgery (SSRF) tool that runs inside your network.
The classic targets are the cloud metadata services that hand out credentials, internal admin panels on private ranges, and localhost services that trust anything on the same machine. A naive "is this hostname internal?" check misses most of them, because the attack lives in DNS answers, redirects and alternate address encodings.
Rule 1: check the address you actually connect to
The network guard allows https only, rejects credentials in the URL, and requires every address a host resolves to be public. It checks every redirect hop, up to five, and connects to the exact address it checked, so a DNS answer cannot change between check and connect.
The important detail is the last one. Checking a hostname and then letting the HTTP library resolve it again leaves a window where a hostile DNS server answers "public" for the check and "169.254.169.254" for the connection. Bello Bot plugs its guard in as the client's DNS resolver, so the address that was checked is the address connected to. IP-literal hosts skip the resolver, so those are checked before the request is sent and on every redirect.
// src/netguard.rs (abridged)
pub const NOT_ALLOWED: &str = "This address isn't allowed. Use the server's public https URL.";
const MAX_HOPS: usize = 5; // every redirect hop is re-checked
const MAX_JSON: usize = 1 << 20; // 1 MB cap for metadata and token JSON
Rule 2: block every private range, not just 10/8
The guard's table covers far more than the RFC 1918 ranges most teams remember. In IPv4 it blocks 0.0.0.0/8, 10/8, 100.64/10 (carrier-grade NAT, used by one cloud for metadata), 127/8, 169.254/16 (link-local and the common metadata address), 172.16/12, 192.0.0/24, 192.168/16, the test and benchmarking nets, multicast, reserved space and Azure's host endpoint at 168.63.129.16.
In IPv6 it blocks unique-local fc00::/7 (where one cloud serves its metadata endpoint), link-local, site-local, multicast, documentation and special-purpose ranges, and it decodes IPv4-mapped and NAT64 addresses so an IPv4 target cannot hide inside an IPv6 literal.
- The refusal never says which address answered, so the guard cannot be used to map your network.
- 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.
Rule 3: the guard covers every outbound path an agent controls
It is not only MCP servers. A custom OpenAI-compatible base URL must start with http(s) and goes through the same network guard as connectors, so it cannot reach private addresses. Connectors, their OAuth endpoints and per-bot MCP servers all go through the same code. Fixed first-party endpoints that Bello Bot itself calls do not need it.
Bots reach MCP servers over streamable HTTP, with the OAuth bearer of the connector. Anything not in the catalog is an MCP address you paste in Settings.
Rule 4: a reachable tool is not an allowed tool
Network safety decides where a client may connect. It says nothing about what a tool call may do once connected. For that, Bello Bot checks an org policy table before every MCP tool call, every bot-to-bot handoff and every access request.
Org rules resolve deny, then ask, then allow. If rules cannot be read, the call is denied. Each rule can match a bot, a connector, a tool name pattern, the tool's arguments, or calls made in rooms, and has a priority. Lower numbers are tried first, and the first match decides. An ask rule forces the approval card even for a tool that is set to run on its own.
-- src/policy.rs: how rules are ordered
ORDER BY priority,
CASE effect WHEN 'deny' THEN 0 WHEN 'ask' THEN 1 ELSE 2 END,
created_at
Rule 5: a person approves sensitive calls, with secrets redacted
A tool call that needs a person pauses the reply. Allow approves this call, Always allow saves a standing allow for that bot and tool, and Deny refuses. The reply picks up again either way. Questions from ask_user ride the same rail.
The stored copy of each call's arguments is redacted: any key containing token, secret, password, authorization or api key is replaced with [redacted], and anything over 2 KB is cut, so the audit trail does not become a second place to leak credentials.
Rule 6: when Bello Bot is the MCP server
Bello Bot serves MCP at /mcp. A token acts as the person who made it, under the same rules as the API, pinned to one workspace, valid for a year, and listed and revocable in Settings, Sessions. The Bello Bot MCP server offers tools to list bots and chats, read messages, send a message and wait for the reply, search, and read or add memory.
A production checklist
- https only, no credentials in URLs.
- Resolve once, require every answer to be public, and connect to that exact address.
- Re-check every redirect hop, with a hop limit.
- Block metadata ranges in IPv4 and IPv6, including mapped and NAT64 forms.
- Cap response sizes for metadata and token JSON.
- Check an org policy before each tool call, and deny if the policy cannot be read.
- Ask a person before sensitive calls, and redact secrets in what you store.
From the blog
Questions
What is SSRF in MCP?
Server-side request forgery: an MCP client is tricked into fetching an internal address, such as a cloud metadata service or a localhost admin port, because it trusted a URL it was given.
Is blocking private hostnames enough?
No. Attacks use DNS answers that change between check and connect, redirects, and IPv6 or mapped encodings. Check every resolved address and connect to the address you checked.
Does Bello Bot let an org turn private addresses back on?
No. The only switch is a server setting for local development; no request or org setting can turn it on.
Which calls does the Bello Bot policy check?
Every MCP tool call, every bot-to-bot handoff and every access request.
Are tool arguments stored in plain text?
Stored arguments are redacted: keys that look like tokens, secrets, passwords, authorization headers or API keys are replaced, and long arguments are cut at 2 KB.
Keep reading

MCP both ways: a governed client and a server
Bello Bot speaks MCP both ways: bots call any MCP server behind a network guard and org rules, and Claude Code or Cursor use Bello Bot as an MCP server with a revocable token.

An MCP gateway for teams: connect any server, govern every call
Bello Bot connects bots to any MCP server through a network guard, per-bot grants and org rules, and serves MCP itself so Claude Code and Cursor act as you, under the same rules.
Designing deny, ask, allow policies for AI agents
How to design deny > ask > allow policy tables for enterprise AI agents: priorities, tool and argument matching, room-only rules, fail-closed evaluation, dry runs and replaying a draft rule against real history.
Try Bello Bot with your team
Public beta. Bring your own model keys, invite your team, and approve what your bots do.