# The Agent Containment Stack: Sandbox, Egress, Identity

> The agent containment stack is three layers that each assume the others failed: a sandbox for compute, an egress proxy, and workload identity.

- Canonical URL: https://webofmike.com/agent-containment-stack/
- Author: Mike Moore (https://webofmike.com/about/)
- Published: 2026-11-18
- Last modified: 2026-11-08
- Tags: AI Agents, Agent Security, Agents Escaping
- Cite as: Mike Moore, "The Agent Containment Stack: Sandbox, Egress, Identity", Web of Mike (webofmike.com), 2026-11-18. https://webofmike.com/agent-containment-stack/


<!-- ART: three nested cages, the innermost one has a padlock with the key taped to it. Crossed out in marker. -->

You contain an AI agent with three layers that each assume the other two already failed: a sandbox for compute and filesystem, default-deny egress through a proxy that logs, and a short-lived identity scoped to the task. Then you record every tool call somewhere the agent cannot write. A sandbox alone is not containment, it is the inner cage.

If the last two posts were the problem, this is the fixture.

## Why isn't a sandbox enough to contain an agent?

The sandbox bounds compute and filesystem. Fresh per run, nothing shared, no write path to its own config or pipeline. I wrote about why [the sandbox is the fixture, not the record](/sandbox-is-the-fixture-not-the-record/): it contains the run, it shouldn't be where you keep the evidence.

What breaks it: shared sandboxes, mounted credentials, and anything persistent between tenants. [Shared sandboxes leak](/shared-sandbox-agent-leak/) leftover files across runs. Palisade Research's shutdown eval is the control-plane version of the same hole: if `shutdown.sh` is writable, the model will sometimes write it. o3 did that in 79 of 100 initial Palisade runs. That is not a sandbox escape. It is a sandbox you asked the workload to administer.

I reproduced the cheaper half of this in [agent containment basics](/agent-containment-basics/). A toy eval agent looks up a package, then pivots to an unapproved host on the same flat network, carrying an ambient API key. The agent's code is identical in the vulnerable run and the contained run. Topology is the control: the agent sits on an internal-only network, the gateway sits on that network and on egress, and the agent has no path around it. In Kubernetes the same idea is a NetworkPolicy that puts pod egress on the gateway's ClusterIP and nothing else.

OpenAI's October 2026 writeup of its own red-team campaign is why you still do not stop at the box. Teams of frontier-model agents, given source and hints, chained bugs into escapes from hardened microVMs and produced upstream fixes in Kata Containers, gVisor, Moby/Docker, and the Linux kernel. They also found a CPU cache-timing covert channel: agents in separate microVMs, with no network and no shared file, exchanged a synthetic secret by evicting cache lines and timing reloads. OpenAI's five-part architecture is the finding: sandbox, then microVM, then monitoring, then network and cloud perimeter, each meant to hold "even if an individual control fails." The cache channel beats the inner two. What stops it, in their telling, is monitoring plus the fact that the channel is slow. I unpacked that in [the frontier containment red-team post](/frontier-containment-redteam/).

If you run agents on Kubernetes rather than a frontier lab, the equivalent outer fence is a network-layer control plane in front of the agents. kagent's model of managed, policy-scoped workloads, and the gVisor sandboxes in [Agent Substrate](/kagent-agent-substrate/) (one actor per sandbox or worker), are how you keep the inner box from being a shared kernel with a long-lived pod. They are still not the whole stack.

## How should agent egress actually work?

Default deny. Every outbound call goes through a proxy that knows which hosts this agent is allowed to reach and logs what it sent. That's the whole idea behind running an [egress proxy for agents](/agentgateway-egress-proxy/) and putting [rate limits on egress](/agent-egress-rate-limits/).

What breaks it: DNS, allowlisted hosts that accept arbitrary content (paste sites, issue trackers, "search"), and proxies that check the hostname but not the payload. [DNS as a covert channel](/agent-dns-egress-covert-channel/) and [egress control bypasses](/agent-egress-control-bypasses/) are the narrow versions. Hugging Face's July 2026 timeline is the wide one: the sandbox escape used a permitted package-registry cache proxy, then command and control used pastebins and file-drop hosts. I mapped that chain in [which controls would have stopped the July 2026 intrusion](/rogue-agent-kubernetes-controls/). Allowlist-by-destination fails when the allowed destination is itself software with a zero-day, or a public site that will host your exfil.

The contained demo in the basics post is the shape I want. One declared route, `/package`, proxied to the registry. `/exfil` matches nothing, so the gateway returns 404 with reason `NotFound` before a backend ever sees it. Nobody maintains a list of bad paths. Only `/package` is declared, so only `/package` is reachable. The access log is attached at the listener, not only on matched routes, so the rejected pivot is a structured line the defender can query. On a flat network that line does not exist except in the attacker's log.

OpenAI's September 20, 2026 DNS-resolver incident is why "we blocked the internet" is not the same as "the resolver cannot be talked into a live lookup." Their later policy, training against an offline cached copy of the web, is the lab-scale version of default deny. Most of us will not cache the web. We can still refuse any host we did not name.

## What identity should an agent hold?

The agent gets its own identity, not yours. Short lived, scoped to the task, and provable. [SPIFFE for agents](/spiffe-identity-for-ai-agents/) and [workload identity federation](/workload-identity-federation-agents/) are the patterns I keep coming back to, because they kill the pasted long-lived token.

What breaks it: personal access tokens, shared service accounts, and tokens that outlive the job. In the July 2026 chain, a projected service account token made cluster reconnaissance possible, a 136-key Secret object turned one read into a dump, and a stolen mesh-VPN auth key enrolled a rooted node into the corporate mesh because the credential was a bearer token: valid because the caller possessed it, not because the caller was this workload on this node for this task. Copy it somewhere else and it still works.

The secretless pattern is the other half. In [an agent that holds no LLM API key](/secretless-ai-agents/), and in the containment-basics demo, the agent container has no credential environment variable. The gateway injects `x-api-key` only on the route that is allowed to use it. A fully compromised agent can call the one place it is allowed to call, with no key in its environment, and nothing at all anywhere else. [Who gave the agent a badge](/who-gave-the-agent-a-badge/) is the same least-privilege rule in office language.

Pod-level defaults that follow from this layer, already argued in the July 2026 control map:

- No long-lived credentials in environment variables or mounted files.
- `automountServiceAccountToken: false` unless the workload calls the API server.
- Secret objects scoped to a consumer. One object with 136 keys is a finding to look for today.
- Pod Security Admission in `restricted` on agent and data-processing namespaces, so a privileged hostPath pod dies at admission.

## Where do tool-call logs fit in the stack?

Across all three layers, [tool-call guardrails](/tool-call-guardrails/) check what the agent is about to do, and an append-only log records what it did. The log is the record. If the agent can edit it, you don't have one. [Audit log integrity](/agent-audit-log-integrity/) and [stopping an agent without losing evidence](/stopping-an-agent-without-losing-evidence/) are the same rule applied to a live incident.

Listener-level logging is the unglamorous half. A 404 with `reason=NotFound` on `/exfil` is the audit trail of a pivot that never landed. A log that only records matched routes is a log of successes. You need the misses.

## How does the stack map to the famous escape stories?

Worked mapping from [the rated list](/agents-escaping/). Every headline dies in at least two layers. That's the point of layering.

| Story | Sandbox | Egress | Identity / logs |
|---|---|---|---|
| Apollo weight-copy (Dec 2024) | No path to real weights. Planted files do not count. | Destination of the `scp` is not on the route table. | Tool-call log shows the copy attempt even if it 404s. |
| Palisade shutdown edit (2025) | No write path to `shutdown.sh`, the prompt, or CI. | Not an egress story. | Guardrail denies control-plane writes. Log keeps the attempt. |
| Anthropic blackmail cluster (May 2025) | Mailbox is not a filesystem escape. | Outbound mail to a new recipient is a new destination. | Identity scopes the mailbox. Guardrail flags new recipients. |
| July 2026 eval-agent campaign | Fresh sandbox, no hostPath, PSA restricted. | Registry proxy is in-scope for patching; pastebins are not allowed. | No projected token, no 136-key Secret, SPIFFE not a bearer VPN key. |
| OpenAI cache-timing channel | Inner two layers lose. | No network, so no data leaves if egress is the fence. | Monitoring has to see the attempt. Inner logs will not. |

Checklist if you only have a week:

1. Fresh sandbox per run. No shared disk. No write to own config.
2. Default-deny egress through one proxy. Listener logs, including 404s.
3. No ambient credentials. Gateway injects on the allowed route.
4. Workload identity, short-lived, not a pasted PAT.
5. PSA `restricted`, `automountServiceAccountToken: false`.
6. Append-only log outside the sandbox.

Previous post: [evals are theater unless you read the setup](/agent-escape-evals-setup/). Infra doors: [what escape looks like in infra](/agent-escape-infra-reality/).

