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

The agent reads HostConfig.CapAdd of every running container from docker inspect and reports the container when the list contains SYS_ADMIN, NET_ADMIN, SYS_PTRACE, SYS_MODULE or ALL (Docker stores them with a CAP_ prefix, such as CAP_NET_ADMIN). The evidence line names the container and the capabilities. Privileged containers are reported by docker.privileged.

Why it matters

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. From the capabilities(7) man page:

  • SYS_ADMIN covers "a range of system administration operations", including mounts. The man page calls it "the new root".
  • SYS_MODULE can "load and unload kernel modules". Code in a kernel module runs in the kernel of the host, outside any container.
  • SYS_PTRACE can trace other processes. With --pid=host that includes the processes of the host.
  • NET_ADMIN configures interfaces, firewall rules and routes. With --network=host these are the ones of the host.
  • ALL gives every capability.

How to fix it

The commands are the same on every distribution.

  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 database needs none of them.

  2. Drop all capabilities and add back only the needed ones:

    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.

SYS_MODULE in a container is rarely needed. Load the kernel module on the host instead, for WireGuard with 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 should 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 affects only the network of that container. SYS_PTRACE in a debugging container you start for an hour is fine if you remove it afterwards. Accept such results on the dashboard, with a note on why the container needs the capability. SYS_MODULE and ALL deserve a closer look every time.

An accepted result is left out of the digest and the counts until it changes; then it shows again.

Sources