Skip to content

CL-0024: cap_add ALL, SYS_ADMIN, SYS_MODULE, SYS_RAWIO

Severity: CRITICAL (how it is derived)

The service adds ALL, SYS_ADMIN, SYS_MODULE or SYS_RAWIO, each of which hands a compromised container a route to code execution on the host. Remove it; there is no safe subset to keep.

Fix

Remove the capability. Unlike the tiers below it, this one has no least-privilege reading — there is no subset of SYS_MODULE that is safe to hold:

# Before
services:
  app:
    image: myapp:1.0
    cap_add:
      - SYS_ADMIN

# After — drop everything, add back only what the workload proves it needs
services:
  app:
    image: myapp:1.0
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
  1. Find out what the capability was for. Remove it, start the service, and read the logs; CL-0006 has the full drop-and-observe loop. SYS_ADMIN is usually there for one of two things, and each fails in its own way without it. Mounting a filesystem inside the container fails with mount: permission denied (are you root?); creating namespaces, as browser and build sandboxes do, fails with unshare: unshare(0x10000000): Operation not permitted (both busybox, re-proven on every CI run by scripts/validate_rule_premises.py). On a host with AppArmor, Docker's docker-default profile refuses the mount even with SYS_ADMIN held (mount: mounting none on /tmp failed: Permission denied), on Debian 13 and Ubuntu 24.04 alike; Debian 13 also refuses unshare with Permission denied, where Ubuntu 24.04 allowed it. Each succeeds once AppArmor is unconfined as well, which is CL-0009's finding (measured on Docker 29.1.3, Debian 13 and Ubuntu 24.04, not CI-asserted; CL-0017 records the same for mounts). So on those hosts SYS_ADMIN was never what made it work. On Fedora 43 with SELinux and no AppArmor, SYS_ADMIN alone did mount.

  2. Move the work out of the container, or narrow it.

  3. Mounting: mount on the host, or let Docker do it with a volume, and hand the container the result as an ordinary mount. The container then needs no capability to see the files.

  4. Namespaces: a custom seccomp profile that allows unshare lets the sandbox create user namespaces without SYS_ADMIN (CL-0009, step 3). That is still a widening, but of one system call rather than the broadest capability in the kernel. On an AppArmor host it also needs a custom AppArmor profile, because docker-default refuses user-namespace creation by itself.
  5. cap_add: ALL: enumerate what the service uses instead, with the CL-0006 loop. ALL is never the answer to "something broke".

A workload that genuinely needs one of these — a kernel-module loader, a storage tool that manages block devices — needs a virtual machine or a host process, not a container.

  1. Check what the container holds. CapBnd in /proc/1/status is the most any process in the container can hold; decode it on the host (CL-0006, step 4):
docker compose exec app grep CapBnd /proc/1/status
# CapBnd:    0000000000000001
capsh --decode=0000000000000001
# 0x0000000000000001=cap_chown

cap_sys_admin, cap_sys_module or cap_sys_rawio in the decoded list means the capability is still there.

  1. Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0024    # prints nothing once fixed

Measured on Docker 29.7.2 with busybox:1.37, on a host without AppArmor: both commands fail under Docker's default capabilities, the mount succeeds once SYS_ADMIN is added, and unshare succeeds under the custom profile with no capability added.

When to suppress

Effectively never. cap_add: [ALL] in particular has no legitimate use: it is strictly worse than enumerating the capabilities a workload needs, and equal in blast radius to privileged: true (CL-0002) on the capability axis. If you must, suppress per service with a reason: naming the workload and the isolation that contains it.

What it detects

cap_add entries naming a capability whose grant is host code execution:

Capability Grants
ALL every Linux capability — the capability half of privileged: true
SYS_ADMIN mount filesystems, configure namespaces; the historical home of most container-escape techniques
SYS_MODULE load and unload kernel modules — arbitrary code in kernel space
SYS_RAWIO raw I/O port access via iopl(2)/ioperm(2), granted by the capability alone. It also unlocks /dev/mem, though that path needs the device to be exposed as well and is bounded by CONFIG_STRICT_DEVMEM

CAP_-prefixed and lowercase spellings are equivalent and are matched the same way: Docker treats CAP_SYS_ADMIN and SYS_ADMIN as the same capability.

Why it matters

A container is not a security boundary against code running in the kernel. SYS_MODULE loads a module; SYS_RAWIO opens the raw I/O ports; ALL grants both and everything else. None of these needs a vulnerability — they are the capability working as designed, granted to a workload that should not have it.

SYS_ADMIN is a judgment call about membership, not about severity. Escaping with SYS_ADMIN does need a technique — mounting a cgroup hierarchy, abusing a filesystem, or similar — so on a strict reading of this rule's membership test (a capability reaching host code execution with no technique) it does not qualify. Its severity does not turn on that question: the matrix gives Technique × Host = CRITICAL exactly as it gives Direct × Host = CRITICAL, so SYS_ADMIN derives CRITICAL on either reading of the precondition axis.

It sits in this rule because it grants a superset of what the other three do in practice, and because a user triaging findings is not served by SYS_MODULE and SYS_ADMIN landing in different buckets. Grouping it here is a scale choice, documented as one — but it is not the reason it is CRITICAL. Relegating it to CL-0011 would score it HIGH only by also moving its impact axis to Cross-container, and a SYS_ADMIN escape reaches the host.

ATT&CK coverage

Remediating this finding contributes to mitigating the following MITRE ATT&CK techniques (pinned to ATT&CK v18). compose-lint is a static analyser, so this is mitigation coverage — it detects nothing at runtime.

Technique Tactic
T1611 Escape to Host Privilege Escalation

See also

  • CL-0002 — privileged: true (a functional superset: these capabilities plus devices plus the profiles)
  • CL-0011 — strong host-adjacent capabilities (HIGH)
  • CL-0027 — bounded-grant capabilities (MEDIUM)
  • CL-0006 — the cap_drop: [ALL] baseline these entries re-open
  • Hardening guide, step 5 — where this rule fits when hardening a whole file

Severity derivation

Derivation (see severity model):

  • Baseline: A — the attacker already has code execution in this container, as the workload uid
  • Precondition: Direct for the three mechanical members — SYS_MODULE loads a kernel module, SYS_RAWIO opens the raw I/O ports, ALL grants the full set — each reaching host code execution through supported calls, no technique and no second defect. SYS_ADMIN sits in this cell as a documented judgment call (its escape does need a technique — see below), not as a no-technique claim; both readings land at CRITICAL, so the cell is unaffected
  • Impact: Host
  • Qualifier/modifier: none
  • Derived: Direct × Host = CRITICAL
  • Shipped: CRITICAL
  • Scoping assumptions: SYS_ADMIN is placed here on consistency grounds rather than on a verified no-technique escape — see Why it matters. That affects which rule reports it, not what it derives: Technique × Host is also CRITICAL. The other three are mechanical
  • Evidence: _cl0011 proves only that cap_add deposits the capability into the effective set — not that any member reaches host code execution. Those reaches (module loading via SYS_MODULE, raw I/O port access via SYS_RAWIO, the full set via ALL) are kernel properties reasoned from the capability model and Docker's default seccomp profile, not exercised by a check

References: - OWASP Docker Security Rule #3 - CIS Docker Benchmark 5.4 — Ensure that Linux kernel capabilities are restricted within containers

A reference means the rule relates to that source. It does not mean a file with no finding complies with it. The CIS, OWASP and ATT&CK mapping for every rule, and the tags SARIF output carries for it, are on Standards mapping.