What an agent sandbox actually has to isolate#
When an artificial intelligence coding agent runs shell commands, installs packages, starts Docker containers, and runs tests on its own, a plain container is not enough. An agent sandbox has to answer five concrete questions:
- Can the agent escape the container to the host node?
- Can it run Docker builds without privileged mode?
- Can a prompt read secrets or connector OAuth tokens from the environment?
- Can it reach internal platform datastores it was not granted?
- Where does it deploy and test a full app stack without touching the cluster?
Nested does not rely on one layer for all five. It combines three sandbox layers that match different risk levels, all checked against shipped code.
Layer 1: Standard agent sandbox with Sysbox#
Every Nested agent runs as a single unprivileged cloud-agent pod (uid 1000) in your Kubernetes cluster. On clusters with Sysbox installed, the default Standard runtime pairs the Sysbox runtime class with a user-namespaced pod (hostUsers: false).
- The pod runs its own inner Docker daemon without privileged mode on the Kubernetes node. Nested strips privileged mode from every non-Kata agent pod.
- Node placement keeps agent pods on
nested.io/agents=truenodes and offnested.io/platform=truenodes when role labels are configured. - Two persistent volumes (20 GiB each by default for workspaces and Docker storage) keep work across restarts without exposing host disks.
If a cluster does not have Sysbox, Standard falls back to the default container runtime. If an operator sets a runtime class explicitly, Nested never silently drops it — the deploy fails with an error instead.
Layer 2: Hardware-isolated VM with Kata Containers#
Some teams run AI agents on untrusted third-party repositories or strict compliance workloads where a shared Linux kernel is not acceptable. When a cluster has Kata Containers with KVM, the deploy wizard offers an Isolated VM runtime (nested-kata).
| Sandbox mode | Kernel isolation | Docker inside pod | Memory reservation | Build speed |
|---|---|---|---|---|
| Standard (Sysbox) | User namespace + Sysbox | Yes, unprivileged | Requests 3 GiB, limit 8 GiB | Full speed |
| Isolated VM (Kata) | Dedicated microVM kernel | Yes, inside the VM | Reserves full memory limit | ~1.6× slower builds |
| Environment VM | Separate cloud VM, outbound-only gateway | Full Docker or k3s | Separate machine per env | Isolated from cluster |
Once an agent is created, its runtime is fixed. If Kata is missing when an Isolated VM agent deploys, Nested refuses to downgrade it to a shared kernel.
Layer 3: Inside the pod — env filtering, token proxies, and Code Mode#
Kernel boundaries stop host escapes, but a coding agent still runs inside the pod. Nested narrows what the AI process can see:
- Deny-by-default environment. Coding-agent processes, terminals, and hook scripts receive only a short allowlist (
PATH,HOME,LANG,TERM, and configured entries). Variables matching*_SECRET,*_TOKEN,*_PASSWORD,DATABASE_*,AWS_*, andKUBERNETES_*are stripped. - No raw OAuth or git tokens in the checkout. Connector tokens stay encrypted in the control plane; a loopback proxy adds them to outbound requests. Git clone, fetch, and push also go through a loopback proxy so remote URLs never contain credentials.
- Sandboxed MCP Code Mode. When an agent runs JavaScript via
nested_mcp_exec, the script runs in a locked sandbox with onlymcpandconsole— no filesystem, network, timers, or module loading, capped at 25 connector calls and 256 MiB memory growth. See Cutting MCP tool overhead with a catalog and Code Mode.
Layer 4: Short-lived Environment sandboxes for running apps#
When an agent needs to boot an entire multi-service app, run end-to-end tests, and share a preview URL, it can spin up an optional Environment: one dedicated virtual machine running Docker or single-node Kubernetes (k3s) from a saved manifest. Every inbound port on the VM is closed; all Docker, Kubernetes, log, exec, and preview traffic relays through an outbound-only gateway. See Saved manifests for Environments and Environments.
What an agent sandbox does not solve alone#
- Secrets you explicitly bind to the agent. If a tool needs a secret in its process environment, a determined prompt can read it. Bind only the minimum secrets each agent needs, and use connectors or site logins wherever possible.
- Network policies. Sandboxes isolate the pod, while your cluster’s NetworkPolicies decide which internal services an agent pod may reach. See The Nested security model, layer by layer.
Questions
- What is an AI agent sandbox?
- An isolated runtime environment where an AI coding agent can execute shell commands, edit files, run builds, and test code without risking the host machine, other workloads, or sensitive credentials.
- How does Nested sandbox AI coding agents on Kubernetes?
- Nested runs each agent as an unprivileged pod using Sysbox user namespaces by default or a Kata Containers microVM (Isolated VM), strips sensitive environment variables, proxies git and connector tokens, and offers separate Environment VMs for running full apps.
- Can a Nested agent run Docker inside its sandbox without privileged mode?
- Yes. With the Sysbox runtime and user namespaces (hostUsers: false), or inside a Kata microVM, an agent runs its own Docker daemon without requiring privileged container mode on the Kubernetes node.
- When should I pick Kata Isolated VM over Standard Sysbox?
- Pick Isolated VM when you need a separate kernel per agent for untrusted repositories or strict compliance. Pick Standard Sysbox for everyday team repositories where faster startup and builds matter more.
More from the blog
2 min read
AI skills for coding agents: turning team standards into verified packs
What an AI skill is, why copy-pasted prompts drift across teams, and how Nested packages SKILL.md files, MCP servers, and formulas into verified packs.
3 min read
Lower software development costs with self-hosted AI coding agents
How teams cut software development costs with AI agents without cutting quality: scale-to-zero Kubernetes pods, MCP token savings, and formula gates.





