Dockerfile includes USER directive with non-root UID above 1000
Why it matters
Containers running as root (UID 0) violate the principle of least privilege (NIST 800-53 AC-6, CWE-250) and collapse the host boundary if any container escape vulnerability is exploited. A root container with a kernel exploit gains full control of the host node — every other workload on that node is compromised. CIS Docker 4.1 and CIS Kubernetes 5.2.6 both mandate non-root execution. The blast radius of a runtime compromise is bounded only when the container process has no privilege to exercise outside its own namespace.
Severity rationale
Critical because a container running as root combined with any container-escape vulnerability grants full host node access, compromising all co-located workloads.
Remediation
Add a dedicated unprivileged user in Dockerfile and enforce it in Kubernetes securityContext. In Dockerfile:
RUN useradd -m -u 1001 appuser
USER appuser
In your Kubernetes Deployment manifest (k8s/deployment.yaml):
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
For distroless images that have no useradd, set USER 65532 (the nonroot user built into distroless). The UID must exceed 1000 to avoid collision with system accounts.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Infrastructure Hardening Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-250 — Execution with Unnecessary Privileges
- nist:rev5 · AC-6 — Least Privilege
- external · CIS-Docker-4.1 — CIS Docker Benchmark v1.6 §4.1 — Ensure a user for the container has been created
- external · CIS-Kubernetes-5.2.6 — CIS Kubernetes Benchmark §5.2.6 — Do not admit root containers
- soc2:2017 · CC6.6 — Protection against threats from outside system boundaries
Taxons
History
- 2026-04-18·v1.0.0·Initial import from infrastructure-hardening·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.6) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2