Container escape: breaking out to the host
Containers share the host kernel. Isolation comes from namespaces, cgroups and capabilities: weakening them opens the way to the host.
The escape routes
--privileged: near-total access to host devices; mount the host disk and read/write everything.
CAP_SYS_ADMIN or SYS_PTRACE capability: abuse cgroup release_agent, or inject into host processes.
hostPath / mounted sockets: a mount of / or the docker socket gives host control.
# classic cgroup v1 release_agent abuse (privileged container)
# writes a command the kernel runs on the hostDefence
Never --privileged. Drop all capabilities and add back the minimum. User namespaces (rootless), seccomp and AppArmor/SELinux profiles. No sensitive host mounts. gVisor/Kata for stronger isolation when needed.