Network Egress Controls for Isolated Agent VMs

Prompt-injected agents need egress controls more than compute sandboxing.

· 11 min read
Cover illustration for “Network Egress Controls for Isolated Agent VMs”
Agent Isolation · October 10, 2026 · 11 min read · 2,518 words

A perfectly hardened micro-VM with an open outbound path is a ready-made exfiltration tool. An autonomous agent running inside it can be hijacked through prompt injection, and once that happens, the agent doesn't need to break out of its sandbox. It only needs permission to make an outbound connection it was already authorized to make. That single fact reorders the priority list for anyone building isolated environments for agent workloads.

The isolation model that actually holds rests on four boundaries: kernel-level compute sandboxing, so agent code cannot reach the host kernel; default-deny network egress, so the agent cannot reach arbitrary external endpoints; a per-tenant namespace or VPC, so the blast radius of any failure stays bounded to one tenant; and per-run scoped credentials, so no long-lived key sits in the environment waiting to be inherited by the next request. Three out of four of these is not isolation. An agent is simultaneously untrusted code, a credential holder, and an outbound network client, and a system that secures three of those four roles while leaving the fourth open has secured nothing that an attacker actually needs to get around.

Prompt injection makes this concrete in a way that traditional security models don't anticipate. There's no binary exploit required, no memory corruption, no privilege escalation bug. An agent's own privileges and its outbound network path are the attack surface, full stop, because the agent will do what it is told by whatever text it reads, including text an attacker planted in a document, a web page, or a tool response. The dominant failure mode in agent infrastructure is an open egress path that lets a prompt-injected agent exfiltrate data from a process that is, by every conventional measure, isolated correctly.

That asymmetry is the argument this piece makes from the start: compute sandboxing, namespace isolation, and credential scoping all matter, but none of them stop an authorized outbound connection from carrying stolen data to an attacker-controlled endpoint. Only egress control does that job, and everything that follows here is about how to design and operate that control so it actually holds.

What compute sandboxing does and does not protect

Micro-VM isolation, Firecracker in particular, is the right compute primitive for running untrusted or LLM-generated code inside an agent workload. It is not a substitute for egress control, and understanding the line between what it secures and what it leaves open is the prerequisite for building the rest of the stack correctly.

Containers fall short of the risk floor this threat model demands. Docker containers share the host kernel, and a kernel exploit, or an agent that manages to execute kernel-level syscalls in a way the container runtime doesn't fully mediate, can break that boundary. For agents that execute LLM-generated code or call out to external tools, shared-kernel isolation is not an acceptable baseline. Firecracker's answer is to give each workload a dedicated kernel through KVM hardware virtualization, which is genuine hardware-enforced isolation rather than a software boundary layered on top of a shared resource. Its boot times run under a second and its memory overhead stays low, making it practical to give every agent its own VM.

Firecracker's design trades away GPU support to get there. There is no support for VFIO device passthrough, because Firecracker has no PCI bus at all, by design. That makes GPU access inside a Firecracker VM impossible in the stock configuration, which narrows what Firecracker is for: regulated data handling and adversarial code execution, where the hardware isolation boundary takes priority over accelerator access.

gVisor offers a different tradeoff, suited to compute-heavy, cost-sensitive, multi-tenant deployments where the threat model doesn't demand full kernel-level isolation. Its approach to GPU workloads works through nvproxy, which forwards ioctl calls made by the containerized application directly to the host NVIDIA driver. This mechanism differs fundamentally from PCIe passthrough, since gVisor has no VM and no PCIe bus to pass a device through. Firecracker's hardware path supports VFIO for real GPU access by working at the hypervisor layer, intercepting nothing in user space.

None of this touches whether an agent sandbox is actually safe to run. The most common real-world leak from an agent sandbox is never an exotic hypervisor escape. It is a VM that is isolated by every measure relevant to compute, with an outbound network path left wide open and a secret sitting in its environment that it never needed to hold. VM-level isolation hardens the execution boundary. Identity, permissions, egress, tool authorization, logging, and state cleanup remain the operator's responsibility, and none of them come free with a strong hypervisor.

