Secret written into the Dockerfile (ARCH10003)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key config.docker.secret-in-image · Severity error · Category security · CWE CWE-798
A value written into an ENV or ARG stays in the image’s layers and build history: everyone who can pull the image can read it, long after the line was removed from the Dockerfile. The rule looks at names that end in a secret word (password, secret, token, API key, client secret, connection string) with a value written out.
Incorrect
Section titled “Incorrect”FROM node:22.11-alpineENV DATABASE_PASSWORD=change-me-123COPY . .USER nodeCMD ["node", "server.js"]Correct
Section titled “Correct”FROM node:22.11-alpine# The password is mounted at run time (docker secret / Kubernetes Secret).ENV DATABASE_PASSWORD_FILE=/run/secrets/db_passwordCOPY . .USER nodeCMD ["node", "server.js"]Pass the value at run time (an environment variable of the container, an orchestrator secret) or as a build secret (RUN --mount=type=secret).
Not flagged
Section titled “Not flagged”- A reference (
$VAR,${VAR}) and an empty value. - Names that only mention a secret:
PASSWORD_FILE,TOKEN_URL,CACHE_KEY.