Checks / Docker and containers

A container has dangerous capabilities

Check
docker.dangerous_caps
Severity
medium
Runs
on the server, in the daily run of the agent
Looks at
CapAdd contains SYS_ADMIN, NET_ADMIN, SYS_PTRACE, SYS_MODULE or ALL
Updated 26 Nov 2026

What the check looks at

HostConfig.CapAdd of every running container (docker inspect). The check fails for each container whose list contains SYS_ADMIN, NET_ADMIN, SYS_PTRACE, SYS_MODULE or ALL, with or without the CAP_ prefix that Docker stores (CAP_NET_ADMIN). The evidence line names the capabilities, for example CapAdd: NET_ADMIN. Privileged containers are reported by docker.privileged.

Risk

Docker starts containers with 14 capabilities. The ones this check looks for are not among them, and each gives a root process in the container more power:

Capability What it allows, from capabilities(7)
SYS_ADMIN "a range of system administration operations", mounts among them; the man page calls it "the new root"
SYS_MODULE "load and unload kernel modules"; the code of a module runs in the kernel of the host, outside any container
SYS_PTRACE tracing other processes; with --pid=host, the processes of the host
NET_ADMIN configuring interfaces, firewall rules and routes; with --network=host, those of the host
ALL every capability

How to fix it

  1. Find out which operation needs the capability. VPN containers usually need NET_ADMIN and the device /dev/net/tun; FUSE needs SYS_ADMIN and /dev/fuse; debuggers need SYS_PTRACE. A web application or a database needs none of them.

  2. Drop all capabilities and add back the ones the program needs:

    services:
      app:
        image: example/app:1.4.2
        cap_drop: [ALL]
        cap_add: [NET_BIND_SERVICE]
        security_opt:
          - no-new-privileges:true
    

    With docker run: --cap-drop ALL --cap-add NET_BIND_SERVICE --security-opt no-new-privileges.

  3. Recreate the container (docker compose up -d --force-recreate <service>) and test the program. If it fails with "Operation not permitted", add one capability at a time.

A container rarely needs SYS_MODULE. Load the kernel module on the host: for WireGuard, sudo modprobe wireguard, and on systemd hosts echo wireguard | sudo tee /etc/modules-load.d/wireguard.conf for every boot. Then drop the capability.

How to check the fix

docker ps -q | xargs -r docker inspect --format '{{.Name}} capadd={{.HostConfig.CapAdd}}'

The output must list none of the capabilities above, or only those you decided to keep.

When a warning is fine

NET_ADMIN for a VPN or router container on its own bridge network changes only the network of that container, and SYS_PTRACE in a debugging container that you remove after an hour is fine too. Accept such results on the dashboard with a note on why the container needs the capability. Look closely at SYS_MODULE and ALL every time.

An accepted result stays out of the digest and the counts until it changes.

Sources