Sandboxing AI Agents with gVisor, Containers, and MicroVMs
The gVisor project provides an application kernel that creates a strong layer of isolation between running applications and the host operating system. As of 2026-11-29, it supports x86_64 and ARM64 on Linux 5.6 or newer and uses systrap as its default interception platform. When running untrusted workloads, developers use standard Docker containers, gVisor, or Firecracker microVMs depending on their performance and security requirements.
What is gVisor and how does its architecture isolate workloads?
When an automated agent runs arbitrary code inside a standard Docker container, that code talks to the host's Linux kernel directly: Docker container isolation stops at the shared kernel. An unpatched kernel bug can allow untrusted code to compromise the entire machine. The gVisor project was created to provide an additional defense against the exploitation of host kernel bugs by untrusted userspace code.
Rather than filtering system calls or running a full virtual machine, gVisor acts as an application kernel that runs in userspace. It implements a Linux-like interface written in Go, which is a memory-safe language. The system architecture splits isolation duties between two distinct components:

- Sentry: A userspace application kernel that handles system calls originating from the container. It does not pass container system calls through to the host kernel, although the Sentry process makes its own system calls to the host to operate.
- Gofer: A companion host process started alongside each container. The Sentry executes inside a restricted seccomp environment without file system access, so it communicates with the Gofer over the 9P protocol to mediate all file operations.
System call interception relies on one of two operational platforms:
- systrap: The default platform since mid-2023, replacing the older ptrace mechanism. It uses seccomp with SECCOMP_RET_TRAP to deliver a SIGSYS signal to the calling thread during a system call. It functions inside existing virtual machines and on machines without hardware virtualization support.
- KVM: Uses host virtualization extensions. On bare metal installations outside a virtual machine, KVM provides the best performance. While nested virtualization functions inside guest virtual machines, systrap is frequently faster in nested environments.
The ptrace interception platform is no longer supported and is expected to be removed.
Security boundaries have specific limitations. The documentation notes that gVisor does not protect against vulnerabilities in containerd that launch a container without gVisor, Spectre-style side channels, or exploits occurring entirely inside the sandboxed workload itself.
How do you install runsc and configure Docker?
Using the runsc OCI runtime requires Docker 17.09.0 or newer. The install page announced that the automatic download through runsc install would be dropped at the end of September 2026, and points to the apt repository or the release tarball instead.
Releases follow a date-based naming format, release/yyyymmdd. The apt repository provides release, nightly, master, and dated release branches. To install runsc on Debian or Ubuntu, add the repository signing key and list file, then install the package:
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl gnupg
curl -fsSL https://gvisor.dev/archive.key | sudo gpg --dearmor -o /usr/share/keyrings/gvisor-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gvisor-archive-keyring.gpg] https://storage.googleapis.com/gvisor/releases release main" | sudo tee /etc/apt/sources.list.d/gvisor.list > /dev/null
sudo apt-get update && sudo apt-get install -y runsc
Alternatively, download the release tarball for your architecture, check it, and unpack it into /usr/local/bin:
ARCH=$(uname -m)
URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH}
wget ${URL}/gvisor.tar.zstd ${URL}/gvisor.tar.zstd.sha512
sha512sum -c gvisor.tar.zstd.sha512
sudo tar --zstd -xf gvisor.tar.zstd -C /usr/local/bin
The archive supplies runsc, containerd-shim-runsc-v1, and a gvisor-bin directory, which must stay in the same directory as runsc.
Once runsc is in place, register the runtime with Docker and restart the system service:
sudo runsc install
sudo systemctl restart docker
Running runsc install updates /etc/docker/daemon.json by registering a runtime entry named runsc.
To run a container under gVisor, pass the runtime to docker run:
docker run --runtime=runsc --rm hello-world
docker run --runtime=runsc --rm -it ubuntu /bin/bash
For a quick look, run dmesg inside a container started with runsc:
docker run --runtime=runsc -it ubuntu dmesg
The output prints a synthetic log generated by gVisor, starting with "Starting gVisor..." and concluding with "Ready!". The documentation warns never to rely on dmesg output to verify the runtime inside a security-sensitive context.
What are the performance costs and compatibility limits?
An AI agent sandbox built on an application kernel costs something, and the cost depends on the workload:
- CPU operations: There is no CPU emulation and no extra cost for raw memory access, resulting in no runtime penalty for pure CPU calculations.
- System calls: Intercepting system calls costs more processing time than native kernel execution, with the exact impact depending on the active platform. Syscall-heavy workloads encounter large overhead, with the documentation citing small operations in Redis as a primary example.
- Network throughput: Networking performance is limited by implementation costs, as the userspace network stack is less CPU efficient than the host Linux kernel network stack.
- File system operations: All file operations pass through the Gofer process via the 9P protocol. Static file serving tests using Apache demonstrated poor throughput.
- Container startup: Most startup time remains attributable to Docker itself rather than the runtime.
Application compatibility requires empirical testing. The gVisor project implements a large portion of the Linux interface, but missing features and bugs exist. The documentation states that the only way to confirm that an application works is to test it. Regression test suites run against Go, Node.js, Python, Java, and PHP runtimes.
Known compatibility limitations include:
- Resource limits between separate processes within the same sandbox are not enforced.
- Block-device file systems such as ext4 lack native support.
- Network packet filtering through iptables is only partially implemented.
- Device files are generally unsupported, with explicit exceptions for NVIDIA GPUs and TPUs.
- The io_uring interface is disabled by default.
- Running KVM inside the sandbox is not supported.
Which isolation route fits your workload?
Selecting an isolation boundary requires balancing host protection against operational requirements. Standard containers share the host Linux kernel directly.
On the Screenbox system, each desktop instance runs as a Docker container created via docker create with a strict memory limit, no extra swap space, 2 CPUs, and 256 MB of shared memory. Files move only through explicit API calls without host bind mounts. As described in the guide to running agents on Linux, these desktop containers are isolated environments but not hardened sandboxes. Screenbox documentation specifies that operators must not expose the MCP API to the public internet and must review untrusted agents before execution. Screenbox has no setting to run desktops under gVisor.
For workloads requiring virtualized hardware boundaries, the Firecracker project provides open source virtualization technology designed for secure, multi-tenant container and function services. Firecracker runs workloads in lightweight virtual machines called microVMs and uses Linux KVM to create them.
| Route | Isolation mechanism | System call handling | Virtualization requirement |
|---|---|---|---|
| Plain Docker container | Shared host Linux kernel | Direct execution on host kernel | No virtualization required |
| gVisor (runsc) | Userspace Sentry kernel with Gofer file proxy | Intercepted in userspace by Sentry | Not required for systrap; optional KVM on bare metal |
| Firecracker microVM | Isolated microVM | Executed within guest virtual machine | Requires Linux KVM |

Frequently asked questions
Can gVisor protect against side-channel CPU vulnerabilities?
No. The architecture guide states that gVisor does not protect against Spectre-style side channels. It also does not protect against exploits in containerd that start a container without gVisor, or exploits that occur entirely within the sandboxed workload itself.
Does gVisor require KVM hardware support to run?
No. While KVM provides the best performance on bare metal machines, gVisor uses systrap as its default interception platform. The systrap platform is the recommended option when running inside a virtual machine or on hardware lacking virtualization support.
Can you run KVM virtualization inside a gVisor sandbox?
No. Running KVM inside the sandbox is not supported by gVisor.
How does gVisor isolate file system access from the host?
gVisor isolates file system access using a dedicated host process called the Gofer. Each container launches a Gofer that communicates with the Sentry application kernel over the 9P protocol. The Sentry operates within a restricted seccomp environment without direct file system access, ensuring all file interactions are mediated by the Gofer.