CVE-2025-59536 illustrates a category of risk that sits outside the compute boundary. The vulnerability, carrying a CVSS score of 8.7, is a code injection flaw in Claude Code versions prior to 1.0.111 that let malicious repository configuration files execute arbitrary shell commands automatically upon tool initialization, when a user started Claude Code in an untrusted directory, before the startup trust dialog ever appeared. The execution context here is the developer's local machine or CLI session, an unsandboxed developer tool, not a deployed, isolated agent environment. The lesson it carries over to agent infrastructure is that execution contexts without a sandboxing boundary carry risk that no amount of downstream policy can retroactively fix, and the compute boundary has to exist before anything else in the stack is built.

Per-sandbox network namespaces and the egress boundary in micro-VM environments

Egress policy needs somewhere to attach, and that somewhere is the network namespace. Without a per-sandbox namespace architecture, an egress rule is a configuration file sitting next to a flat network that quietly ignores it. The namespace turns policy into an enforcement point.

In a Firecracker environment, each sandbox is wired up as its own dedicated network namespace, containing a veth pair and a tap device that Firecracker attaches to directly. Because the namespace is per-sandbox, the routing table, the packet filtering and address translation rules, and the set of visible interfaces are all scoped to that one sandbox alone. That architecture closes off an entire class of lateral movement before any policy rule even runs: there is no flat shared network where one sandbox can scan for its neighbors and then open a connection to a sibling. Lateral reach between tenants is absent from the network topology itself, not merely blocked by a rule that a misconfiguration could later lift.

Building this by hand costs more setup effort than teams coming from Kubernetes typically expect. Kubernetes ships mature CNI plugins that abstract most of this work away. Bare Firecracker requires manual management of TAP interfaces, IP tables, and routing rules on the host, though the firecracker-go-sdk and firecracker-containerd projects do support CNI-based setups through a chained plugin called tc-redirect-tap. That manual burden isn't a gap in the tooling so much as the exact place where egress policy gets installed, and any team running Firecracker directly needs to understand this layer before it can write a policy that actually enforces anything.

One target deserves specific, deliberate attention in this layer: the cloud instance metadata endpoint at 169.254.169.254. Amazon's own documentation confirms that EC2 instances reach their instance metadata through HTTP requests to that exact address, and it is reachable from inside a VM by default unless something explicitly blocks it. Azure describes the same address as a well-known, non-routable IP reachable only from within the VM. A default-deny egress posture means no route exists to that address and no lateral path exists to sibling sandboxes, and both conditions have to hold at the same time. A prompt-injected agent that can still reach the metadata endpoint can retrieve instance credentials no matter how strong the VM boundary around it is, because the metadata service doesn't check whether the request came from a trustworthy process, only whether it arrived on the right interface.

Kubernetes environments carry a parallel gap that's easy to miss for teams assuming the platform secures egress by default. A pod in Kubernetes is non-isolated for egress out of the box. Every outbound connection is permitted until a NetworkPolicy selects that pod and restricts it. The correct build order starts from a default-deny NetworkPolicy and adds a narrow allowlist on top of it, not the reverse, because starting from an open policy and trying to subtract access later means every gap left unclosed during that process was a live exfiltration path the whole time.

Designing an egress policy that matches the real workflow of an autonomous agent

An allowlist built around convenience is a liability with a friendly name attached to it. The organizing principle that actually holds up is to build the allowlist around the agent's real workflow, not around broad categories of traffic and not around what makes development easiest. A default-deny policy with a wildcard entry sitting inside it is barely better than no policy at all, because the wildcard is exactly where the specificity that makes default-deny meaningful gets thrown away.

Every domain or endpoint on the allowlist should map to a named, documented workflow step: a package install, a vendor API call, an internal service call, a web retrieval. Each of those categories needs its own owner and its own review path, and a domain that shows up on the list without a documented business reason attached to it is a policy smell that should be treated as a finding, not a convenience to leave alone. It either belongs to a workflow that should be named explicitly, or it has no business being there.

