Sub topic 2
From processes to VMs: what each boundary shares with the host
This chapter assumes you are comfortable with the Linux command line, know basic Docker usage (images, containers, volumes), and understand Linux users and file permissions. It also assumes you have a general idea of what an LLM-based coding agent does. The chapter does not cover how to configure each boundary. Later chapters do that.
The question every boundary answers
An isolation boundary is a mechanism that limits what code inside it can see and do outside it. Every boundary can be described by one question: what does the code inside still share with the host?
The most important shared thing is the kernel. The kernel is the core of the operating system. It handles system calls (syscalls), which are the requests a program makes to read files, open sockets, start processes, and allocate memory. If sandboxed code and the host use the same kernel, a bug in that kernel can let the code escape. This is called an escape.
So the useful way to compare boundaries is by shared surface. The shared surface is the set of interfaces that sandboxed code can reach and that, if flawed, give it access to the host. A smaller surface means a stronger boundary. It usually also means more overhead and more setup work.
The spectrum at a glance
Moving from left to right in the diagram, each step shrinks the surface that the agent's code can attack.
The table below states the same ordering in more detail.
| Boundary | Kernel used by agent code | Main shared surface with host | Typical startup | Typical overhead |
|---|---|---|---|---|
| Plain process (same user) | Host kernel | Everything the user can access | Milliseconds | None |
| Separate user account | Host kernel | Kernel, any files with permissive modes | Milliseconds | None |
| Container | Host kernel | Full syscall interface, filtered by seccomp and capabilities | Under a second | Very low |
| gVisor (runsc) | A user-space kernel written in Go | A reduced set of host syscalls used by gVisor itself | Around a second | Moderate, higher for syscall-heavy work |
| VM | Its own guest kernel | Hypervisor and emulated devices | Seconds to tens of seconds | Moderate |
| microVM | Its own guest kernel | Hypervisor and a very small set of devices | Often well under a second to a few seconds | Low to moderate |
Startup and overhead figures are rough and depend on the image, hardware, and configuration. Treat them as orders of magnitude.
Level 0: a plain process
The simplest option is to run the agent as an ordinary process under your own account. This is what happens when you start an agent in your terminal with no extra setup.
The agent can do anything you can do. It can read ~/.ssh, read environment variables that hold tokens, edit your shell profile, and delete any file you own. It can also open network connections to anywhere your machine can reach.
Nothing is isolated here. The only protection is whatever the agent's own permission prompts enforce. Those prompts are policy inside the agent, not a boundary around it. If the model produces a harmful command and the command runs, the operating system does not stop it.
Level 1: a separate user account
A step up is a dedicated Linux user for the agent. Linux file permissions then stop the agent from reading your home directory, assuming those files are not world-readable.
sudo useradd --create-home --shell /bin/bash agent
sudo -u agent -H bash -c 'cd ~ && pwd && id'This costs almost nothing and removes the biggest risk from a plain process: access to your personal files and credentials. It still has clear limits.
- The agent shares the host kernel, process table, and network.
- Anything with loose permissions, such as files in
/tmpor world-readable directories, remains visible. - The agent can see other processes (for example through
ps) and can bind to ports. - A local privilege escalation bug lets it become root.
A separate user is a reasonable baseline for a trusted agent on a machine you control. It is not enough for untrusted code.
Level 2: containers
A container is a process, or group of processes, that the kernel runs with a restricted view of the system. A container is not a small VM. There is no guest kernel. The processes run directly on the host kernel, and the kernel uses its own features (namespaces, cgroups, capabilities, and seccomp) to limit what they see and use. The next chapter explains those features. For now, what matters is what the container shares.
What a container does not share with the host by default:
- The filesystem. It sees its own image layers plus any volumes you mount.
- The process list. It sees only its own processes.
- The network stack. It gets its own interfaces and routing, though Docker's default bridge network still allows outbound traffic.
- Most Linux capabilities. Docker drops many of them, though not all.
What it does share:
- The host kernel. Every syscall the container makes is handled by the same kernel code that handles host processes.
- Kernel-wide resources that are not namespaced, such as some kernel modules, parts of
/procand/sys, and the clock (except with time namespaces). - Any host path you mount in, any device you pass in, and any socket you expose.
You can see the shared kernel directly. The kernel version printed inside a container matches the host:
uname -r
docker run --rm python:3.12-slim uname -rBoth commands print the same version. On Docker Desktop for macOS or Windows, both would show the VM kernel that Docker Desktop runs, not the macOS or Windows kernel. Docker Desktop therefore adds a VM layer, but containers inside that VM still share one kernel with each other.
Where container isolation fails
Container escapes come from a few repeated causes.
- Kernel vulnerabilities. A flaw in a syscall implementation that the container can reach lets a process gain kernel-level access. Seccomp filters block some syscalls but cannot block the ones a normal program needs.
- Runtime vulnerabilities. Bugs in
runcor similar components have allowed escapes in the past. - Configuration mistakes. These are the most common. Examples are
--privileged, mounting/var/run/docker.sock, adding capabilities such asSYS_ADMIN, mounting the host root, or running with--pid=host.
The third group matters most for agent work, because it is under your control. A container started with --privileged has almost none of the isolation described above.
Level 3: a user-space kernel (gVisor)
gVisor is a sandbox runtime that sits between the container and the host kernel. It implements most of the Linux syscall interface in a user-space program, written in Go. When agent code makes a syscall, gVisor handles it itself. gVisor then makes a much smaller set of syscalls to the host kernel to do real work.
The result is that the host kernel's large syscall surface is no longer directly reachable from the agent's code. An attacker must first find a bug in gVisor's implementation, and then find a way from gVisor's process to the host through the narrow set of calls it uses. gVisor also runs with restricted privileges and its own seccomp filter.
It plugs into Docker as an alternative runtime:
docker run --rm -it --runtime=runsc python:3.12-slim bashThis requires gVisor to be installed and registered as a Docker runtime. If it is not, Docker reports an unknown runtime error.
The trade-offs are real:
- Syscall-heavy workloads run slower, because each syscall goes through gVisor first. File-heavy builds and some network tests can be noticeably affected.
- gVisor does not implement every syscall or every
/procand/sysdetail. Some programs, especially those that depend on unusual kernel features, fail or behave differently. - It is still a shared-host design. The host kernel is still there and still reachable through gVisor's own calls.
Because the agent's tools (compilers, package managers, test runners) mostly use common syscalls, many development workflows run fine. Test your own toolchain before relying on it.
Level 4: virtual machines and microVMs
A virtual machine (VM) runs a complete guest operating system, with its own kernel, on virtual hardware provided by a hypervisor. The hypervisor is the software that creates and runs VMs, for example KVM on Linux. The guest kernel handles all of the agent's syscalls. A compromise of the guest kernel gives the attacker control of the guest only.
To reach the host, an attacker must break out through the hypervisor or one of the emulated devices (network card, disk controller, and so on). That interface is much smaller and better defined than the full syscall interface. Escapes exist, but they are rarer and usually more expensive to find than kernel escapes.
A microVM is a VM with a deliberately minimal design. It has few emulated devices, a stripped-down guest kernel, and no BIOS-style legacy hardware. Firecracker and Cloud Hypervisor are examples of microVM monitors. Fewer devices mean less code in the shared surface and faster boot. Several hosted agent platforms use microVMs for this reason.
The costs are:
- Each VM needs its own memory allocation for the guest kernel and page cache.
- You must build or choose a guest image and keep its kernel patched, in addition to the host.
- Sharing files with the host needs a mechanism such as a shared directory protocol or a block device, and each of those adds shared surface of its own.
- Hardware virtualization must be available. Running a microVM inside another cloud VM requires nested virtualization, which not every provider supports.
What a boundary does not decide
The kernel-sharing question tells you how hard an escape is. It does not tell you what the agent can do without escaping. Even in a VM, the agent can:
- Delete or corrupt every file you mounted in.
- Read any secret you placed inside.
- Send data out over any network you allowed.
- Consume all CPU and memory you allocated.
Those are controlled by filesystem scoping, credential handling, network policy, and resource limits. The boundary is one layer. Later chapters cover the others. Chapter planning should treat the choice of boundary and the configuration inside the boundary as two separate decisions.
A quick way to check what you share
Whatever boundary you use, you can inspect it from inside. The script below prints facts that show how much of the host the sandboxed process can see.
import os
import platform
from pathlib import Path
print("kernel:", platform.release())
print("uid/gid:", os.getuid(), os.getgid())
print("pid 1 command:", Path("/proc/1/cmdline").read_bytes().replace(b"\0", b" ").decode().strip())
print("docker socket present:", Path("/var/run/docker.sock").exists())
print("home entries:", sorted(p.name for p in Path.home().iterdir())[:10] if Path.home().exists() else "no home")Run it on the host and inside a container, for example with docker run --rm -v "$PWD":/w -w /w python:3.12-slim python check.py after saving it as check.py. In a container, PID 1 is the container's own entry process, not the host's init. Inside a gVisor container, the kernel string reports a gVisor-provided version rather than the host's. Inside a VM, it reports the guest kernel.
Exercise
A teammate says, "Our agent runs in a Docker container, so a kernel bug in the host cannot affect us." Explain why this is wrong, and name one boundary that would reduce that exposure and why.
Show answer
A container shares the host kernel, so every syscall the agent's code makes is handled by the same kernel code the host uses. A bug in a reachable syscall can let the code escape. A microVM or full VM gives the agent its own guest kernel, so the agent's syscalls hit the guest kernel and only the hypervisor and emulated devices are shared. gVisor also reduces the exposure, because it handles most syscalls in user space and passes only a small set to the host.
Exercise
You start a container with --privileged and mount /var/run/docker.sock. Which boundary properties from this chapter still hold?
Show answer
Almost none. Privileged mode removes most capability and device restrictions, and the Docker socket lets the agent launch new containers with the host root filesystem mounted. The container still has separate namespaces in name, but the agent can reach the host's resources, so it should be treated as having root on the host.
Exercise
Order these from smallest to largest shared surface with the host: a microVM, a plain process, gVisor, a standard Docker container.
Show answer
Smallest to largest: microVM, gVisor, standard Docker container, plain process. The microVM shares only the hypervisor and a few devices. gVisor shares a reduced set of host syscalls. A container shares the full host kernel interface behind filters. A plain process shares everything the user can access.