Skip to content

CL-0028: cap_add: PERFMON, SYS_TIME

Severity: HIGH (how it is derived)

The service adds SYS_TIME, which sets the host's clock for every workload on the machine, or PERFMON, which samples every process on the host. Keep the clock in sync on the host and profile from the host, and the container needs neither.

Fix

# Before: an NTP server that also sets the host clock
services:
  ntp:
    image: mychrony:1.0        # chronyd, e.g. from Alpine's chrony package
    cap_add:
      - SYS_TIME

# After: serves time, never sets the clock
services:
  ntp:
    image: mychrony:1.0
    cap_drop:
      - ALL
    command: ["chronyd", "-d", "-x", "-u", "root"]
  1. Check the host already keeps its own clock. A container reads the host's clock, so it does not need its own time daemon for that:
# On a systemd host
timedatectl show -p NTPSynchronized --value
# yes

If the container's only job was keeping the clock right, remove it.

  1. If it serves time to other machines, run it without clock control. chronyd's -x keeps it from touching the clock at all, so it needs no SYS_TIME. -u root keeps it from switching to the chrony user, which under cap_drop: [ALL] fails with Could not change ownership of /run/chrony : Operation not permitted. It logs Disabled control of system clock. To answer clients at all, chrony.conf needs an allow line (Alpine's default has none, and a client then reports No suitable source for synchronisation). Publish UDP 123 the way CL-0005 describes if clients on your network use it.

Without SYS_TIME and without -x, chronyd exits at startup:

CAP_SYS_TIME not present
Fatal error : adjtimex(0x8001) failed : Operation not permitted
  1. Profile from the host instead of granting PERFMON. The host sees the container's processes under host PIDs; this prints the one for the service's main process, to hand to perf top -p or another host profiler:
docker inspect --format '{{.State.Pid}}' $(docker compose ps -q app)
  1. Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0028    # prints nothing once fixed

Verified against Docker 29.7.2 with chrony 4.6.1: the -x server starts under cap_drop: [ALL] and a second chrony container synced to it once the server's config had an allow line (selected as ^* in chronyc sources). The chronyd messages are its own wording, captured, not CI-asserted. perf itself was not run.

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, SYS_TIME let a container set the host clock (date -s moved it to 2031); with systemd-timesyncd running, the host snapped back within a second, so the change is brief but real. Not tested: SELinux.

When to suppress

These have real legitimate uses, so suppression here is ordinary rather than exceptional — but both have a better answer than the capability:

  • SYS_TIME — an NTP client (chrony, ntpd) in a container. Prefer syncing the clock on the host; a container that sets the host clock is a design smell even when it works.
  • PERFMON — profilers and APM agents. Prefer profiling from the host, where the same access needs no container capability.

Suppress per service with a reason: naming the workload.

What it detects

cap_add entries naming a capability whose reach lands on the host:

Capability Grants Why it is not CRITICAL
SYS_TIME set the system clock, host-global — Docker does not isolate CLOCK_REALTIME it corrupts host state; it does not execute code on the host or hand over control of it
PERFMON perf_event_open across the host — kernel samples, every process on the machine a read primitive: it discloses, it does not write or execute

Why it matters

SYS_TIME is the one most often underestimated. The clock is host-global — a container holding this capability moves the host's wall clock, and every workload on the machine sees it. Certificate validation, time-based one-time passwords and Kerberos all break together, and the failure looks like an outage rather than an attack. Rolling the clock backwards is worse than forwards: it can bring expired certificates back inside their validity window and reopen TOTP windows that have already been used.

PERFMON is a host-wide read that needs no other key in the compose file. On a kernel at the upstream default it samples across every process on the machine, which is a credible route to material from workloads that have nothing to do with this container.

Neither hands over the host, which is why they sit below CL-0024 — but both leave this container, which is why they sit above CL-0027.

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
T1070 Indicator Removal Stealth
T1499 Endpoint Denial of Service Impact
T1003 OS Credential Dumping Credential Access

See also

  • CL-0024 — host-code-execution capabilities (CRITICAL)
  • CL-0011 — strong host-adjacent capabilities (HIGH)
  • CL-0027 — bounded, container-scoped capabilities (MEDIUM)
  • 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 — one supported syscall realises the impact. clock_settime(2) sets the clock; perf_event_open(2) opens the host-wide event. Neither needs a published technique, a defect outside this file, or anything from the image
  • Impact: Host — both members reach past the container onto the host itself, with no sibling key required. SYS_TIME writes the host's wall clock because Docker does not namespace CLOCK_REALTIME; PERFMON reads host processes and kernel samples. This is the axis on which the rule was split from CL-0027, whose members stay inside the container and depend on what the image supplies
  • Qualifier/modifier: integrity-only — priced at SYS_TIME, whose grant is a write that corrupts host state without disclosing anything or granting any control over the host. PERFMON reaches the same tier by the other route, read-only: it is pure observation. Both members land at HIGH, so the rule is homogeneous at the tier even though the two take different qualifiers to get there
  • Derived: Direct × Host + integrity-only = HIGH
  • Shipped: HIGH
  • Scoping assumptions: none. That is the point of the split — neither member's reach is conditional on another key in the file, so there is nothing to hold at a secure default and nothing to scope away
  • Daemon assumptions: grounded at the upstream kernel default kernel.perf_event_paranoid = 2 (ADR-020). Debian and Ubuntu ship 3, a downstream hardening patch that demands CAP_SYS_ADMIN instead and leaves PERFMON inert; that is hardening and reads the severity down, as rootless mode does. It does not move the cell: SYS_TIME is the pricing member and no sysctl affects it
  • Evidence: _t_perfmon in scripts/validate_rule_premises.py asserts the grounded behaviour against a live daemon: at --cap-drop ALL a system-wide perf_event_open (pid=-1, cpu=0, kernel samples included) is refused, and --cap-drop ALL --cap-add PERFMON opens one. Measured on Arch at perf_event_paranoid=2 (granted) and Debian 13 at 3 (refused, where --cap-add SYS_ADMIN grants it instead — the check asserts that fallback rather than assuming it, and reports the host as hardened rather than the premise as wrong). _t_sys_time covers the pricing member: a clock_gettime→clock_settime round-trip of the same timespec is refused without the capability and succeeds with it. That the affected clock is the host's follows from CLOCK_REALTIME not being namespaced; it is reasoned, not measured — the round-trip deliberately changes nothing

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.