require-dockerfile-user
Require an explicit USER instruction in Dockerfiles.
Targeted pattern scopeâ
- Repository-root
Dockerfilecontent. - Presence of a
USER ...instruction.
What this rule reportsâ
This rule reports Dockerfiles that never set a runtime user.
Why this rule existsâ
Without an explicit USER, containers typically run as root, which increases
blast radius if a process is compromised. Requiring USER keeps privilege
choices explicit and reviewable.
â Incorrectâ
FROM node:22-alpine
WORKDIR /app
â Correctâ
FROM node:22-alpine
WORKDIR /app
USER node
When not to use itâ
Disable this rule if your container intentionally requires root at runtime.
Rule catalog ID: R084