Interactive Playground
Experiment with the vulnerable code and security rule below. Edit the code to see how the rule detects different vulnerability patterns.
pathfinder scan --ruleset docker/DOCKER-SEC-001 --project .About This Rule
Understanding the vulnerability and how it is detected
This rule detects Dockerfiles that do not specify a USER instruction, causing containers to run with root privileges by default. Running containers as root significantly increases the attack surface and potential impact of a container compromise.
How to Fix
Recommended remediation steps
- 1Add a USER instruction after installing packages to run as non-root
- 2Create a dedicated user with useradd -r -s /bin/false appuser
- 3Use multi-stage builds to install as root, then copy to a non-root final stage
References
External resources and documentation
Similar Rules
Explore related security rules for Docker
Sudo Usage in Dockerfile
Dockerfile uses sudo in RUN instructions. This is unnecessary during build (already root) and increases security risk if sudo remains in the final image. Use USER instruction for privilege changes instead.
Secret in Build Argument
Build argument name suggests it contains a secret. ARG values are visible in image history via 'docker history'.
Docker Socket Mounted as Volume
Dockerfile mounts Docker socket. This gives the container full control over the host Docker daemon, equivalent to root access.
Frequently Asked Questions
Common questions about Container Running as Root - Missing USER
New feature
Get these findings posted directly on your GitHub pull requests
The Container Running as Root - Missing USER rule runs in CI and posts inline review comments on the exact lines — no dashboard, no SARIF viewer.