kosa8 / Guides / AI agent egress control
Guide · Network · Last checked: November 2026
AI agent egress control: default-deny network access
Egress control decides where an AI agent's traffic can go. Deny every outbound connection and DNS query by default, allow only the hosts the task needs, and enforce that list somewhere the agent cannot reach: on the host, in the virtual network path or in a gateway outside the sandbox, with DNS answered by the same enforcer. A proxy setting or a firewall inside the agent's own machine is not a control, because the agent can ignore one and remove the other. Even a good allow-list limits only where data goes, not what is sent there.
01Why egress is the control that matters most
An agent leaks data when three things meet: it can read something private, it reads content an attacker wrote, and it has a way to send data out. You can rarely remove the first two, because reading private data and untrusted content is the agent's job. Egress is the one you can close. If the only hosts the agent can reach are its model provider and one package registry, an injected instruction to "send the notes to drop.example" fails at the network.
Exfiltration does not need a dramatic upload. It can be a query string, an image URL rendered in a chat, a DNS lookup for a name that encodes the data, or a commit to a public repository. Egress control has to cover all of those paths, which is why the details below matter more than the idea.
02Requirements for agent egress control
Deny by default. No outbound TCP, UDP or DNS unless the destination is listed. A list of blocked hosts is not egress control; the internet is too large to enumerate.
Enforce outside the agent. The rule lives on the host, in the hypervisor's network path, in a gateway on another machine, or in a cloud network control. Root inside the sandbox must not be able to lift it.
Fix the rule before the agent starts. Rules applied after boot leave a window. Changes during a run should come from outside, and be recorded.
Own DNS. Intercept every DNS query, resolve allowed names yourself and refuse the rest. Admit only the addresses your resolver returned for allowed names.
Block internal ranges. Loopback, link-local (including
169.254.169.254, the cloud metadata address), and your private networks, unless a task needs one by name. Withhold private answers for public names, which stops DNS rebinding.Fail fast and visibly. A refused connection should fail at once with an error the agent can read, and be logged with its destination.
Per task, not per machine. A coding task needs a registry; a data task may need nothing. Give each sandbox its own list.
Log both outcomes. Allowed and refused attempts, with host, port and time, written outside the sandbox. Refusals are the most useful signal you will get that something went wrong.
03Where to enforce it: approaches compared
| Approach | Sees | Can the agent bypass it? | Good for | Gaps |
|---|---|---|---|---|
| Agent or tool setting (built-in allowed domains) | Requests the tool chooses to route | Yes, if it runs other programs | A first layer for one tool | Does not cover code the agent writes and runs |
| Firewall inside the sandbox | All traffic from the guest | Yes: root inside can flush it | Convenience only | Not a boundary |
| HTTP(S) forward proxy outside | Host name and port of proxied requests | Yes, by ignoring HTTPS_PROXY or dialling an IP | Name-based allow-lists, request logs | Needs a deny-all packet filter underneath |
| DNS filter alone | Name lookups | Yes, by using an IP or its own resolver | Blocking known-bad names | Raw IPs and tunnels over allowed names |
| Host packet filter (nftables, a VMM network guard) | Every frame the sandbox sends | No, from inside a VM | The base layer: deny all, admit resolved addresses | Sees addresses, not names, without DNS control |
| Cloud network controls (security groups, egress gateway) | Traffic leaving a subnet or VPC | No, from inside the workload | Fleet-wide floors | Usually coarse: per subnet, not per task |
| TLS-inspecting proxy | Full requests, including bodies | Not easily, if certificates are pinned to it | Content rules and data-loss checks | Holds decrypted traffic; breaks pinned clients; heavier to run |
The pattern that holds is two layers: a deny-all packet filter outside the sandbox, plus DNS (and optionally a forward proxy) on the same enforcer, so names are resolved by you and only the resulting addresses are admitted.
04DNS and proxies: the details that leak
- Raw IP addresses. Code can connect to an address without a lookup. Only a packet filter sees that.
- Custom resolvers. If the sandbox can reach any DNS server, it can get any answer, and can carry data out in the names it asks for. Intercept port 53 and answer locally.
- Wildcards. Allowing
*.example.comlets the sandbox look up any name below it, and whoever runs that domain's name servers sees those names. Use wildcards only for domains you trust. - Shared addresses. Address rules admit everything on an allowed address. Content delivery networks host many sites on one address, so an allowed name can open more than you meant.
- Encrypted tunnels. A forward proxy that does not inspect TLS sees the name in
CONNECTand nothing else. What travels to an allowed host is not checked. - IPv6. A rule set written for IPv4 alone may leave IPv6 open. Close it or cover it.
The step-by-step version of these checks is in How do I restrict an AI agent's network access to an allow-list?
05Which approach fits
- Pure computation, data analysis, code an LLM wrote. No network at all, DNS included.
- Coding agents. The model API and the package registries the project uses. Mirror registries internally if you can, and allow only the mirror.
- Agents that call business APIs. Each API host, reached through a credential broker so the key never enters the sandbox; see credential brokering.
- Browsing agents. The hardest case: they need much of the web. Give them no private data and no credentials, or route them through a TLS-inspecting proxy you run, and accept that an allow-list cannot be tight here.
- Fleets. A cloud or data-centre floor (no direct internet from the agent subnet) plus per-sandbox lists on the host.
06One way to do it: kosa8
In kosa8, every frame a sandbox sends crosses a network guard in the kosa8d service on the host, outside the microVM, so root inside the guest cannot lift the rules. The rules exist before the machine boots. A sandbox can be fully closed (--egress deny, DNS included) or allow-listed with exact names, *.example.com wildcards, IPv4 addresses and CIDR ranges. DNS answers only listed names, and private, loopback and link-local answers are withheld for allowed names unless you list that address. A refused TCP connection gets a reset and a refused DNS question gets REFUSED, so the program fails at once. Each refusal is counted and written to the audit log.
kosa8 sandbox create agent --egress-allow registry.npmjs.org kosa8 sandbox egress agent kosa8 sandbox create offline --egress deny
The limits, stated plainly: an allow-list bounds where data can go, not what is sent there. HTTPS bodies to allowed hosts are not inspected; the broker checks the name and port of an HTTPS CONNECT and carries TLS it does not open. A sandbox has no IPv6 route. An organisation can set a default rule in its signed policy. On hosted kosa8 Cloud, each sandbox is still its own microVM, but the audit log, evidence export and signed policy are features of the software on your own machines and hosts; hosted Cloud sandboxes do not expose them yet.
kosa8 limits what a hijacked agent can reach; it does not detect prompt injection. SOC 2 Type II is in progress; there is no SOC 2 report and no external penetration test yet.
To try a kosa8 sandbox without installing anything or making an account, kosa8.com/try runs code in a fresh sandbox with no outbound network: 15 minutes of run time free per 24 hours, each run up to 60 s.
Try free with no account. Starter is free with no card; plans from $29 a month.
07Questions
What is default-deny egress for an AI agent?
Every outbound connection, datagram and DNS lookup from the agent's sandbox is refused unless its destination is on a list you wrote. The agent still reaches its model provider and package registry, but an injected instruction cannot send data to a host you did not list.
Is an HTTP proxy enough to control agent egress?
Not on its own. A proxy only sees programs that choose to use it. Code that ignores proxy settings or connects to an IP address goes around it, so put a deny-all packet filter underneath, outside the sandbox.
Why does DNS matter for egress control?
If the sandbox can query any resolver, it can get any answer for an allowed name and can carry data out inside the names it looks up. Answer DNS on the enforcer, only for allowed names, and admit only the addresses it returned.
Does an allow-list stop all data exfiltration?
No. It limits where traffic goes, not what it carries. An allowed host that accepts uploads, such as a code host, a paste site or a storage bucket, is still a way out, so allow the fewest and narrowest hosts you can.
Should I block the cloud metadata address?
Yes. 169.254.169.254 and other link-local addresses can hand out cloud credentials. Block link-local, loopback and private ranges by default, and withhold private answers for public names.
08Sources and further reading
Last checked: November 2026 · Updated 2026-11-29