Container escape: when Docker becomes the vulnerability
, 4 min read
A container isn't a small virtual machine. It's an ordinary Linux process that namespaces, cgroups, capabilities and seccomp restrict to a narrower view of the system. Every container on a host shares that host's kernel. An escape means getting from that narrower view to the host itself.
Escapes fall into two groups. Configuration escapes are settings that hand the container more than it needs. Vulnerability escapes are bugs in the container runtime or the kernel. The first group is entirely in your control, so start there.
Configuration escape 1: privileged containers
docker run --privileged, or privileged: true in a pod spec, turns off most of the isolation. The container gets every capability, sees the host's devices and has no seccomp filter. From inside, mounting the host's disk and changing into it is a few commands. There's no exploit involved.
Prevention: don't run privileged containers for applications. In Kubernetes, the baseline Pod Security Standard already rejects them.
Configuration escape 2: the Docker socket
Mounting /var/run/docker.sock into a container gives that container full control of the Docker daemon. The daemon runs as root and can start new containers with any settings, including one that bind-mounts the host's root filesystem. Docker's own security documentation says only trusted users should be allowed to control the daemon for this reason. Socket access is host root in all but name.
Prevention: don't mount the socket into workloads. If a CI job or tool truly needs to build images, use a rootless builder, or a socket proxy that allows only the API calls the tool needs.
Configuration escape 3: dangerous capabilities
Capabilities split root's powers into pieces. A few pieces are nearly the whole thing:
- `CAP_SYS_ADMIN` covers mounting file systems and many other administrative operations. The classic cgroup v1
release_agentescape needs it. That technique makes the host run a program when a cgroup empties. - `CAP_SYS_PTRACE`, combined with the host's process namespace, lets a container attach to host processes.
- `CAP_SYS_MODULE` loads kernel modules, which means running code in the host kernel.
Prevention: drop everything and add back only what a workload proves it needs:
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"] # only if it binds a port below 1024
seccompProfile:
type: RuntimeDefaultConfiguration escape 4: sensitive host paths
A hostPath mount of /, /etc, /root, /var/lib/kubelet or the container runtime's state directory gives write access to files the host trusts. A new user in /etc/passwd, a key in /root/.ssh/authorized_keys or a cron entry is an escape with no exploit.
Prevention: avoid hostPath for applications. The baseline Pod Security Standard blocks it. Where an agent really needs a host path, mount the narrowest directory read-only.
Vulnerability escapes: runtime and kernel bugs
When the configuration is tight, escapes need a bug. Some notable ones:
| CVE | Component | What it allowed | Fixed in |
|---|---|---|---|
| CVE-2019-5736 | runc | A malicious container overwrote the host's runc binary through /proc/self/exe, giving root on the host | runc after 1.0-rc6; Docker 18.09.2 |
| CVE-2022-0185 | Linux kernel | Heap overflow in file-system context parsing. With unprivileged user namespaces, a local user could escalate privileges | Distribution kernel updates |
| CVE-2022-0492 | Linux kernel | Missing check in cgroup v1 release_agent let a process bypass namespace isolation | Distribution kernel updates |
| CVE-2024-21626 | runc | A leaked file descriptor could leave a new container process with a working directory on the host file system | runc 1.1.12 |
| CVE-2025-31133, CVE-2025-52565, CVE-2025-52881 | runc | Tricks with mount targets, symlinks and /proc writes during container setup could lead to escape | runc 1.2.8, 1.3.3, 1.4.0-rc.3 |
The pattern: the runtime runs as root on the host while it sets up the container. Any confusion about which file it's touching during that window becomes host access. Keep runc (and containerd or Docker, which bundle it) patched on the same schedule as the kernel.
Prevention for this group:
- Patch host kernels and runtimes promptly. For managed Kubernetes, that means keeping node images current.
- Keep the default seccomp profile (
RuntimeDefault) on. Docker's default profile blocks dozens of system calls that ordinary containers don't need, which shrinks the kernel surface an exploit can reach. - For untrusted or multi-tenant workloads, use a sandboxed runtime such as gVisor, which puts a user-space kernel in front of the host kernel, or Kata Containers, which runs each pod in a lightweight VM.
- Rootless containers and user namespaces map container root to an unprivileged host user, so a successful escape lands with far less power.
Checks to run today
# Privileged containers on this Docker host
docker ps -q | xargs docker inspect --format '{{.Name}} privileged={{.HostConfig.Privileged}}'
# Containers with the Docker socket mounted
docker ps -q | xargs docker inspect --format '{{.Name}} {{range .Mounts}}{{.Source}} {{end}}' | grep docker.sock
# Pods in a cluster that run privileged
kubectl get pods -A -o json | jq -r '.items[]
| select(any(.spec.containers[]; .securityContext.privileged == true))
| "\(.metadata.namespace)/\(.metadata.name)"'Sources
- Docker docs — Docker Engine security (daemon attack surface)
- Kubernetes docs — Pod Security Standards
- NVD — CVE-2019-5736
- NVD — CVE-2022-0185
- NVD — CVE-2022-0492
- NVD — CVE-2024-21626
- runc security advisory GHSA-cgrx-mc8f-2prm (CVE-2025-31133, CVE-2025-52565, CVE-2025-52881)
- Docker docs — Seccomp security profiles
- gVisor documentation
- Kata Containers