Run through as_root, the check executes find /var/lib/docker/volumes -mindepth 2 -maxdepth 2 -type d -perm -0002 and counts the directories it returns. Pinning both -mindepth and -maxdepth to 2 holds the scan to exactly one level, each volume's own _data directory, and -perm -0002 is the test for the world-write bit. A single match is enough for a FAIL, which quotes the first three paths; no match at all is the PASS. The result list is capped with head -10 before it is counted, so on a badly affected host the reported number is a floor rather than a total.
Needs root or sudo - without it the check SKIPs before doing anything - and needs /var/lib/docker/volumes to exist. A host using a custom data-root, a rootless daemon (volumes live under ~/.local/share/docker), or no Docker at all therefore SKIPs, which is not a pass. The scan is narrow by design: -mindepth 2 -maxdepth 2 -type d -perm -0002 matches each volume's _data directory itself, not the files inside it, and at most 10 are reported. A volume whose _data is correctly 755 but full of world-writable files passes.
| Result | When | What it means |
|---|---|---|
| SKIP | No root, or /var/lib/docker/volumes absent (different data-root, rootless, or no Docker) | Nothing was verified. No directory was scanned, so world-writable volume data may exist and go unreported. |
| PASS | None world-writable | No volume's _data directory carries the world-write bit. The files inside those directories were not examined. |
| FAIL | One or more _data dirs are o+w | At least one volume's data directory can be written by any local account, or by another container sharing that UID space. Up to three paths are named. |
Volume data lives on the host filesystem. A world-writable _data lets any local user (or a different container with the same UID space) plant or modify files that another container will execute or trust. Least privilege on data directories; CIS Docker 1.2.x host configuration and 5.x volume guidance.
- Images that
chmod 777their data dir in the Dockerfile (VOLUME+chmod 1777), or operators who ranchmod -R 777to "fix permissions" instead ofchowning to the container UID. - Only the volume root directory is checked, not files beneath it.
- On a default install
/var/lib/dockeris710 root:root, which keeps non-root local accounts away from every volume, so host-side exposure also needs that parent loosened (achmod -Rover/var/lib/dockerdoes both at once). Cross-container and in-container escalation apply either way. - Custom
data-rootin daemon.json → SKIP. Adjust the path.
Find the container and the UID it writes as
The directory name under
volumes/is the volume name.docker topshows the UID the container's process really runs as, which matters for images that start as root and drop privileges in their entrypoint.sh docker volume inspect <vol> --format '{{.Mountpoint}}'docker ps -a --filter volume=<vol> --format '{{.Names}}'docker top <container> -eo uid,gid,commGive the data directory to that UID
sh sudo chown -R <uid>:<gid> /var/lib/docker/volumes/<vol>/_dataClear the world-write bit
sh sudo chmod o-w /var/lib/docker/volumes/<vol>/_datadocker restart <container>docker logs --tail 50 <container>A "Permission denied" in the logs means the UID from the first step was not the one writing; check it again rather than putting the bit back.
Remove the cause
Delete the
chmod 777orchmod -R 777from the Dockerfile, entrypoint or deploy script. Set ownership in the image instead, withCOPY --chownorRUN chownon the directory before itsVOLUMEline: a new named volume copies that directory's owner and mode the first time it is mounted.
# Reproduce the check:sudo find /var/lib/docker/volumes -mindepth 2 -maxdepth 2 -type d -perm -0002# expected: no output# Go one level deeper than the check does, into the contents:sudo find /var/lib/docker/volumes -xdev -perm -0002 ! -type l | head -20# Confirm where volumes actually live on this host:docker info --format '{{.DockerRootDir}}'- Re-run the audit as root or with sudo; there is no unprivileged fallback. Membership of the
dockergroup is not enough here: it reaches the daemon, not this directory. - Check
docker info --format '{{.DockerRootDir}}'. A customdata-rootindaemon.json, a rootless daemon storing volumes under$HOME/.local/share/docker, oruserns-remap(volumes under/var/lib/docker/<uid>.<gid>/volumes) puts them somewhere this check never looks. Run thefindabove against the real path. - Map the volume name to its users:
docker volume ls, thendocker ps -a --filter volume=<name>. The directory name undervolumes/is the volume name. - The container was relying on world-write because its process UID does not own the data. Fix it properly with ownership:
sudo chown -R <uid>:<gid> /var/lib/docker/volumes/<name>/_data, matching the UID the container's process runs as.docker top <name> -eo uid,gid,commshows it;docker inspect -f '{{.Config.User}}'is empty for images that start as root and drop privileges in their entrypoint, such as postgres and redis. - Only the
_datadirectory itself is tested, not its contents. Use the deeperfindabove. - Safe for ownership and permissions, but do not add or remove files there by hand; use
docker run --rm -v <name>:/mnt alpine …so the daemon's view stays consistent.
