Egress means traffic going out. The phrase turns up in AI agent sandbox docs, in Kubernetes setups and in cloud firewall guides, and it means the same thing in all of them: one place where outbound connections are checked before they leave. This post explains how an egress proxy works, why sandboxes for AI coding agents rely on one, and what it cannot see, from the agents' own docs and the source of three proxies.
What an egress proxy is
A proxy is a program that makes a connection on someone else's behalf. A reverse proxy sits in front of your servers and handles traffic coming in. An egress proxy is a forward proxy used as a checkpoint: it sits in front of your programs and handles traffic going out.
The useful part is the decision. For each connection the proxy reads the destination, compares it to a list, and opens the connection or refuses it. Stripe's open-source Smokescreen is a well-known example: it allows requests only to hostnames on a configured list, and checks that each name resolves to a public address, so nobody can use it to scan Stripe's internal network.
For an AI agent the list answers one question: which hosts may this process talk to. That is the network half of what agentic AI security means, next to which folders it can read and which keys it holds.
How it knows where a connection goes
Most tools find a proxy through environment variables such as HTTPS_PROXY. For a plain HTTP request the tool sends the proxy the whole URL. For HTTPS it sends a CONNECT request that names the host and port, and once the proxy agrees, the encrypted traffic flows through a tunnel the proxy cannot read.
CONNECT api.github.com:443 HTTP/1.1
Host: api.github.com:443
That first line is all the proxy learns by default: a hostname and a port. It does not see the method, the path or the body. Claude Code's docs say so about its own sandbox proxy.
The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic.Claude Code docs, Configure the sandboxed Bash tool
To see more, a proxy has to terminate TLS: it decrypts the connection, reads the request, and encrypts it again toward the real server. The program inside must trust the proxy's own certificate authority for that to work. Codex's network proxy does this in its limited mode, which allows only GET, HEAD and OPTIONS and blocks HTTPS it cannot decrypt.
Why AI agent sandboxes use one
The kernel can limit ports, not names. Linux Landlock can allow port 443, which is every HTTPS server on the internet. A firewall works on IP addresses, and one address can serve thousands of sites behind a CDN.
Anthropic's reference dev container shows the firewall route, and needs the NET_ADMIN and NET_RAW capabilities to run it. Its init-firewall.sh script resolves each allowed domain once at startup, adds GitHub's published address ranges, and drops everything else with iptables. A list built at startup can go stale if a provider moves its addresses while the container runs.
A proxy decides on the name the program asked for, at the moment it asks. Anthropic's sandbox runtime, which Claude Code's sandbox is built on, runs an HTTP proxy for web traffic and a SOCKS5 proxy for other TCP. Codex's network proxy runs the same two kinds of listener.
| Firewall on addresses | Egress proxy | Proxy that terminates TLS | |
|---|---|---|---|
| Decides on | IP address and port | Hostname and port | Hostname, method, path and headers |
| Sees what is sent | No | No | Yes |
| Extra setup inside | Network admin rights to install the rules | Proxy settings, and no other route out | The same, plus the proxy's certificate in the trust store |
It holds only if it is the only way out
An environment variable is a request, not a rule. A program can ignore HTTPS_PROXY, open a socket and connect straight to an address, and a proxy it never talks to decides nothing.
So the sandbox has to remove the other routes. On Linux, Claude Code runs sandboxed commands in a separate network namespace with no connection to your network, and on macOS a macOS Seatbelt profile blocks every connection except the one to the proxy. Anthropic's sandbox runtime removes the network namespace entirely on Linux and hands the proxies in as Unix sockets.
The cost is that tools which ignore proxy settings simply fail. Claude Code's docs name plain ssh, most database drivers, and anything that is not TCP, such as HTTP/3 and ping. They also give a test to ask the agent to run, which should fail with Could not resolve host:
curl --noproxy '*' https://example.com
What a host list does not stop
Data sent to an allowed host. If the agent can reach github.com, it can push a repository, open a gist or post an issue there. Claude Code's docs warn that broad domains such as github.com can open a path for data to leave. That is the way out in the lethal trifecta, and a host list only narrows it.
A name that hides another. A proxy that does not decrypt trusts the hostname the client gives it. The same docs warn that code in the sandbox could use domain fronting, where the visible name belongs to an allowed service and the real destination sits behind the same provider, to reach a host outside the list.
A name that points inside. Whoever controls an allowed name's DNS controls what it resolves to, including services on your own machine or the cloud metadata address 169.254.169.254. Claude Code's proxy and Smokescreen both resolve the name and refuse local or internal addresses. Codex's README is plain about the limit: "DNS rebinding is hard to fully prevent without pinning the resolved IP(s) all the way down to the transport layer."
Traffic the rules let through by design. Anthropic's firewall script lets DNS out to any server on UDP port 53, and SSH out on port 22, before it drops the rest. A DNS query carries whatever name it asks for, so an open DNS path can carry small amounts of data out.
The agent's own tools. In Claude Code the sandbox proxy covers shell commands, and its web fetch tool follows permission rules instead. Our notes on whether Claude Code can access the internet go through each path.
"A host list keeps data in."
Revision 1: it decides where data can go. What goes to an allowed host is a separate question.Where the key goes
A proxy that terminates TLS can do one more job: hold the real credential. The program gets a placeholder, and the proxy puts the real value in only on requests to the hosts that key is meant for. Claude Code's experimental credential masking works this way and needs its tlsTerminate setting, and Codex's proxy can also swap a placeholder for a secret.
That keeps a key from being read out of the environment and sent to the wrong host. It does not stop the agent from using the key on the right host for the wrong thing, which is why the method and path matter as much as the name. Our list of AI agent security risks starts with that kind of mistake.
How to check yours
Is it the only route? Ask the agent to run the curl --noproxy line above, and to connect to an address with no hostname. Both should fail.
What does it decide on? Find out whether your proxy matches names, addresses or whole requests, and whether it terminates TLS. A list of names with no decryption means anything can go to an allowed host.
How broad are the entries? Replace a whole domain with the exact hosts the task needs, such as an API host and a package registry. Every wildcard is a set of hosts you did not name.
Who can widen it? In Claude Code, strictAllowlist refuses unlisted hosts instead of asking, and managed settings can lock the list for an organization with allowManagedDomainsOnly. Codex's proxy blocks every request until a list is configured, and its deny entries always win.
A side note on how we do it
We build Fenzi, which starts the agent in an OpenShell sandbox where a network namespace sends every connection to a proxy that checks the host and the program, and, on hosts it can read, the method and path; the real key is added only on the hosts it is bound to. The default hosts sheet lists what it allows. The proxies in Claude Code and Codex, or Smokescreen in front of a container, can answer the same question.
So, do you need one?
If an AI agent runs without someone reading every command, yes. An egress proxy is the practical way to say which hosts it may reach, because it decides on names where the kernel and a firewall see only ports and addresses. Make it the only route out, keep the list to exact hosts, and terminate TLS where the method, the path or a key matters. Anthropic's page on the sandboxed Bash tool, its network isolation and security limitations sections in particular, is the clearest next read, whichever agent you run.