Network Isolation Strategies for Self-Hosted Coding Agents
Network isolation prevents agents from exfiltrating secrets even when runtime sandboxes fail.

Running a coding agent on infrastructure you own means the security perimeter that a managed platform used to handle is now sitting on your desk. Nobody hands you that perimeter as a courtesy. Coder research from 2026 found that 70% of companies are deploying agents on infrastructure that was never built to support them, which tells you adoption sprinted way past readiness. That gap shows up most often at the network layer, which most teams quietly under-engineer.
Agent failures rarely look like a movie hack; the canonical failure mode is trusted agent code, sitting there with unrestricted internet access, quietly shipping your secrets to an address nobody approved.
Three ingredients turn any agent into an exfiltration risk, and a typical self-hosted coding agent has all three sitting in its lap: access to private data, exposure to untrusted content, and the ability to talk to the outside world. Take any one away and the risk mostly evaporates. Leave all three, and you've built a machine that's one bad instruction away from mailing your credentials to a stranger.
This isn't theoretical anxiety. OWASP's Top 10 for LLM Applications puts prompt injection at the very top of the list, and production systems from major vendors got exploited through prompt injection across 2025 and 2026 grigio.org williamzujkowski.github.io. That's not a hypothetical researcher finding a clever demo. That's the attack occurring in systems built by companies with enormous security budgets.
So here's the thesis, stated plainly: network isolation isn't one item on a security checklist among many. The network layer decides whether your agent is a contained tool or a liability wearing a friendly interface. The rest of this piece walks through a layered approach, egress controls, microsegmentation, and secret proxying, because no single one of them does the whole job.
Threat model for a coding agent on your own infrastructure
Coding agents don't accidentally stumble into risk. They're built to combine all three exfiltration ingredients by design. They read your repository. They consume untrusted content constantly, issues, pull requests, search results, packages pulled in through MCP servers. And they call external APIs as a routine part of doing their job. That isn't a bug in the architecture; it's the design itself.
The supply chain angle deserves its own spotlight. A package called postmark-mcp shipped many clean, boring, trustworthy-looking versions before someone quietly slipped in a single line of exfiltration code. Fifteen versions of good behavior bought the trust, and then one version cashed it in. That's legitimacy used as a weapon, a pattern that recurs every time a dependency updates itself without anyone reading the diff.
Then there's the infrastructure the agent leans on. CVE-2025-6514 was a remote code execution flaw in core MCP infrastructure, rated 9.6 on the CVSS scale, and was used by a very large number of developers. The tooling your agent depends on to function is itself a target, not a neutral pipe.
CVE-2026-22708 sharpens the point even further. It let an attacker poison the agent's execution environment so that allowlisted commands, things as mundane as git branch, delivered arbitrary payloads instead. The allowlist, the very thing meant to keep you safe, became the weapon. Safety mechanisms only work when they can't be repurposed against you.
A short list of the threats a coding agent's infrastructure has to answer for: host compromise through a container escape via an unpatched kernel CVE, and resource exhaustion from a fork bomb consuming all host CPU. None of these require a genius attacker. They require an agent that trusted the wrong input at the wrong moment.
Regulators have noticed, too. Compliance paperwork aside, all three frameworks agree that network controls need to be enforced at the infrastructure layer, not left to the agent's own good judgment. Regulatory context teams cannot ignore includes NIST AI RMF (including NIST AI 600-1 and the Agentic AI Profile in NIST IR 8596), EU AI Act cybersecurity robustness requirements (full high-risk AI system obligations took effect August 2026), and ISO 42001, all three requiring documented controls at the model, application, and context layers grigio.org.
The runtime boundary and its limits on containing an agent's network reach
Runtime isolation gets talked about like it's the whole solution. It isn't, and the isolation spectrum makes that clear once you walk through it.
One unpatched CVE in that shared kernel compromises every container sitting on the host, which makes this level insufficient on its own for LLM-generated code. gVisor moves up a rung, intercepting syscalls in user space before they ever touch the host kernel, with sub-second cold starts and roughly 10 to 20% overhead per syscall grigio.org williamzujkowski.github.io. Modal, Beam, and Northflank use it, though compatibility gaps occur with some Linux software grigio.org williamzujkowski.github.io.
MicroVMs go further still. Firecracker, Kata Containers, and libkrun each give a workload its own guest kernel dev.to williamzujkowski.github.io grigio.org. E2B, Vercel, and CubeSandbox all build on this layer dev.to williamzujkowski.github.io grigio.org.
Even the strongest of these, the microVM, doesn't solve your network problem. Firecracker's own design notes say guest network traffic should be treated as untrusted, and filtering is expected to happen at the host level. The microVM boundary isolates the runtime. It does nothing about exfiltration, which depends entirely on egress controls, DNS policy, what secrets got mounted, and where output can go.
And 2026 delivered a reminder that even the strongest boundary isn't invincible Coder research. Firecracker's long-standing claim of no published hypervisor escape broke twice in four months: CVE-2026-5747, an out-of-bounds write in virtio-pci rated 8.7, and CVE-2026-1386, a jailer symlink flaw allowing host writes, rated 6.0 williamzujkowski.github.io. Two escape-class vulnerabilities in a technology considered close to gold standard, in a single season grigio.org williamzujkowski.github.io.
So the lesson doesn't stop at picking a better runtime and moving on. Runtime isolation and network isolation have to be designed together, as a pair, from day one. Treating them as substitutes for each other caused the readiness gap that Coder's research flagged in the first place. Level 4 (Library OS, Microsoft LiteBox) is experimental as of February 2026, with no production SDK. Level 5 (confidential computing, AMD SEV-SNP, Intel TDX) provides hardware-encrypted memory, relevant for regulated industries handling PII, financial, or healthcare data.
Default-deny egress as the non-negotiable foundation
Picture a zero-trust model for your agent's network behavior: nothing goes out unless it's explicitly allowed. Every outbound connection has to earn its place on the list.
There's a mandatory floor here, and it isn't negotiable. Any self-hosted setup needs a non-root container, network egress filtering, read-only mounts, and strict timeouts on every agent task. Those four together handle the majority of production incidents. Three properties turn any agent into an exfiltration risk (access to private data, exposure to untrusted content, and the ability to communicate externally), and all three are present in a typical self-hosted coding agent.
At the OS level, the baseline controls are straightforward to state, harder to skip: block egress to unknown destinations, prevent file writes outside the active workspace, and block writes to the agent's own configuration files or extensions. Simple rules, but each one closes a path an attacker would otherwise walk through without resistance.
For a small team running Kubernetes, the baseline looks like this: GitOps with a pull-request gate on every policy change, container-level NetworkPolicy restricting egress, and Kyverno or Gatekeeper enforcing non-root, non-privileged, resource-limited pods. None of that is exotic. It's the kind of boring, repeatable infrastructure hygiene that doesn't make headlines but quietly prevents them.
Resource controls belong here too, as a genuine adjunct to network policy. Rate-limiting outbound traffic and watching for unusual volume patterns catches exfiltration attempts that pure destination-based rules miss entirely. CPU limits stop a runaway agent process from eating the whole box. Memory limits terminate anything that exceeds its allocation. Disk quotas cap filesystem usage and throttle I/O. Bandwidth controls flag the kind of sudden spike that looks a lot like a data dump in progress.
None of this solves the whole problem, though. Agents legitimately need to reach the outside world, for tool calls, for package installs, for the ordinary business of doing their job. And that's exactly where a naive, static allowlist starts falling apart.
Where static allowlists break down for agentic workloads
Backend services are predictable. They talk to a small, known, stable set of destinations, so a static allowlist works fine because the whole destination set is known the moment the policy gets written.
Agents don't work that way. An agent talks to whatever destination the model decides to reach for in the moment, often steered by user instructions, often pointed at an address that didn't even exist when the policy was drafted. The destination set is neither small nor stable, and pretending otherwise is how teams end up shipping a false sense of security.
The pip problem illustrates this cleanly. Teams allowlist *.pypi.org so sandboxed code can run pip install without friction, and that allowlist turns into a DNS-exfiltration path, because pip happily fetches arbitrary package names. The postmark-mcp supply-chain incident showed that the allowlist itself became the attack vector, not some hole outside it.
CVE-2026-22708 makes the problem structural rather than incidental. Allowlisted commands turned into delivery vehicles for arbitrary payloads. An allowlist that only checks the destination, and never inspects the context of the request, can be flipped and used against the very system it was meant to protect.
The real engineering problem is building controls that keep the agent genuinely useful without turning the runtime into an open relay for anyone clever enough to game the request. That means treating egress as a structured, policy-aware layer, not a flat, binary allow-or-deny firewall. That gap is precisely what signed-context proxies and identity-aware enforcement are built to close, and that's where the next two sections head.
Signed-context egress proxies and why the proxy must be kernel-enforced, not convention-trusted
A signed-context egress proxy sits between the agent and the network, and it makes decisions based on more than just where the request is headed. The agent's request carries metadata: session identity, which user kicked things off, the provenance of whatever upstream context triggered the call, which tool made the request, and a summary of the recent reasoning that led here. Crucially, the runtime signs that metadata, not the agent itself, so the agent can't forge its own permission slip. The proxy checks the signature and decides whether the request fits policy for that session.
That's a genuinely smart design. It also has a hole in it big enough to drive a truck through, if you stop reading one paragraph too early.
HTTPS_PROXY is an environment variable. It's a convention, a polite request that software agrees to follow, not a rule enforced by the kernel⟧c25⟦. And any tool that ignores the variable, opens a raw TCP socket, or resolves a hostname and connects directly, walks straight past the proxy like it was never there. Nobody stopped it, because nobody could. It just didn't ask permission.
A proxy control only earns its keep when it's paired with network-level lockdown, meaning egress rules that force every outbound packet through the proxy's port and block everything else at the infrastructure layer. An environment variable that the agent's process is merely trusted to respect is a suggestion wearing a security control's clothes.
The fix is pairing: a signed-context proxy for policy intelligence, plus kernel-level egress enforcement so the proxy physically can't be bypassed. Neither one alone gets the job done. If a vendor pitches a proxy-based tool, the fair question to ask is whether it's paired with infrastructure-level traffic enforcement. If the answer's no, what's been bought is an observability tool. It watches. It doesn't stop anything. The fundamental weakness of proxy-based controls is that HTTPS_PROXY is an environment-variable convention, not a kernel-enforced control.
eBPF-based network enforcement and Kubernetes-native identity policies
This is where the kernel finally gets involved directly, instead of being asked politely to cooperate.
The CubeVS pattern gives each sandbox its own TAP device with eBPF policy enforcement attached, and it's becoming something close to the standard approach for agent network isolation. Three eBPF programs sit directly on the kernel's data path: from_cube handles ingress on the TAP device, doing source NAT, policy checks, and session tracking; from_world handles ingress on the host's network interface, reversing that NAT and mapping ports; from_envoy handles egress on the overlay, doing destination NAT to route traffic to the right sandbox. By default, every private subnet gets blocked outright, including 10/8, 172.16/12, 192.168/16, 127/8, and 169.254/16, which covers cloud metadata service endpoints too grigio.org williamzujkowski.github.io. Metadata endpoints are where cloud credentials often live, and blocking them by default closes a door that's caused real incidents elsewhere.
CubeSandbox (CubeVM/KVM) is fully open-source under Apache 2.0 grigio.org williamzujkowski.github.io. Fast, cheap, and dense, which is a rare combination in security tooling.
Policies compile down into BPF programs that evaluate at the kernel level with per-packet granularity, and Hubble gives full visibility into every packet allowed or denied. Mutual authentication runs through SPIFFE-based mTLS without needing sidecar injection, and transparent encryption between nodes comes via WireGuard or IPsec.
An agent process cannot route around an eBPF program attached to its own TAP device or to the host's network interface, which closes the gap the proxy couldn't. There's no environment variable to ignore, no convention to skip. Enforcement is baked into the path the packet has to travel, not a request the agent gets to honor or not. Policy enforcement, in other words, has to live below the layer an attacker, or a compromised agent, can actually influence. User space was never that layer, and it never will be. Cilium on Kubernetes marks the transition from IP/port-based rules to intent-based policies defined by Kubernetes-native identity (Pod names, labels). CiliumNetworkPolicy extends standard Kubernetes NetworkPolicy to L3/L4/L7, covering HTTP method/path filtering, DNS-based egress, and FQDN policies.
Microsegmentation and agent-level firewalls for tool-call interception
Even with airtight egress control, one more risk sits inside the network itself. An agent with compromised execution can pivot sideways, and scanning the internal network from inside a sandbox is a named threat in the 2026 sandbox threat model. Getting out to the internet isn't the only danger. Getting around, from one internal service to another, matters just as much.
Microsegmentation closes that east-west gap. Each agent sandbox should carry network policy that stops it from reaching other sandboxes, internal databases, or control-plane services it has no legitimate reason to touch. If the agent's job is to edit code in one repository, its network policy shouldn't let it so much as ping a payments database three subnets over.
Agent-level firewalls handle a different layer of the same problem: the tool-call layer, not the network layer. AEGIS, an open-source, self-hosted option, sits between the agent and its tools and intercepts before execution happens. The pipeline runs in sequence: the agent calls a tool, the AEGIS SDK intercepts it, a gateway classifies what kind of call it is (SQL query, file operation, shell command), a policy engine evaluates it for injection, path traversal, or exfiltration risk, and a decision gets made, allow, block, or hold for human review. That's not just a log file somebody might check later. It's a tamper-evident record built to survive scrutiny.
As of August 2026, the open-source agent firewall landscape splits roughly into three camps. The first covers network allowlist and control-plane tools: gh-aw-firewall, which is open source though GitHub's own documentation notes MCP traffic sits outside its scope, iron-proxy running in its self-hosted, allowlist-first default mode, and straightforward infrastructure controls like NetworkPolicy, CNI egress rules, and VPC egress firewalls. The second camp handles MCP gateway and routing, a crowded field including Docker MCP Gateway, Runlayer, the open-source agentgateway, TrueFoundry, Operant AI, Obot, Lasso, and MintMCP, with capability and content-inspection depth varying a good deal from one to the next. A third camp works at the inference layer itself, filtering content closer to where the model actually generates its output.
None of the three properties (access to private data, exposure to untrusted content, and the ability to communicate externally) replaces the others. A network allowlist doesn't know what a tool call is doing once it's inside the perimeter, and a tool-call firewall doesn't stop a raw socket connection that bypasses it entirely. Layered together, egress control, kernel-enforced proxying, microsegmentation, and tool-call interception, they cover the ground that any single one leaves exposed. That's the whole point of a layered strategy: nothing on this list is sufficient by itself, but stacked correctly, they turn a self-hosted agent into something contained, instead of something that just hasn't caused an incident yet.


