NewThe Mac app is out for Apple SiliconGet it →
Fenzi
blog, safety

What is a container escape?

A container escape is code running inside a container reaching the host machine it runs on: the host's files, its other processes, or root on it. Most escapes need no exploit at all, only a setting that hands the host over, such as privileged mode, a mounted Docker socket or a host folder shared in. The rest are bugs in the container runtime or in the kernel the container shares with the host, which is why AI agents that run code nobody reviewed get extra layers on top.

By Boris Kwemo, , seven-minute read

A container is the boundary most people reach for when they let an AI coding agent run commands on its own. Anthropic documents a dev container for Claude Code for that purpose. This post explains what a container escape is, the two kinds, the advisories behind the recent ones, and how to check the container your agent runs in today, from Docker's and runc's own docs.

What a container is, and what leaving it means

Docker's Engine security page describes a container as a set of kernel namespaces and control groups. Namespaces decide what a process can see: its own process tree, its own network stack, its own view of the filesystem. Control groups decide how much memory and CPU it can use.

What a container does not get is its own kernel. Every system call goes to the same Linux kernel that runs the host. An escape is any path from inside that view to the host itself: writing a host file, signalling a host process, or getting a root shell on the machine.

An escape is not the same as data leaving over the network. A container that holds perfectly can still send your files to any host it can reach; that is a question for an egress proxy, and it comes back at the end of this post.

Escapes that need no bug

The most common way out is a flag someone added to make something work. Each of these hands the host to whatever runs inside, by design:

SettingWhat it hands over
--privilegedAll kernel capabilities, all host devices, a writable /sys, and no seccomp, AppArmor or SELinux profile
-v /var/run/docker.sock:/var/run/docker.sockThe Docker daemon, which can start a new container with the host's root folder mounted
-v ~:/home/agent or -v /:/hostThose host folders, read and written directly
--cap-add SYS_ADMIN and friendsMount and other root powers Docker drops by default
--pid=hostA view of every process on the host

Docker's docker run reference is blunt about the first row:

A container with --privileged is not a securely sandboxed process.Docker, docker container run

The socket is the one agents meet most. An agent that builds images or runs tests in containers wants Docker, and the quick way to give it Docker is to mount the host's socket. Docker's security page explains what follows: whoever controls the daemon can start a container whose /host is the host's /, and alter the host's files "without any restriction".

Escapes that need a bug

The second kind starts from a well-configured container and uses a flaw in the code that runs it. There are two places to look.

The container runtime. runc is the low-level program that starts containers for engines such as containerd, CRI-O and Podman, and its security advisories list several escapes. In January 2024, CVE-2024-21626 let a leaked file descriptor give a new process a working directory on the host; the advisory says all four of its attacks "can lead to full control of the host system." In November 2025 runc published three more high-severity escapes, and CVE-2025-31133 says it was verified with a standard Dockerfile under docker buildx build.

The latest, published on 12 November 2026 as GHSA-g2c3-j8g3-7gpw, lets a malicious image get a host folder mounted read-write, but only when an operator checkpoints and restores the container. Each was fixed in a runc release, so the fix is an update.

The kernel. Because the kernel is shared, a kernel bug reachable from inside is a way out. Docker's seccomp page says its default profile disables around 44 system calls out of more than 300, and lists the io_uring calls as blocked "due to security vulnerabilities that can be exploited to break out of containers."

Why AI coding agents raise the stakes

A web server in a container runs code you wrote and reviewed. An agent runs whatever its last few inputs suggested: a test script, a package's install step, a command from a README. Text the agent reads can steer it, which is the first item in our list of AI agent security risks and the subject of our prompt injection examples.

Anthropic's secure deployment guide spells out the consequence: if an agent runs malicious code, perhaps because of prompt injection, that code runs in the container "and could attempt kernel exploits." The agent does not need to mean harm. It only needs to run what it was handed.

Agents also tempt the people who set them up. When the agent cannot build an image, mounting the socket fixes it. When it cannot find a config file, mounting the home folder fixes it. Each fix is one of the rows in the table above.

"The agent runs in a container, so the host is safe."

Revision 1: the container keeps its processes apart from yours. What you mount, the socket you share and the kernel you both run decide whether that holds.

How to check the container your agent runs in

From the host, look at how the container was started. From inside, look at what the agent's process actually holds:

# on the host
docker inspect my-agent | grep -E '"Privileged"|"CapAdd"|"PidMode"|"Source"'

# inside the container
id -u                          # 0 means the agent runs as root
ls -l /var/run/docker.sock     # should not exist
grep -E 'CapEff|NoNewPrivs|Seccomp' /proc/self/status

You want Privileged false, no added capabilities, no host PidMode, and no mount Source outside the project. Inside, the kernel's proc documentation names the fields: CapEff is the effective capabilities, ideally all zeros for a non-root agent, and NoNewPrivs should be 1. A Seccomp value of 2 means a filter is loaded; 0 means seccomp is not in use.

Then check the version of runc, or of the engine that bundles it, against the advisories above. The fixed releases are listed on each one.

How to make an escape harder

Anthropic's secure deployment guide gives a hardened docker run for agents. Its core lines:

docker run \
  --cap-drop ALL \
  --security-opt no-new-privileges \
  --read-only \
  --user 1000:1000 \
  --network none \
  -v /path/to/code:/workspace:ro \
  agent-image

It also passes a seccomp profile, noting that Docker's default blocks about 44 calls and a custom one can block more, and it warns against mounting ~/.ssh, ~/.aws or ~/.config. With --network none, the guide routes the agent's traffic through a proxy on the host over a mounted Unix socket, a proxy socket and not Docker's.

Take root away on the host too. Docker's user namespace remapping maps root in the container to an unprivileged host user, and the Engine security page notes it is "not enabled by default". Rootless mode goes further and runs the daemon itself without root. runc's 2025 advisory recommends user namespaces as the step that blocks most of the serious parts of those attacks.

Give the agent its own kernel. gVisor answers system calls in user space before they reach the host kernel, and a microVM gives the agent a kernel of its own. Anthropic's sandbox environments page recommends a dedicated VM when your policy requires kernel-level separation between the agent and the host.

What a container that holds still leaves open

A container nobody can escape still gives the agent everything inside it. Anthropic's development containers page warns that with permissions skipped, a dev container does not prevent a malicious project from exfiltrating anything accessible inside it, including Claude Code's own credentials in ~/.claude.

So three questions remain after the escape question: which folders are mounted and whether they are writable, which secrets are in the environment, and which hosts the container can reach. Those are the questions behind what agentic AI security means to us: directories, hosts, keys, and a person who approves more.

A side note on how we do it

We build Fenzi, which starts the agent in an OpenShell sandbox as a non-root user with its capabilities cleared, a seccomp filter, Landlock on its folders, and a copy of the project in place of your home folder. The security model sheet lists what each layer stops; a hardened container with a proxy, gVisor or a microVM can answer the same questions.

So, should you worry about container escapes?

Worry first about the escapes you can see in a docker inspect: privileged mode, the Docker socket, host folders and added capabilities hand over the host without any bug. Then keep runc and the kernel patched, run the agent as a non-root user with user namespaces, and move to gVisor or a VM when the code it runs is untrusted or the machine is shared. Anthropic's secure deployment guide is the best next read: it puts containers, gVisor and VMs side by side with the network setup each one needs.

One line to install.
One command to run.

curl -fsSL https://fenzi.dev/install.sh | sh

Then fenzi run claude. Ask it to open a pull request with the GitHub API, and watch the deny land.