Docker Container Escape Hardening Checklist (2026)
A practical checklist to stop container escapes: remove --privileged and CAP_SYS_ADMIN, keep seccomp and AppArmor on, run rootless or with user namespaces, use read-only root filesystems and distroless images, audit Docker socket exposure, and patch the shared host kernel, with lessons from Infinity Core, LXD, Docker Sandboxes and the backdoored ARTEX image.
// key takeaways
- Containers share the host kernel. The Infinity Core kernel bugs disclosed on October 16, 2026 came with public root exploits that the researcher says also allow container escape, so kernel patching is part of container hardening.
- --privileged removes almost every isolation layer at once: all capabilities, all host devices, and no seccomp or AppArmor confinement. Treat any privileged container as host root.
- A mounted /var/run/docker.sock is root on the host. Anyone who can talk to the Docker API can start a privileged container that mounts the host filesystem.
- Defaults matter: drop all capabilities, keep the default seccomp and AppArmor profiles, set no-new-privileges, run as a non-root UID, and use a read-only root filesystem.
- The boundary includes host-side tooling and images. Docker Sandboxes before 0.50.0 could run attacker-controlled Git config on the host, and the tomicdd/artex image shipped a hidden root shell.
What a container escape actually is
A Linux container is a normal process that the kernel isolates with namespaces (PID, mount, network, user, IPC, UTS), cgroups for resource limits, Linux capabilities that split root's powers into pieces, a seccomp filter that restricts which system calls it may make, and a mandatory access control profile from AppArmor or SELinux. There is no separate kernel. An escape means code in the container gains the ability to act on the host: read or write host files, control other containers, or run as host root.
Escapes come from three places. Configuration that removes isolation layers (privileged mode, broad capabilities, host namespaces, sensitive host mounts). Bugs in the shared kernel or in the runtime and tools around the container. And trusted inputs that are not trustworthy, such as images from an unknown publisher or files the container wrote that host-side tools later process. Hardening has to cover all three.
- Configuration: --privileged, --cap-add SYS_ADMIN, --pid=host, --net=host, hostPath and docker.sock mounts.
- Kernel and runtime: local privilege escalation bugs reachable from inside the container's seccomp profile.
- Supply chain and host tooling: backdoored images, crafted image archives, and host processes that trust container output.
Remove --privileged and CAP_SYS_ADMIN first
Docker's documentation is explicit about privileged mode: it grants all capabilities, lifts the device cgroup restrictions so the container sees host devices, and disables the default seccomp and AppArmor confinement. A process that is root inside a privileged container can mount the host's block devices or load kernel modules. There is no partial version of this risk; a privileged container is equivalent to root on the node.
CAP_SYS_ADMIN is the next worst thing. It covers mount operations, namespace manipulation and many administrative interfaces, and well-known escape techniques depend on it. Most application containers need no capabilities at all. Start from --cap-drop ALL and add back only what a measured need requires, typically NET_BIND_SERVICE for binding a port below 1024, which you can often avoid by listening on a high port.
Also look for the host namespace flags. --pid=host lets the container see and signal host processes, --net=host puts it on the host network stack including services bound to localhost, and --ipc=host shares host shared memory. Each is occasionally needed for monitoring agents; none belongs on an application workload.
- Search compose files, Helm charts and CI scripts for privileged: true, --privileged, SYS_ADMIN, hostPID, hostNetwork and hostIPC.
- Run with --cap-drop ALL and an explicit, reviewed --cap-add list.
- Set --security-opt no-new-privileges:true so setuid binaries cannot raise privileges inside the container.
- Give monitoring agents that need host access their own nodes or a documented exception, not a blanket pattern.
# Privileged flag, added capabilities, and host namespaces for every running container
docker ps -q | xargs docker inspect --format \
'{{.Name}} privileged={{.HostConfig.Privileged}} capadd={{.HostConfig.CapAdd}} pid={{.HostConfig.PidMode}} net={{.HostConfig.NetworkMode}} secopt={{.HostConfig.SecurityOpt}}'
# A hardened baseline for an application container
docker run -d --name api \
--cap-drop ALL \
--security-opt no-new-privileges:true \
--user 10001:10001 \
--read-only --tmpfs /tmp:rw,noexec,nosuid,size=64m \
--pids-limit 256 --memory 512m \
registry.example.com/api@sha256:<digest>Keep seccomp and AppArmor or SELinux on
Docker applies a default seccomp profile that blocks system calls most containers never need, including kernel keyring calls such as keyctl and add_key, kexec_load, and calls that are only allowed when the container holds a matching capability such as mount and unshare. Many kernel exploits rely on a syscall that this profile blocks, which is why seccomp=unconfined in a compose file deserves the same scrutiny as privileged mode.
On Ubuntu and Debian hosts Docker loads the docker-default AppArmor profile; on Fedora and RHEL hosts containers run under an SELinux container type. Both restrict writes to sensitive /proc and /sys paths and mount behaviour. Check that the host actually has the LSM enabled, because a container launched on a host without AppArmor silently runs without the profile.
In Kubernetes, the kubelet does not apply the runtime's default seccomp profile unless you ask for it. Set seccompProfile type RuntimeDefault in the pod or container securityContext, or enforce the restricted Pod Security Standard on the namespace, which requires it.
- Reject seccomp=unconfined and apparmor=unconfined in review unless a security owner signs off.
- Verify the host LSM: aa-status on AppArmor hosts, getenforce on SELinux hosts.
- Set seccompProfile: RuntimeDefault on every Kubernetes workload, or enforce the restricted Pod Security Standard.
- For untrusted code, add a stronger boundary such as gVisor or Kata Containers instead of relying on a syscall filter alone.
# Enforce the restricted profile on a namespace
apiVersion: v1
kind: Namespace
metadata:
name: payments
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/warn: restricted
---
# Container securityContext that passes the restricted profile
securityContext:
runAsNonRoot: true
runAsUser: 10001
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefaultRun as non-root, rootless, or with user namespaces
If a process escapes as UID 0 and that UID maps to host root, the escape is a full host compromise. Three controls change that mapping. Set a non-root USER in the Dockerfile and run with --user so the application never holds root inside the container. Enable user namespace remapping in the daemon ("userns-remap": "default" in /etc/docker/daemon.json) so container root maps to an unprivileged range of host UIDs. Or run the whole daemon rootless with dockerd-rootless-setuptool.sh, so even the Docker daemon has no host root.
Each has trade-offs. User namespace remapping changes file ownership on volumes and is incompatible with some host-namespace flags. Rootless mode limits some networking and storage drivers. Running the application as a non-root UID is cheap and almost always possible; do that everywhere, then pick userns-remap or rootless for hosts that run less trusted workloads.
- Add USER 10001 (or the distroless nonroot user) to every application Dockerfile.
- Turn on userns-remap or rootless Docker on build hosts, CI runners and shared developer machines.
- Check file ownership of mounted volumes after enabling remapping; fix them deliberately rather than reverting to root.
Read-only root filesystems and distroless images
An attacker who lands in a container usually wants to download tools, write a payload and make it executable. A read-only root filesystem (--read-only in Docker, readOnlyRootFilesystem: true in Kubernetes) removes the easy places to do that. Mount a small tmpfs for /tmp with noexec and nosuid, and put real state on named volumes.
Distroless images, such as gcr.io/distroless/static-debian12 for static Go binaries, ship the application and its runtime dependencies without a shell or package manager. That does not stop an exploit, but it removes the shell, curl and apt that most post-exploitation scripts assume. The :nonroot tags also default to an unprivileged user. Fewer packages also means fewer CVEs in your scanner output, which keeps real findings visible.
- Use multi-stage builds so compilers and build tools never reach the runtime image.
- Pin base and application images by digest (image@sha256:...) rather than mutable tags.
- Mount tmpfs with noexec,nosuid and a size limit for scratch space.
- Generate an SBOM per image so you can answer which images contain a vulnerable package.
Audit Docker socket and daemon API exposure
The Docker daemon runs as root and its API can create containers with any configuration. Bind-mounting /var/run/docker.sock into a container hands that container the same power: it can start a new privileged container with the host root filesystem mounted and chroot into it. CI runners, reverse proxies that discover containers, and dashboard tools often request the socket. Treat each of those as host-root software.
The same applies to the network API. A daemon listening on TCP 2375 has no authentication and no TLS; anyone who can reach it controls the host. If remote access is required, use TLS client certificates on 2376 or SSH (DOCKER_HOST=ssh://user@host), and firewall the port to known administrators. Members of the docker group can also use the socket without sudo, so that group membership is effectively root.
- Find every container with docker.sock mounted and record why it needs it.
- Replace socket access with a filtering socket proxy that only allows read-only endpoints where possible.
- Check that dockerd is not listening on 0.0.0.0:2375; require TLS client auth or SSH for remote use.
- Review who is in the docker group on every host and treat additions like sudo grants.
# Containers that mount the Docker socket
docker ps -q | xargs docker inspect \
--format '{{.Name}}{{range .Mounts}} {{.Source}}{{end}}' | grep docker.sock
# Is dockerd listening on TCP?
ss -ltnp | grep -E ':(2375|2376)\b'
# Who can use the socket without sudo?
getent group dockerPatch the shared kernel and the tools around the container
Every container on a node shares one kernel, so a kernel local privilege escalation is a container escape candidate. On October 16, 2026 researcher Hyunwoo Kim published Infinity Core: six Linux kernel bugs in the timer, signal, memory management, futex, scheduler and SLAB code, five with public exploits from an unprivileged user to root, which the researcher says also allow container escape, and none needing an unprivileged user namespace. Fixed stable kernels include 6.6.158, 6.12.112, 6.18.54 and 7.2.9. Separately, CISA added the Fragnesia kernel privilege escalation to its Known Exploited Vulnerabilities catalog on October 28, 2026 after it was chained in real attacks; fixed stable lines include 5.15.208, 6.1.174, 6.6.141, 6.12.91, 6.18.33 and 7.0.10. Installing the kernel package is not enough: nodes must reboot into it.
System container managers have their own escape surface. On November 6, 2026 Canonical published a wave of critical LXD advisories for host escapes through malicious images, backup compression arguments and project-restriction bypasses. The lesson is to import images only from trusted sources and upgrade LXD to builds that include those fixes; for the snapshot restriction bypass that means 6.9, 5.21.5 or 5.0.7.
Host-side tools that act on container output are part of the boundary too. Docker Sandboxes from 0.31.0 before 0.50.0 ran host Git commands that honoured repository-controlled Git config, so a sandbox with a read-write repository mount could set core.fsmonitor and later run a program on the host outside the microVM. Upgrade to 0.50.0 or later, and avoid read-write mounts of untrusted repositories into any sandbox.
- Track running kernel versions per node (uname -r) against the fixed stable releases and reboot after updates.
- Drain and replace nodes on a schedule so kernel fixes actually land in Kubernetes clusters.
- Upgrade LXD and Docker Sandboxes to the fixed builds; import system container images only from trusted remotes.
- Treat files written by a container as untrusted input for any host process that later reads or executes them.
Image provenance: the escape you pull yourself
You do not need an escape if the image already runs the attacker's code with host-level access. After the ARTEX AI penetration-testing console's original repository was taken down on October 8, 2026, a copycat repository changed its docker-compose.yml to pull a Docker Hub image, tomicdd/artex. BadByte found that the image's binary added a hidden login check that ran input through sh -c as root before any credential check. The image had 7,946 pulls by November 3, 2026, and congdonglinux/artex was a byte-identical re-push. There was no fix: anyone who ran it was told to treat the host as compromised and rebuild from reviewed source.
Pull images from publishers you can identify, pin them by digest, and build from source for anything security-sensitive. Verify signatures where publishers provide them, scan images before admission, and restrict which registries a cluster may pull from with an admission policy.
- Allow-list registries and namespaces at admission time.
- Pin by digest and record the digest in the deployment manifest.
- Verify image signatures where the publisher signs releases.
- Never run a third-party image with --privileged or the Docker socket just because its README says so.
// actionable engineering checklist
No privileged containers
Zero --privileged or privileged: true outside documented node-agent exceptions.
Capabilities dropped
--cap-drop ALL with a reviewed add list; no SYS_ADMIN on application workloads.
seccomp and LSM enforced
Default seccomp and AppArmor/SELinux on; RuntimeDefault set in Kubernetes; no unconfined overrides.
Non-root everywhere
USER set in every Dockerfile, no-new-privileges on, userns-remap or rootless on shared and CI hosts.
Read-only and minimal images
Read-only root filesystem, tmpfs scratch with noexec, distroless or minimal bases pinned by digest.
Socket and API locked down
Every docker.sock mount justified, no plain TCP 2375, docker group membership reviewed.
Kernel patched and rebooted
Running kernels at or above the Infinity Core and Fragnesia fixed stable releases for their line.
Runtime tools current
Docker Sandboxes 0.50.0+ and LXD builds with the November 6, 2026 advisory fixes.
// connected pwn.watch tools & live trackers
SBOM Viewer →
Open an image SBOM to see which base packages and versions ship in each container.
chmod Calculator →
Check permissions on docker.sock, daemon TLS keys and files mounted into containers.
Hash Generator →
Compute SHA-256 digests to compare downloaded artifacts against published checksums.
CVSS v3.1 & v4.0 Calculator →
Re-score kernel and runtime bugs for your environment, for example a local-only bug on a single-tenant node.
Stack & Tag CVE Trackers
Security Hubs & Feeds
Related Incidents
- Infinity Core: six Linux kernel bugs with public root exploits and container escapes →
- Linux kernel Fragnesia root exploit added to CISA KEV →
- LXD host escapes via malicious images and project-restriction bypasses →
- Docker Sandboxes escape via poisoned Git config, fixed in 0.50.0 →
- Backdoored ARTEX Docker image gives an unauthenticated root shell →
Frequently Asked Questions
- Is a container a security boundary?
- It is a useful one, but it shares the host kernel. With dropped capabilities, seccomp, an LSM profile, a non-root user and a patched kernel it stops most attacks. For code you do not trust at all, add a stronger isolation layer such as gVisor, Kata Containers or a separate VM.
- Why is mounting /var/run/docker.sock dangerous?
- The socket is the Docker API, and the daemon runs as root. Anything that can call it can start a privileged container with the host filesystem mounted, which is root on the host.
- Does rootless Docker prevent container escapes?
- It limits the impact. If a process escapes, it lands as the unprivileged user that runs the rootless daemon instead of host root. Kernel bugs can still be exploited for local privilege escalation, so keep patching.
- Do I need to reboot after a kernel security update?
- Yes. Containers use the running kernel. Until the node boots into the fixed kernel, every container on it is still exposed to the old bug unless your distribution supports live patching for that fix.
Get an email when a new major security incident drops. No spam, unsubscribe any time.