What is AI agent sandboxing?

NOFire AI

What is AI agent sandboxing and which isolation substrate should I use?

AI agent sandboxing runs agent-generated code inside an isolation boundary so that a compromised or mistaken agent cannot reach the host or the rest of the estate. The substrate choice, container, gVisor, Kata, microVM or unikernel, is a trade between isolation strength and startup cost. NOFire AI issues sandbox grants that are scoped, time-limited and bound to a task.

VerdictSandboxing contains code after it is running. It does not verify the artifact before it loads and it does not decide which actions are allowed, so it is one control of three rather than the answer on its own.

AI agent sandboxing is the practice of running agent-generated code inside an isolation boundary, so that an agent which has been compromised, prompt-injected, or is simply wrong cannot reach the host or the rest of the estate. The premise is that the agent is untrusted by default, which is a different starting point from most application security and the reason designing for breach is the useful frame.

The question is almost never whether to sandbox. It is which boundary, because the substrates differ by orders of magnitude in both isolation strength and cost.

What sandboxing does and does not protect against

Sandboxing is containment after execution has started. Being precise about that boundary is what makes the control worth having, because it is routinely oversold.

It contains. Code running inside a sufficiently strong sandbox cannot read the host filesystem, reach services it was not granted, or escalate through the host kernel. If an agent is induced to run something destructive, the destruction is bounded by the sandbox.

It does not verify. Nothing about a sandbox checks whether the artifact that just loaded is the one you expected. A poisoned dependency, a tampered model, or a malicious tool definition runs perfectly happily inside a strong sandbox. That is a supply chain control, and it belongs upstream in the pipeline as signature verification. In the OWASP agentic threat taxonomy this is the class sandboxing is weakest against.

It does not decide. A sandbox constrains where code can reach. It has no opinion about whether the action should happen at all. An agent permitted to call the deployment API from inside a perfectly isolated sandbox can still roll out a bad change to every user. Deciding which actions are allowed is runtime policy enforcement, and it is a separate layer.

Prompt injection sits across all three. The sandbox limits the blast radius of a successful injection and does nothing to prevent it.

The isolation substrates

SubstrateIsolation boundaryWhat an escape requiresReported cost
Container, namespaces and cgroupsShared host kernelA Linux kernel exploitNative
Container plus seccomp and a tight profileReduced syscall surfaceA kernel exploit within the allowed syscallsNear native
gVisorUser-space kernel, the SentryBreaking the Sentry, or the roughly 50 host syscalls it still allowsSentry footprint around 20 to 40 MB; simple syscalls measured 2.2 to 2.8x slower under runsc
Kata ContainersA lightweight VM with its own guest kernelBreaking the hypervisorAround 100 to 180 MB per pod; virtio I/O typically within 2 to 3x native
Firecracker microVMGuest kernel plus a minimal device modelBreaking the hypervisor, across a deliberately small device surfaceBoots in under 125 ms, roughly 5 MB overhead per VM
Unikernel, for example uruncSingle-purpose guest with no general-purpose kernelBreaking the hypervisor, with almost no in-guest surface to pivot throughContainer-class startup with VM-class isolation

The numbers vary by workload and the syscall-heavy cases move most, so treat them as the shape of the trade rather than constants. gVisor's Systrap platform, which replaced ptrace with a seccomp-based trap, cut context-switch overhead materially on syscall-heavy workloads and the older figures overstate the tax.

The pattern underneath is consistent. Moving the boundary further from the host kernel buys isolation and costs either memory or startup time. What changed recently is that microVM and unikernel runtimes narrowed the startup penalty enough that the old reason to accept a shared kernel, that VMs are too slow for short-lived work, no longer holds for most agent workloads.

Running it in Kubernetes

The mechanism is RuntimeClass, and it is the part people expect to be harder than it is.

You install a sandboxed runtime on the node, register it as a RuntimeClass, and set runtimeClassName on the pod spec. Scheduling, networking and the rest of the orchestration layer are unchanged, which means sandboxing can be applied per workload rather than as a cluster-wide decision. That granularity matters: the useful policy is usually strong isolation for anything an agent generated and standard containers for everything you built and reviewed.

urunc and the Kubernetes agent-sandbox CRD is how that is wired for unikernel-backed sandboxes through containerd.

How to choose

Start from what the code is, not from a security tier list.

Code your team wrote and reviewed does not need a microVM. Standard containers with a tight seccomp profile are proportionate, and reaching further costs real money in memory and latency for a threat you do not have.

Code an agent generated is untrusted regardless of which model produced it, and the shared host kernel is the wrong boundary for it. Somewhere at or beyond gVisor is the floor.

Then let the workload shape pick between the stronger options. A long-lived, syscall-heavy process pays gVisor's syscall tax continuously and is usually better in a VM-backed sandbox. A short-lived, high-churn workload, which is what most agent tasks are, is dominated by startup cost, and that is where microVM and unikernel runtimes win outright.

The last question is the one this page opened with. A sandbox is one of three controls, and the other two are artifact verification before load and policy enforcement on what the code is allowed to do. The sandboxing whitepaper covers the substrate comparison in depth, and AI agent governance covers the enforcement layer that decides which actions a sandboxed agent may take at all.

Frequently asked questions

Are containers enough to sandbox an AI agent?
Not for untrusted code. A standard container shares the host kernel, so the isolation boundary is the whole syscall surface and a kernel exploit reaches the host. Containers are fine for code you wrote and wrong for code an agent generated.
What is the difference between gVisor and Kata Containers?
gVisor intercepts syscalls in a user-space kernel called the Sentry, so an escape means breaking the Sentry or the small set of host syscalls it still allows. Kata runs each workload in a lightweight VM, so an escape means breaking the hypervisor.
How do I run a sandboxed workload in Kubernetes?
Through RuntimeClass. You install a sandboxed runtime such as gVisor's runsc, Kata Containers or a microVM runtime like urunc, register it as a RuntimeClass, and set `runtimeClassName` on the pod spec. The orchestration layer does not otherwise change.
Does sandboxing protect against prompt injection?
It limits the damage, not the injection. A successful injection still makes the agent attempt an action; the sandbox bounds what that action can reach. Deciding whether the action is permitted at all is policy enforcement, which is a separate control.
Book a demo