This product is not supported for your selected Datadog site. ().

Metadata

Id: dockercompose-service-explicitly-runs-as-root

Platform: DockerCompose

Severity: Medium

Category: Least Privilege

Learn More

Description

Explicitly running a service as the root user (user: root or user: 0) means any process breakout or file-system exploit has immediate root-level access to the host filesystem and kernel. Running as root also bypasses many file permission checks, increasing the blast radius of a container compromise. Services should run as a dedicated non-root user by setting user to a non-zero UID or a named non-root account.

Compliant Code Examples

services:
  non_root:
    image: alpine
    user: "1000"
  named_user:
    image: alpine
    user: appuser
  no_user:
    image: alpine

Non-Compliant Code Examples

services:
  root_name:
    image: alpine
    user: root
  uid_zero:
    image: alpine
    user: "0"
  root_group:
    image: alpine
    user: root:root
  padded_uid:
    image: alpine
    user: "00"
  padded_uid_with_group:
    image: alpine
    user: "000:1000"