Checks / Docker and containers
A container runs privileged
- Check
docker.privileged- Severity
- high
- Runs
- on the server, in the daily run of the agent
- Looks at
- HostConfig.Privileged is true
What the check looks at
The agent reads HostConfig.Privileged of every running container from docker inspect and reports each
container where it is true, with its name and image.
Why it matters
--privileged, or privileged: true in a compose file, removes most of the isolation between container and
host. In a test on Docker 29.9 with kernel 6.12, a privileged container had all 41 capabilities of the kernel
instead of 14, its seccomp filter was off, and /dev held 161 entries instead of 15, including the disks of
the host. The Docker documentation adds that the option "reconfigures AppArmor or SELinux to allow the
container nearly all the same access to the host".
With the disks and CAP_SYS_ADMIN, a root process in the container can mount the file system of the host and
change any file. A vulnerability in the application in that container is then a vulnerability of the whole
host.
How to fix it
The steps are the same on every distribution.
-
Find out what the container needs. Common cases and narrower options:
- a device such as
/dev/net/tun, a USB device or/dev/dri:--device /dev/net/tun(compose:devices: ["/dev/net/tun:/dev/net/tun"]); - network configuration inside the container, for a VPN:
--cap-add NET_ADMIN; - FUSE:
--cap-add SYS_ADMIN --device /dev/fuse.
- a device such as
-
Remove
privileged: true(or--privileged), add the narrower options, and recreate the container:docker compose up -d --force-recreate <service> -
If the program fails, its error message usually names the missing device or the operation that was denied. Add that one item and try again.
Docker in Docker (docker:dind) needs --privileged. For CI builds, a dedicated runner host keeps that risk
away from servers with production data.
How to check the fix
docker ps -q | xargs -r docker inspect --format '{{.Name}} privileged={{.HostConfig.Privileged}}' \
| grep 'privileged=true'
No output means that no running container is privileged.
When a warning is fine
Some software is built to manage the host and documents that it needs --privileged: hardware monitoring,
some storage and network tools, Docker in Docker on a dedicated CI host. If you trust the image and run it on
purpose, accept the result on the dashboard and keep the image pinned and updated. A web application or database never needs
it.
An accepted result is left out of the digest and the counts until it changes; then it shows again.