Dockerfile security checker
Paste a Dockerfile and get the risky lines: running as root, latest tags, secrets in ENV or ARG, curl piped to a shell, and more, each with the fix.
Checked as you type. Nothing you paste leaves this page.
The file is read in your browser. It is not uploaded.
Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.
How to use the dockerfile security checker
- Paste the Dockerfile, drop the file, or load the example.
- Read the findings from the top: critical and high first.
- Change the line as the finding says, then paste again to confirm it is gone.
- Treat info findings as things to check, such as what your .dockerignore leaves out.
About this tool
A Dockerfile decides what is inside an image and who the process runs as. A few lines cause most of the trouble: no USER instruction, so the app runs as root; a base image on the latest tag, so each build pulls something different; a token in ENV or ARG, where anyone with the image can read it from docker history.
This checker reads the file the way a reviewer would. It follows multi-stage builds, so only the last stage decides the user, and it knows that a stage name or scratch is not an unpinned image. Findings come worst first with the line number, the reason, and what to write instead. Secrets it finds are shown redacted.
It is a set of rules, not a review, and it sees the Dockerfile only: not the base image’s own packages and not your .dockerignore. For known vulnerabilities in what the image installs, HardenKit Scan reads the packages inside a built image and ranks what it finds by what is being exploited.
Sources
Questions
Root inside a container is root on the kernel the container shares with the host. If the application is exploited, the attacker starts with the highest privilege, and a container escape bug becomes a host takeover. Add a USER instruction with an unprivileged user as the last one in the file.
No. Build arguments are recorded in the image history, so docker history shows them to anyone who can pull the image. Use a build secret with RUN --mount=type=secret, which is available to one step and is not stored in any layer.
It moves. Two builds of the same Dockerfile can produce different images, you cannot say which version is running, and a bad or compromised push upstream reaches you on the next build. Pin a version tag, and pin the digest as well if you want builds that never change underneath you.
COPY, unless you need what ADD adds. ADD also unpacks local tar archives and downloads URLs, and a download has no integrity check unless you give it --checksum. Docker’s own best practices recommend COPY for plain files.