The Docker daemon should restrict containers from acquiring new privileges

docker

Classification:

compliance

Framework:

cis-docker

Control:

2.15

Description

The Docker daemon should start every container with no-new-privileges.

Rationale

With no-new-privileges, a process in a container keeps the privileges it started with: setuid and setgid binaries and file capabilities grant it nothing more.

Audit

Look for no-new-privileges on the dockerd command line and in daemon.json:

ps -o args= -C dockerd
grep '"no-new-privileges"' /etc/docker/daemon.json

Datadog reads --no-new-privileges on the dockerd command line or, if it isn’t set there, no-new-privileges in daemon.json. It passes the rule when the setting is true and fails it otherwise.

Remediation

Set no-new-privileges in daemon.json:

{
  "no-new-privileges": true
}

Then restart the daemon with systemctl restart docker.

Impact

Programs that need setuid binaries, such as sudo inside a container, stop working.

Default value

Containers can gain privileges through setuid and setgid binaries.

References

  1. https://docs.docker.com/reference/cli/dockerd/
  2. https://github.com/moby/moby/pull/20727