Containers isolate with namespaces and cgroups, not with the hardware-enforced boundary a virtual machine gets. That isolation is real but thin, and a container escape is what happens when a process crosses it to reach the host or a sibling container. Escapes come in two kinds: exploits of genuine kernel or runtime bugs, and abuse of configurations that were never isolating in the first place. In practice the second kind is the more common, and it is entirely on you.

The most dangerous line in any pod spec is privileged: true. A privileged container runs with all Linux capabilities, an unrestricted device list, and most kernel-enforced protections stripped away. It can access host devices under /dev, manipulate the host's cgroups and kernel modules, and mount filesystems. Reaching the host from a privileged container is intended behavior, misapplied, and needs no exploit. Some workloads legitimately need it (certain CNI and storage plugins); many workloads that request it do not need it.

The self-inflicted escapes

Privileged Containers and Container EscapesDiagram with these labels, in reading order: CONTAINER; CONFIG BOUNDARY; HOST; never a boundary; if enforced; Attacker with; code execution; privileged /; hostPath /; runtime socket; Break out; mount host, drive; daemon; Not enforced; PSA baseline; drop caps, seccomp; Root on the node; Sibling containers; & their secrets; These configs were; never isolation.CONTAINERCONFIG BOUNDARYHOSTnever a boundaryif enforcedAttacker withcode executionprivileged /hostPath /runtime socketBreak outmount host, drivedaemonNot enforcedPSA baselinedrop caps, seccompRoot on the nodeSibling containers& their secretsThese configs werenever isolation
Most escapes need no exploit, just a config that was never a boundary.
  • Mounting the host filesystem. A hostPath volume of /, or just /etc or the container runtime socket, hands the container the host's files to read and rewrite.
  • Mounting the Docker/CRI socket. /var/run/docker.sock inside a container lets it instruct the daemon to start a new privileged container mounting the host. It is root-on-host by API call.
  • Host namespaces. hostPID, hostNetwork, and hostIPC punch through the very isolation namespaces provide, exposing host processes and interfaces.
  • Dangerous capabilities. CAP_SYS_ADMIN is a near-superset of root; CAP_SYS_PTRACE, CAP_SYS_MODULE, and CAP_DAC_READ_SEARCH each enable well-documented breakout techniques.
Why it matters: Many container escapes come from configurations that were never a boundary and need no zero-day. privileged: true, a host mount, or a mounted runtime socket removes the wall and then acts surprised when someone walks through.

The exploit-driven escapes

The rarer, headline class exploits real flaws in the runtime or kernel. The 2019 runc vulnerability (CVE-2019-5736) let a malicious container overwrite the host's runc binary and gain root on the host. It needed a root command to run in a container from an attacker-controlled image, or an exec into a container the attacker could already write to. The 2022 cgroups v1 release_agent flaw (CVE-2022-0492) allowed breakout from containers that lacked protections such as seccomp, AppArmor or SELinux. In January 2024, CVE-2024-21626 showed runc leaking a file descriptor that gave a container process a working directory in the host filesystem (fixed in runc 1.1.12). Kernel bugs like Dirty Pipe (CVE-2022-0847) are shared by every container on the host because they all share one kernel. The defense against these is unglamorous: patch the runtime and the host kernel promptly, because a shared kernel means a shared exposure.

Building real containment

  • Ban privileged, host namespaces, and host mounts at admission. The Baseline and Restricted Pod Security Standards block these; enforce them.
  • Never mount the container runtime socket into a workload. If a pod needs to manage containers, that is an architecture to rethink, not a mount to grant.
  • Drop all capabilities and add back the few needed. Explicitly refuse CAP_SYS_ADMIN unless a workload cannot function without it, and then isolate that workload.
  • Apply seccomp and an LSM. The RuntimeDefault seccomp profile blocks obscure syscalls exploits rely on; AppArmor or SELinux adds mandatory access control on top.
  • Use user namespaces. Remapping container root to an unprivileged host UID means even 'root' in the container is an unprivileged user on the host. Kubernetes supports this with hostUsers: false, generally available since version 1.36.
  • For genuinely hostile multi-tenancy, add a sandbox. gVisor or Kata Containers interpose a user-space kernel or a lightweight VM, so a kernel exploit inside the container never reaches the real host kernel.
The pod spec that is one field away from owning the nodesecurityContext:
  privileged: true
volumes:
- name: host
  hostPath: { path: / }  # host root, writable, from inside the container

Defense in depth here is layered on purpose: admission control stops the dangerous spec, capability dropping and seccomp shrink the exploit surface, patching closes the known bugs, and sandboxing contains the unknown ones. But every layer assumes the workload is one you govern. A privileged container running on a node nobody is watching is the escape you will read about in someone else's incident report. You can't contain what you haven't discovered.

Back to the knowledge baseRequest an assessment