flawopen.com/Reference/Docker Socket & Capability Escapes
Imagine renting out your guest bedroom to an unknown Airbnb guest. You lock the door to your private master bedroom and hide the keys. But on the guest room nightstand, you leave the master smart-home touchscreen that has full administrative power to unlock every door, turn off the security alarms, and format the house computer. In container security, mounting /var/run/docker.sock inside a container is the master touchscreen—it allows any process inside the container to command the host Docker daemon to give it root control over the physical server.
/var/run/docker.sock, running with --privilegedThe Docker Unix socket (/var/run/docker.sock) is the control interface for the Docker daemon. Giving a container read/write access to this socket gives it equivalent power to root on the host. Any process inside the container can issue HTTP API calls to the socket, commanding Docker to spawn a new container with the host root filesystem mounted at /host and chrooting into it.
# VULNERABLE: Mounting docker socket for CI/CD or monitoring container
docker run -d \
--name build-runner \
-v /var/run/docker.sock:/var/run/docker.sock \ # Instant host compromise!
ci-runner:latest
# Inside the container, any unprivileged user runs:
# curl --unix-socket /var/run/docker.sock http://localhost/containers/create \
# -d '{"Image":"alpine","Cmd":["chroot","/host","sh"],"Binds":["/:/host"]}'
# HARDENED: Run rootless, drop capabilities, and never expose host socket
docker run -d \
--name secure-app \
--user 10001:10001 \
--read-only \
--cap-drop=ALL \
--security-opt no-new-privileges:true \
--tmpfs /tmp:rw,noexec,nosuid,size=64M \
app-image:latest
/var/run/docker.sock.:docker run -v /:/host_root alpine chroot /host_root.--privileged flag disables all AppArmor, Seccomp, and namespace protections, enabling trivial device escapes.--cap-drop=ALL and selectively add back only the specific capabilities needed (e.g. CAP_NET_BIND_SERVICE).