For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/default_rules/634-w65-56w.md. A documentation index is available at /llms.txt.

SELinux security options should be properly configured for effective application security

docker

Classification:

compliance

Framework:

cis-docker

Control:

5.3

Description

On a host with SELinux enforcing, containers should run with an SELinux label.

Rationale

An SELinux label confines the processes of a container to its own files, which limits what an attacker can do from inside it.

Audit

Inspect the containers:

docker ps --quiet --all | xargs docker inspect --format '{{ .Name }}: SecurityOpt={{ .HostConfig.SecurityOpt }} ProcessLabel={{ .ProcessLabel }}'

Datadog applies the rule to the hosts where SELinux is enforcing. It passes the rule when a container runs with a process label other than the unconfined types spc_t and unconfined_t, and without label=disable, and fails it otherwise.

Remediation

Set selinux-enabled in daemon.json:

{
  "selinux-enabled": true
}

Then restart the daemon, and run the containers without --security-opt label=disable.

Impact

Bind mounts need the :z or :Z option to relabel their content.

Default value

Docker labels the containers when the daemon enables SELinux.

References

  1. https://docs.docker.com/engine/security/#other-kernel-security-features
  2. https://docs.docker.com/engine/containers/run/#security-configuration
  3. https://docs.redhat.com/en/documentation/red_hat_enterprise_linux_atomic_host/7/html/container_security_guide/docker_selinux_security_policy