# Agent sandboxes on Kubernetes: Sysbox, Kata, and Environments

> How an AI agent sandbox isolates untrusted code execution on Kubernetes: Sysbox user namespaces, Kata microVMs, deny-by-default env, and short-lived VMs.

Published: 2026-12-04 · Topics: Security, Agents, Architecture · Canonical: https://nested.me/blog/agent-sandbox-kubernetes-sysbox-kata

## 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:

1. **Can the agent escape the container to the host node?**
2. **Can it run Docker builds without privileged mode?**
3. **Can a prompt read secrets or connector OAuth tokens from the environment?**
4. **Can it reach internal platform datastores it was not granted?**
5. **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=true` nodes and off `nested.io/platform=true` nodes 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_*`, and `KUBERNETES_*` 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 only `mcp` and `console` — 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](https://nested.me/blog/mcp-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](https://nested.me/blog/saved-environment-manifests) and [Environments](https://nested.me/docs/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](https://nested.me/blog/nested-security-model).

## 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.
