Container escape to the host
A container that is over-privileged — a mounted Docker socket, host namespaces or dangerous capabilities — becomes a path out of the container and onto the node itself.
Scenario
An authorized assessment where you already have code execution inside a container (for example via an exploited app). The objective is to show whether the container's configuration allows escape to the underlying host.
- 1
Discovery
Inventory the container's privileges
Enumerate the container: capabilities, whether it is privileged, which host paths or sockets are mounted (notably the Docker socket), and shared host namespaces — these determine whether escape is even possible.
DetectionReads of capability/cgroup/mount information and probing of /var/run inside a container can be captured by runtime security tooling.
MitigationDrop all capabilities by default, never run privileged containers, and never mount the Docker socket into a workload.
- 2
Credential Access
Collect mounted secrets
Check mounted volumes, environment variables and service-account tokens reachable from the container for credentials that widen access, documenting each exposure.
DetectionAccess to token files and secret mounts from an unexpected process is visible to runtime monitoring.
MitigationMount only the secrets a workload needs, use short-lived tokens, and keep secrets out of environment variables.
References docker-security - 3
Privilege Escalation
Escape to the host
Where the configuration allows it — a mounted Docker socket, a privileged container, or dangerous capabilities — demonstrate breaking out to execute in the host context, reporting the specific misconfiguration that permitted it rather than a generic exploit.
DetectionA container process gaining host context, new host processes parented to the runtime, and socket-driven container creation are high-fidelity signals.
MitigationEnforce a restrictive seccomp/AppArmor profile, run as non-root with no-new-privileges, and use user namespaces so container root is not host root.
- 4
Discovery / Lateral Movement
Leverage the host
From the host, show what the node exposes — other containers, the orchestrator, and reachable networks — to map how a single workload compromise becomes node or cluster exposure, staying within scope.
DetectionDeploying new containers, and host-level network discovery, are strong post-escape signals in audit and runtime logs.
MitigationSegment nodes, restrict the orchestrator API, and apply least-privilege to the node's own identity.
Key takeaways
- Container escape is almost always a configuration gift — a mounted socket, privileged mode, or a dangerous capability.
- Non-root, no-new-privileges, dropped capabilities and user namespaces turn a breakout into a dead end.
- Treat the Docker socket as root on the host: never hand it to a workload.