TMAegis
More rules for docker

TMA-DOCKER-3.9

Ensure that TLS CA certificate file ownership is set to root:root

HighLevel 1Automateddocker

Description

The TLS CA certificate file must be owned by root:root so that it cannot be replaced by unprivileged users. The path is taken from --tlscacert on the dockerd command line or "tlscacert" in /etc/docker/daemon.json (default /root/.docker/ca.pem); compliant when no such file exists (TLS not configured).

How it is checked

Audit method: Shell command

shell
args=$(ps -eo args 2>/dev/null) || exit 1; s=$(printf '%s\n' "$args" | grep '[d]ockerd'; cat /etc/docker/daemon.json 2>/dev/null); p=$(printf '%s\n' "$s" | sed -n -e 's/.*--tlscacert[= ]\([^ ]*\).*/\1/p' -e 's/.*"tlscacert"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1); [ -n "$p" ] || p=/root/.docker/ca.pem; [ -e "$p" ] || { echo compliant; exit 0; }; o=$(stat -Lc '%U:%G' "$p") || exit 1; [ "$o" = root:root ] && echo compliant || echo "$p $o"
Expected output
compliant

How it is fixed

Fix method: Guidance or infrastructure patch

chown root:root <path of the tlscacert file> (as configured for dockerd).

Properties

Operating systems
Any
Tags
dockerpermissionstls
Reference
CIS Docker Benchmark v1.9.0 - 3.9 Ensure that TLS CA certificate file ownership is set to root:root

Check this host

Run this on a machine you are allowed to audit. The scan is read-only.

shell
tmaegis scan --target docker