LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

How does membership in the docker group allow privilege escalation to root via a bind-mounted volume and a setuid binary?

A docker-group user can start a container that bind-mounts a host directory; because container processes run as root and the mount keeps host ownership, a setuid(0) binary written there becomes a root-owned setuid file the user can execute on the host.

The chain uses two facts established earlier: a docker group member can drive the root daemon without sudo, and container processes run as root by default.

  1. A small C program calls setuid(0) and then system(…), so running it gives a root shell. It is compiled on the host.
  2. The user starts a container that bind-mounts a host folder (--mount type=bind,src=$HOME/…/shared,dst=/shared). A bind mount shares the same files between host and container, keeping host ownership.
  3. Inside the container (running as root) a script copies the binary into the shared folder and sets its setuid bit. Because the container is root, the file ends up owned by root with setuid set — and because it is a bind mount, that is true on the host too.
  4. Back on the host, the ordinary user runs the setuid-root binary and gets a root shell — no sudo needed, able to read /etc/shadow.

The root cause: "docker group = root", plus containers defaulting to root, plus a bind mount that carries root ownership onto the host filesystem. Defences: don't put untrusted users in the docker group, run containers as a non-root user, and enable user namespaces so container-root maps to a harmless host UID.

docker-group user → root container writes a setuid binary onto a bind mount → host-owned setuid file → root shell on the host

* The bind mount carries root ownership back to the host. *

Go deeper:

From Quiz: ISLAB / Docker Security | Updated: Nov 26, 2026