- Home
- Skills
- DevOps & Cloud
- Dockerfile Security Linter with Fixes
Works with the AI Agents you already use
Dockerfile Security Linter with Fixes
by Saizul Amin
Audit Dockerfiles for leaked secrets and insecure root configurations, then rewrite them for BuildKit hardening.
$6
Dockerfile Security Linter with Fixes
Example session with this skill installed
Review this Dockerfile for security problems and give me the fixes.
- Read your context and instructions
- Compiled the dockerfile security linter
I ran the bundled script from the dockerfile-security skill and reviewed its findings.
Demo data: this is the real, unedited output of the skill's script on the test fixture that ships with its source repo.
Script output
dockerfile lint: 1 file(s), 3 high, 8 medium, 4 low, 1 info
HIGH tests/fixtures/dockerfile-security/bad/Dockerfile:3 DF003 ARG GITHUB_TOKEN has a default secret value; build args are visible in image history
fix: use BuildKit secrets: RUN --mount=type=secret,id=github_token
HIGH tests/fixtures/dockerfile-security/bad/Dockerfile:4 DF003 ENV DB_PASSWORD bakes a secret into the image
fix: pass it at runtime (docker run -e / compose secrets) or use RUN --mount=type=secret,id=...
HIGH tests/fixtures/dockerfile-security/bad/Dockerfile:10 DF006 secret file copied into the image: .env
fix: use RUN --mount=type=secret or runtime secrets; add the file to .dockerignore
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:1 DF001 base image 'node' is not tagged
fix: pin a version tag and ideally a digest: FROM image:1.2.3@sha256:...
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:2 DF003 ARG NPM_TOKEN passes a secret; build args are visible in image history
fix: use BuildKit secrets: RUN --mount=type=secret,id=npm_token
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:6 DF003 ENV API_KEY bakes a secret into the image (from a build arg; still stored in the image)
fix: pass it at runtime (docker run -e / compose secrets) or use RUN --mount=type=secret,id=...
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:7 DF004 ADD downloads from a URL without an integrity check
fix: ADD --checksum=sha256:... URL, or RUN curl -fsSL ... && sha256sum -c
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:11 DF005 remote script piped straight into an interpreter
fix: download, verify a checksum or signature, then run it
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:12 DF007 TLS certificate verification is disabled
fix: remove the flag; add the CA instead
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:12 DF008 world-writable permissions
fix: grant only what the app user needs
MEDIUM tests/fixtures/dockerfile-security/bad/Dockerfile:15 DF002 final USER is root
fix: switch to an unprivileged USER
LOW tests/fixtures/dockerfile-security/bad/Dockerfile:8 DF004 ADD used for plain files
fix: use COPY (ADD auto-extracts archives)
LOW tests/fixtures/dockerfile-security/bad/Dockerfile:9 DF010 COPY . without a .dockerignore may ship .git, .env and local secrets
fix: add .dockerignore with .git, .env*, *.pem, node_modules, ...
LOW tests/fixtures/dockerfile-security/bad/Dockerfile:13 DF008 sudo in RUN (builds already run as root)
fix: drop sudo; switch USER explicitly
LOW tests/fixtures/dockerfile-security/bad/Dockerfile:14 DF009 EXPOSE 22: SSH server inside a container
fix: use docker exec / kubectl exec
INFO tests/fixtures/dockerfile-security/bad/Dockerfile:1 DF012 no HEALTHCHECK
fix: add HEALTHCHECK CMD ... (or define it in compose/k8s)
Next steps
- Remove baked-in secrets first and rotate any token that was ever in an image.
- Pin the base image to a tag and digest, and switch to a non-root USER.
- Add a .dockerignore and a HEALTHCHECK, then rebuild and re-run the lint.
Connects securely to your tools. The creator never sees your data.
About this skill
Leaking secrets in image history or running containers as root are common oversights that lead to production breaches. This skill audits your Dockerfiles for security anti-patterns and rewrites them using industry-standard hardening techniques.
What it does
- Static analysis audits Dockerfiles for 12 distinct security rules including hardcoded secrets and insecure permissions.
- Secret detection identifies credentials baked into
ENV,ARG, orRUNcommands that persist in image layers. - Hardening rewrites transforms insecure files into multi-stage builds with unprivileged users and pinned image digests.
- BuildKit integration implements
RUN --mount=type=secretto handle build-time credentials likeNPM_TOKENwithout leaking them. - Context validation checks for the presence of
.dockerignoreto prevent accidental inclusion of.envfiles or private keys.
How it works
- Lint the target directory or specific file using the provided Python utility to identify high, medium, and low risk findings.
- Analyze the output to distinguish between fixable build patterns and compromised secrets that require immediate rotation.
- Rewrite the Dockerfile using multi-stage patterns, checksum-verified downloads, and minimal final stages.
- Verify the fix by inspecting image history and checking the runtime user ID if a Docker daemon is accessible.
Frameworks & tools
This skill uses a Python-based linting script and targets Docker, Containerfile, and BuildKit environments.
Why this beats prompting it yourself
Generic LLMs often suggest :latest tags or forget to mention that ARG values are permanently stored in image metadata. This skill follows a strict rule-based audit that ensures no secret is left in the docker history and enforces specific BuildKit syntax for secure secret handling.
Use cases
- Auditing a legacy Dockerfile before a production deployment.
- Safely passing
GITHUB_TOKENorNPM_TOKENduring a container build. - Refactoring a monolithic Dockerfile into a secure multi-stage image.
- Verifying that an image does not require root privileges to function.
Known limitations
Does not scan for CVEs within installed OS packages or libraries. It is restricted to Dockerfile syntax and build patterns, not runtime orchestrator configurations like Kubernetes NetworkPolicies.
Open source: saizul/security-audit-skills on GitHub (MIT licence, by Saizul Amin).
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.
Does not scan for OS/library CVEs. Limited to Dockerfile syntax. Does not audit Kubernetes or Docker Compose runtime manifests.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 days ago
- Software
Python 3.8+