CL-0002: privileged: true — what it grants and how to replace it¶
Severity: CRITICAL (how it is derived)
privileged: true hands the container every capability and every host device,
and turns off its seccomp and AppArmor profiles, so escaping to host root is a
one-liner. Remove it and grant only the specific thing the service needed.
Fix¶
# Instead of:
privileged: true
# Use:
cap_drop:
- ALL
cap_add:
- NET_ADMIN # only what you actually need
security_opt:
- no-new-privileges:true
- Find out what it was for. Remove the line, start the service, and read the logs; the CL-0006 drop-and-observe loop names each capability a failure points at. Most uses are one of these, and each has a narrower setting:
| Use case | Instead of privileged: true |
|---|---|
| Mount filesystems | Mount on the host and hand the container the result. cap_add: SYS_ADMIN works but is itself CRITICAL (CL-0024) |
| Specific device access | devices: [/dev/foo] + device_cgroup_rules (CL-0016) |
| Network configuration | cap_add: NET_ADMIN + cap_add: NET_RAW (CL-0011) |
| Bind a port below 1024 | Nothing: in the container's own network namespace low ports need no capability since Docker 20.10. Only under network_mode: host does it take NET_BIND_SERVICE (CL-0006) |
| Run a debugger sidecar | cap_add: SYS_PTRACE and pid: "service:<name>", which reaches only that service's processes (CL-0027) |
| Docker-in-Docker | Prefer the sysbox-runc runtime. Rootless DinD is not a way out: docker:29-dind-rootless without privileged exits with [rootlesskit:parent] error: failed to start the child: fork/exec /proc/self/exe: operation not permitted (captured on Docker 29.7.2, not CI-asserted). It starts only with security_opt: [seccomp:unconfined, systempaths=unconfined] and devices: [/dev/net/tun], which trades this finding for CL-0009's |
- Recreate the service and check what it holds:
docker compose up -d app
docker inspect --format '{{.HostConfig.Privileged}}' $(docker compose ps -q app)
# false
docker compose exec app grep -E 'CapBnd|Seccomp:' /proc/1/status
# CapBnd: 0000000000001000 (only what you added; decode with capsh)
# Seccomp: 2 (0 while privileged: no filter)
Privileged, the same container showed CapBnd: 000001ffffffffff (every
capability), Seccomp: 0, and 215 entries in /dev against 15
(Docker 29.7.2, busybox:1.37).
- Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0002 # prints nothing once fixed
Tested on: Docker 29.7.2 with Compose 5.5.0, on a host without AppArmor (Yama ptrace_scope 1); the Fix steps above were re-run there in October 2026. Also measured in throwaway VMs in October 2026 (Docker 29.9.1 or 29.1.3): on Ubuntu 24.04 with AppArmor, a default container reports docker-default (enforce) and a privileged one unconfined. Not tested: SELinux; the sysbox-runc runtime.
What it detects¶
Any service with privileged: true.
Why it matters¶
Privileged mode disables nearly all container isolation. The container receives every Linux capability, every host device under /dev, and runs without the default seccomp and AppArmor profiles. PID, mount, and network namespaces are still in place by default, but escape to host root is trivial — mount, unshare, mknod, and BPF are all unblocked, and the host's block devices are all present, so mounting the host root filesystem (mount /dev/sda1 /mnt) is a one-liner.
The release_agent escape that older write-ups lead with is cgroup v1 only. Current hosts run the v2 unified hierarchy, which has no release_agent file (verified: CgroupVersion: 2 on the daemon these rules are grounded against). Do not treat its absence as evidence that a privileged container is contained — the block-device path above needs no cgroup trick at all.
Treat privileged: true as trivially escapable to host root, not literally equivalent to running on the host — but the practical attack distance is one well-known technique away.
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 |
| T1685 Disable or Modify Tools | Defense Impairment |
See also¶
- CL-0006 —
cap_drop: [ALL](privileged grants all caps) - CL-0009 — seccomp / AppArmor (privileged drops both default profiles)
- CL-0010 — host namespaces (privileged does not by itself share them, but is often combined with them)
- CL-0024 —
cap_add: [ALL]is the cap-only subset of privileged - CL-0011 / CL-0027 — the other capability tiers
- Hardening guide, step 10 — where this rule fits when hardening a whole file
On a service with privileged: true and nothing else hardened, CL-0002 fires
alongside CL-0003, CL-0006, CL-0007 and CL-0026. CL-0009, CL-0010 and CL-0024
fire only on their own keys, so privileged does not raise them even though it
grants what they guard.
Severity derivation¶
Derivation (see severity model):
- Baseline: A — the attacker already has code execution in this container, as the workload uid
- Precondition: Direct — the container starts with every capability, every host device, and no default seccomp or AppArmor profile
- Impact: Host
- Qualifier/modifier: none
- Derived: Direct × Host = CRITICAL
- Shipped: CRITICAL
- Evidence:
_cl0002— a privileged container holds the full capability set, verified against a live daemon on every CI run
References: - OWASP Docker Security Rule #3 - CIS Docker Benchmark 5.5 — Ensure that privileged containers are not used
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.