Understanding Container Escape
Container escape occurs when an attacker breaks out of a container's isolation boundary to access the host system or other containers. While containers provide process and filesystem isolation, they share the host kernel, which makes escape possible through kernel vulnerabilities, misconfigurations, or deliberate weaknesses.
Common Escape Techniques
1. Mounted Docker Socket
The most common escape vector. If the Docker socket is mounted inside a container:
# Inside the container
docker -H unix:///var/run/docker.sock run -v /:/host -it ubuntu chroot /host
# Now you have root access to the host filesystem
Prevention: Never mount /var/run/docker.sock into application containers.
2. Privileged Containers
Containers running with --privileged have full access to host devices:
# Inside privileged container
mount /dev/sda1 /mnt
chroot /mnt
# Full host access
3. Kernel Exploits
Containers share the host kernel. A kernel vulnerability (e.g., CVE-2022-0185, CVE-2022-0847 "Dirty Pipe") can be exploited from inside a container to gain host access.
4. CAP_SYS_ADMIN Abuse
Containers with CAP_SYS_ADMIN can mount filesystems, use ptrace, and perform other privileged operations that enable escape.
5. cgroup Escape
Manipulating cgroup release_agent to execute commands on the host:
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp
echo 1 > /tmp/cgrp/notify_on_release
echo "#!/bin/sh" > /cmd
echo "cat /etc/shadow > /tmp/cgrp/output" >> /cmd
chmod +x /cmd
echo "/cmd" > /tmp/cgrp/release_agent
Prevention
- Drop all capabilities and add only what's needed
- Use read-only root filesystems
- Enable seccomp profiles to restrict syscalls
- Run as non-root inside containers
- Keep kernel updated to patch escape vulnerabilities
- Use gVisor or Kata Containers for stronger isolation
- Monitor with runtime security tools (Falco, Tetragon)
SuperClue Container Security
SuperClue does not audit container or pod configurations. Its SOC agent can run as a Docker container or a Kubernetes DaemonSet and monitors host processes, network connections, and file integrity, which helps you spot activity after an escape.