The containerd socket file should be audited, if applicable

docker

Classification:

compliance

Framework:

cis-docker

Control:

1.1.8

Description

The containerd socket should carry an audit rule, so that the audit log records every change to it and every use of it.

Rationale

Whoever can use the containerd socket controls every container of the host. An audit rule on it records who read, changed, or ran it, and when. An investigation of a compromise needs this record.

Audit

Find the containerd socket that dockerd uses, then look for an audit rule on it:

ps -o args= -C dockerd
grep containerd /etc/docker/daemon.json
auditctl -l | grep containerd.sock

Datadog judges the containerd socket that dockerd uses: the one that --containerd or daemon.json names, else /run/containerd/containerd.sock when it exists, else /run/docker/containerd/containerd.sock, where dockerd starts a containerd of its own. It passes the rule when a loaded audit rule watches that socket, under /run or /var/run, fails it when the socket exists without a watch, and reports it not applicable when the socket is absent. A socket that dockerd names elsewhere also reports not applicable, and needs a manual review.

Remediation

Add a watch for the path to a file in /etc/audit/rules.d, then load the rules:

echo "-w /run/containerd/containerd.sock -k docker" >> /etc/audit/rules.d/docker.rules
augenrules --load

Impact

Every use or change of the path adds a record to the audit log, which needs rotation and room of its own.

Default value

A new installation leaves the audit rules to the administrator, and the rule fails until the watch is added.

References

  1. https://github.com/containerd/containerd/blob/main/docs/ops.md
  2. https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/system_design_guide/auditing-the-system_system-design-guide
  3. https://docs.docker.com/reference/cli/dockerd/#docker-runtime-execution-options