Skip to Content
AgentShield
Security

SSRF Protection

How the http.request adapter and the network layer prevent agents from reaching internal services, cloud metadata endpoints, and unintended hosts.

Server-side request forgery (SSRF) is the risk that an agent, possibly steered by injected content, makes the gateway send requests to places it should not: cloud metadata services, internal admin panels, databases, or other tenants. AgentShield addresses SSRF at three independent layers.

Layer 1: Host allow-list

http.request reaches only hosts listed in the gateway's tools file. The check happens in Validate, before anything is claimed:

  • Hosts are lowercase hostnames with an optional port. IP addresses are refused in the configuration, so an allow-list entry cannot point at an address range.
  • The request's resource must use one of those exact hosts.
  • HTTPS is required unless allow_insecure_http is set, which production refuses.

Layer 2: Address checks after DNS resolution

A hostname on the allow-list could still resolve to an internal address, either by misconfiguration or by DNS rebinding. The adapter's dialer therefore checks the resolved IP address immediately before connecting, in the socket's control hook. A hostname that resolves to a blocked address is refused even if DNS changes between lookups.

Blocked addresses include:

CategoryRanges
Loopback127.0.0.0/8, ::1
Private10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7
Link-local (including cloud metadata)169.254.0.0/16, fe80::/10
Carrier-grade NAT100.64.0.0/10
Unspecified and "this network"0.0.0.0/8, ::
MulticastAll multicast scopes
Documentation and benchmarking192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24, 198.18.0.0/15, 2001:db8::/32
Reserved192.0.0.0/24, 240.0.0.0/4
Transition mechanismsNAT64 64:ff9b::/96, 64:ff9b:1::/48, 6to4 2002::/16
Anything not global unicastRejected by the standard library check

IPv4-mapped IPv6 addresses are unmapped before checking. A blocked connection is reported as 400 validation_failed: "resource host resolves to a blocked network address".

allow_private_networks disables these checks for local development. Production refuses it.

Layer 3: Request shaping

ControlPrevents
Redirects are not followed. A 3xx is returned as the resultBouncing through an allowed host to an internal one
Proxy environment variables are ignoredRouting through an unexpected intermediary
Canonical resource URLs onlyEncoding tricks that bypass exact policy rules
No userinfo in URLshttps://allowed@internal/ confusion
Agent cannot set HostVirtual-host routing to a different backend
Agent headers limited to Accept, Accept-Language, If-Match, If-None-MatchHeader injection and credential smuggling
Response cap (256 KiB default, 4 MiB maximum)Memory exhaustion
Set-Cookie dropped, response headers filteredLeaking session material back to the agent

Layer 4: Network policy

On Kubernetes, the gateway's egress NetworkPolicy allows outbound HTTPS only to public ranges, excluding private, loopback, carrier-grade NAT, and link-local networks. This repeats the adapter's checks at a layer the gateway process cannot change. It requires a network plugin that enforces NetworkPolicy.

Policy as a final control

Even with network protections in place, use policy to restrict what agents may reach:

{
  "permissions": { "allowed": ["http.get"], "denied": ["http.delete"], "approval_required": ["http.post"] },
  "resource_rules": [
    { "effect": "allow", "action": "http.get", "resource": "https://api.github.com/repos/octo/hello" }
  ]
}

Allow-listed hosts are trusted

SSRF protection keeps requests on the hosts you list. It cannot make a listed host safe. If an allowed host itself proxies arbitrary URLs, an agent can use it as a proxy. List only hosts whose behavior you understand.

Was this page helpful?

On this page