Four traffic categories need to be governed separately, because each carries a different risk profile and a different correct lifecycle. Package registries, PyPI and npm among them, should be allowed on a time-limited basis, scoped to the setup phase of a run and closed off once the agent moves into its execution phase, not left open for the life of the sandbox. Vendor APIs should be enumerated per workflow, with ports and protocols constrained to what that integration needs, nothing broader. Internal services should route through per-tenant namespace boundaries rather than being left reachable from sibling namespaces. Web browsing and retrieval carry the highest risk of the four categories, because injected content encountered during a web fetch can carry stolen data out in a query string or a URL, and that traffic needs to be governed under the same allowlist discipline applied to shell tools, not treated as a lower-risk category just because it looks like ordinary browsing.

Shell-based network tools deserve the same scrutiny. Tools like curl and wget, and anything equivalent to them, should be blocked by default unless they're part of an explicitly approved workflow. Two failure patterns appear constantly in tool-level egress policy. The first is inconsistent policy across tool types: bash tools reaching domains that the agent's browser tool is blocked from reaching, which creates a gap an attacker only needs to find once. The second is a policy left open past its useful life: network access opened to support package installs during setup and never narrowed back down once that phase ends, leaving the setup-phase allowlist live for the entire duration of the agent's run.

Cursor's documentation for its cloud agent product shows how a wildcard entry turns into an unintended exfiltration route. A pattern like *.s3.us-east-1.amazonaws.com opens egress to every bucket in that entire region, not just the one bucket the workflow actually needs. Cursor's own documentation for per-team and per-environment egress rules describes configuring this kind of rule, so a misconfigured wildcard here is a documented, reachable risk, not a hypothetical one.

The subtlest failure mode involves no misconfigured rule. A prompt injection can drive an agent to send data to an endpoint that is correctly on the allowlist and entirely the wrong destination for that data, and because the endpoint is approved, the egress policy permits the connection without any violation being logged as a policy failure. Policy design alone cannot catch this. It's the reason policy and logging have to be designed together from the start, rather than treating logging as an afterthought bolted onto a finished policy.

Logging as the layer that makes egress policy auditable and durable

An egress policy with no structured logging behind it cannot be audited, and a policy no one can audit will drift toward permissiveness over time, because every exception added under deadline pressure looks reasonable in isolation and no one is positioned to see the cumulative effect. Logging is the mechanism that keeps a policy from rotting into something looser than anyone intended it to be.

Each logged event needs to capture the process or tool that initiated the connection, the domain and port of the destination, a session identifier linking the connection back to the specific agent run and tenant it belongs to, and a clear record of whether the connection was allowed or denied and which rule handled it. Both denied and allowed outbound attempts need to be logged, with process, tool, domain, and session attached to each, because a log of only the denials tells you nothing about what the policy is permitting day to day.

A log entry showing that a request happened, without the prompt or tool chain that caused it, doesn't give an investigator enough to work with. Without that chain, there's no way to distinguish an agent that made a legitimate, intended API call from an agent that was prompt-injected and used an approved endpoint to exfiltrate data. That distinction is the operational version of the approved-but-wrong-endpoint issue described in the policy section above: the allowlist can't catch it, so the log has to be the thing that makes it visible after the fact.

Web search, web fetch, and browser tools need to be logged with the same rigor applied to shell network tools, because they are egress paths wearing a friendlier name. Injected content encountered through any of them can carry stolen data out in a query string or embedded in a URL just as easily as a raw curl call could. Logging shell tool destinations carefully while treating browser tool destinations as inherently benign creates a blind spot in precisely the place an attacker is most likely to aim.

Microsoft Foundry Agent Service's preview path for egress control offers a practical model for how teams can get from an unverified policy to a trustworthy one without guessing. It supports an Audit mode and an Enforced mode: a team defines and attaches an outbound policy to a hosted agent, observes what that agent actually tries to reach while running in Audit mode, and only flips to Enforced once the audit log has built confidence that the allowlist is both complete and correctly scoped. That sequence is how a team avoids the common failure of opening egress broadly for setup and never narrowing it again. The audit log supplies the evidence needed to write a tight allowlist before enforcement is ever turned on, which is a meaningfully different starting point than guessing at a policy and tightening it reactively after something has already gone wrong.

How production platforms have wired egress controls in practice

The sources checked for this guide are listed below.

Sources

  1. Secrets & Network
Filed underAgent Isolation

More in Agent Isolation