Skip to content

Outbound proxy Since v0.2 ​

Checking request values cannot see every fetch. An application may build the URL itself, follow a redirect, or resolve a name that answers differently a second later (DNS rebinding). The outbound proxy closes that gap from the other side. Each node runs a proxy listener for the application, and the application sends its own outbound HTTP and HTTPS requests through it. Every destination is checked before anything leaves the node, and the node connects to exactly the address it checked.

The proxy is part of the SSRF guard and uses its categories and allowed internal networks and hosts.

Before you begin ​

  • Role: operator for the application.
  • The proxy is off by default. Nothing listens until you turn it on, and then only on the configured address: a loopback address with a port (127.0.0.1:15080) or an absolute unix socket path. It is never reachable from the network.
  • Each application needs its own address, distinct from every data-plane listener. Validation refuses a clash.
  • Turning the SSRF guard off turns the proxy off too.

Turn on the proxy ​

text
1. Open Applications > All applications, and select the application.
2. Open Request checks > SSRF and outbound, tab Outbound proxy.
3. Turn on Outbound proxy, enter the Proxy address, the Allowed destinations and Allowed ports.
4. Select Preview changes, add a comment and select Apply.
5. Copy the address the page shows under "Give this to the application".
sh
waap ssrf set -app shop -m "route outbound through the guard" egress.enabled=true egress.listen=127.0.0.1:15080 egress.allow_hosts=api.partner.example
waap ssrf get -app shop
yaml
# applications[].policy.ssrf
ssrf:
  mode: block
  allow_networks: [10.20.0.0/16]          # the image service (internal, allowed)
  egress:
    enabled: true
    listen: 127.0.0.1:15080
    allow_hosts: [api.partner.example, "*.cdn.partner.example", images.corp.example]
    allow_ports: [80, 443]

Point the application at it ​

Set the proxy in the application's environment, for example HTTP_PROXY=http://127.0.0.1:15080 and HTTPS_PROXY=http://127.0.0.1:15080. Most HTTP libraries read these. Some need the proxy in their own settings.

Plain HTTP URLs are sent to the proxy as full URLs. HTTPS uses a tunnel (CONNECT host:443), so the encrypted content is not inspected, only the destination.

Do not exempt internal services by accident

Do not list internal services the application calls directly in NO_PROXY unless you want them to bypass the check.

What is checked ​

For every request and tunnel, in order:

  1. The destination port is in Allowed ports (default 80 and 443).
  2. The host is in Allowed destinations when that list is set (api.partner.example, *.partner.example). An empty list allows any host that passes the next check.
  3. With Refuse internal destinations (default on), the destination is not internal: address literals in any encoding (decimal 2130706433, octal 0177.0.0.1, hex 0x7f.1, IPv4-mapped IPv6), internal names (localhost, *.internal, your internal domains), address-embedding names (127.0.0.1.nip.io) and names whose DNS answer is internal. The categories and the allowed internal networks and hosts are the same as for request values, so an internal service the application is meant to reach passes when it is listed there.
  4. Only http URLs are proxied in plain. An https URL sent without a tunnel, and any other scheme (gopher, file, ftp), are refused.

Pinning ​

The inspection service resolves the name itself (a bounded cache sized by the DNS cache size and lifetime, waiting at most Lookup timeout of the proxy) and hands the data plane the address it checked. The data plane connects to that address and never resolves the name again. A name that answers a public address first and an internal one afterwards therefore cannot redirect a request that was checked against the first answer. The next lookup after the cache entry expires is checked again.

The application's Host header and URL are forwarded unchanged. The proxy's own headers and the application's address (X-Forwarded-For) are not sent to the destination.

Modes ​

The proxy follows the guard's mode and action. In detect (the default) a refused destination is logged and the request still goes to the checked address. In block the application gets 403 with a reference to the event. A name that does not resolve, or whose lookup times out, gets 502, because there is no checked address to connect to.

When inspection is unreachable, the application's inspection failure policy applies:

  • fail_closed: the proxy answers 503.
  • fail_open: requests go out unchecked through the data plane's own resolver. With Refuse internal destinations, that resolver drops internal answers, so loopback, private, link-local and metadata addresses stay unreachable. But Allowed destinations, Allowed ports and the allowed internal services are not applied on that path.

Choose fail-closed when the allow list matters

Choose fail_closed when the outbound allow list matters more than availability.

Read the events ​

A refused destination is rule ssrf.egress.denied, module ssrf_egress, variable EGRESS. The key and matched value are the destination as host:port. The message gives the reason ("port 22 is not an allowed destination port", "internal destination: loopback address 127.0.0.1: hex 0x7f.1 = 127.0.0.1", "name x.example resolves to 10.0.0.7 (private)"), and the tags name the category (ssrf/metadata is CRITICAL). Events belong to the application.

The data plane's access log has every proxied request with app set to egress/<application>, the status, and the address connected to (upstream). Header limits (limits.header_bytes, limits.header_count) apply to outbound requests as to inbound ones. Outbound bodies are not inspected or limited, and inbound exceptions do not apply to the proxy.

Settings reference ​

SettingWhat it doesDefaultAllowed valuesApplies in
Outbound proxy (policy.ssrf.egress.enabled)Runs the proxy.falsetrue, falseSSRF guard on
Proxy address (egress.listen)Where the proxy listens.127.0.0.1:15080loopback IP:port, or an absolute unix socket path of at most 100 bytesproxy on
Allowed destinations (egress.allow_hosts)Hosts the application may fetch.none: any non-internal hostup to 1,024; *.domain allowedproxy on
Allowed ports (egress.allow_ports)Destination ports.80, 443up to 64 portsproxy on
Refuse internal destinations (egress.deny_internal)Refuse internal destinations except the allowed internal networks and hosts.truetrue, falseproxy on
Allow tunnels (HTTPS) (egress.connect)Accept CONNECT tunnels.truetrue, falseproxy on
Connection limit (egress.max_connections)Connections to the proxy at once per node; also the cap on connections to destinations.10241 to 100000proxy on
Lookup timeout (egress.dns_timeout)Longest wait for a destination's DNS answer.1s50ms to 5sproxy on

Limits ​

LimitValue
Allowed destinations1,024
Allowed ports64
Connections at once per node1 to 100,000 (default 1,024)
Added latency, measured on loopbackabout 0.2 ms median, 0.6 ms at the 99th percentile

A name seen for the first time waits for its DNS answer.

Troubleshooting ​

Preview refuses the proxy address ​

  • Cause: the address is not loopback or an absolute unix socket path, the port is out of range, or another application or listener already uses it.
  • Fix: choose a free loopback IP:port for this application.

The application gets 403 from the proxy ​

  • Cause: the destination was refused in block mode.
  • Check: the event ssrf.egress.denied gives the reason.
  • Fix: add the host to Allowed destinations, the port to Allowed ports, or the internal network to Allowed internal networks.

The application gets 502 ​

  • Cause: the name does not resolve, or the lookup timed out.
  • Fix: check DNS from the node, or raise Lookup timeout.

The application gets 503 ​

  • Cause: inspection is unreachable and the application's failure policy is fail_closed.
  • Fix: restore the inspection service.