Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Dockerfile Security Linter with Fixes

    by Saizul Amin

    1

    Audit Dockerfiles for leaked secrets and insecure root configurations, then rewrite them for BuildKit hardening.

    $6

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Dockerfile Security Linter with Fixes

    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

    1. Remove baked-in secrets first and rotate any token that was ever in an image.
    2. Pin the base image to a tag and digest, and switch to a non-root USER.
    3. 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, or RUN commands 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=secret to handle build-time credentials like NPM_TOKEN without leaking them.
    • Context validation checks for the presence of .dockerignore to prevent accidental inclusion of .env files or private keys.

    How it works

    1. Lint the target directory or specific file using the provided Python utility to identify high, medium, and low risk findings.
    2. Analyze the output to distinguish between fixable build patterns and compromised secrets that require immediate rotation.
    3. Rewrite the Dockerfile using multi-stage patterns, checksum-verified downloads, and minimal final stages.
    4. 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_TOKEN or NPM_TOKEN during 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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.

    Frequently Asked Questions

    This skill specifically targets Dockerfile syntax and build-time patterns to prevent secret leaks and privilege escalation, whereas traditional scanners usually focus on vulnerabilities (CVEs) within the installed OS packages or libraries.

    Yes, the skill is designed to work with both standard Dockerfiles and Containerfiles, and it specifically optimizes for BuildKit features like secret mounting and multi-stage builds.

    You will receive the core security audit engine, a Python-based utility for local linting, and the specialized AI logic required to automate the secure refactoring of your Dockerfiles.

    No, the audit logic identifies patterns where secrets are baked into layers (like ENV or ARG) and rewrites the file to use BuildKit secret mounts, ensuring the credentials never persist in the image history.

    The skill provides a specialized Python utility that your AI agent uses to analyze the directory, followed by a guided rewrite process that you can review and apply to your source code.

    While the skill enforces best practices like unprivileged users and pinned digests, it does not scan for runtime-specific configurations like Kubernetes SecurityContexts or NetworkPolicies.

    New in DevOps & Cloud