CVE explainer

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_agent escape 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: RuntimeDefault

Configuration 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:

CVEComponentWhat it allowedFixed in
CVE-2019-5736runcA malicious container overwrote the host's runc binary through /proc/self/exe, giving root on the hostrunc after 1.0-rc6; Docker 18.09.2
CVE-2022-0185Linux kernelHeap overflow in file-system context parsing. With unprivileged user namespaces, a local user could escalate privilegesDistribution kernel updates
CVE-2022-0492Linux kernelMissing check in cgroup v1 release_agent let a process bypass namespace isolationDistribution kernel updates
CVE-2024-21626runcA leaked file descriptor could leave a new container process with a working directory on the host file systemrunc 1.1.12
CVE-2025-31133, CVE-2025-52565, CVE-2025-52881runcTricks with mount targets, symlinks and /proc writes during container setup could lead to escaperunc 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

Start with a $500 audit.

See exactly where you stand. Actionable findings in a week.

The full report and debrief call. Delivery in 5–7 business days.