User namespace support should be enabled in Docker

docker

Classification:

compliance

Framework:

cis-docker

Control:

2.10

Description

The Docker daemon should remap the users of containers to an unprivileged range of the host.

Rationale

With user namespace remapping, root in a container is an unprivileged user on the host, so an escape from the container lands without root privileges.

Audit

Look for userns in the security options of the daemon:

docker info --format '{{ .SecurityOptions }}'

Datadog passes the rule when the security options include name=userns, or name=rootless for a rootless daemon, and fails it otherwise.

Remediation

Set userns-remap in daemon.json:

{
  "userns-remap": "default"
}

Then restart the daemon with systemctl restart docker. Containers that need the host’s user namespace then run with --userns=host.

Impact

Remapping changes the owner of files in volumes and bind mounts, and some workloads need --userns=host.

Default value

User namespace remapping is off.

References

  1. https://man7.org/linux/man-pages/man7/user_namespaces.7.html
  2. https://docs.docker.com/reference/cli/dockerd/#daemon-user-namespace-options