Skip to main content

Impact & Risk Analysis

  • Severity: High
  • CIS Benchmark: CIS 4.1
  • Impact: Privilege Escalation & Bind Mount Issues. By default, containers run with root privileges. This increases the risk of privilege escalation if the container is compromised. Additionally, running as root can create permission challenges when bind-mounting volumes from the underlying host.

Common Misconfiguration

Failing to create a specific user in the Dockerfile or failing to switch to that user using the USER directive. By default, Docker containers run as the root user inside the container.

Vulnerable Example

Secure Example

Alternative Remediation (Entrypoint Script)

If it is not possible to set the USER directive in the Dockerfile (e.g., you need root to install dependencies at runtime), use a script to drop privileges:

Audit Procedure

To verify if a container is running as root, run the following command on the host:
  • Result: This returns the effective UID.
  • Fail: If it returns 0, the container process is running as root.
  • Pass: If it returns a non-zero ID (e.g., 1000), it is compliant.