agentleFS
medy-gribkovmedy-gribkov/arcana/skills/container-security/SKILL.md

container-security

Skill1 starsChanged 9 months agoApache-2.0View on GitHub

Container security from build to runtime. Image scanning, minimal base images, rootless execution, secrets management, supply chain verification, and runtime policies with concrete Dockerfile examples.

  • Reads credentials
  • Installs packages

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use iac-security, threat-modeling and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • UnitOneAISkill

    iac-security

    Performs a security review of Infrastructure as Code templates against the OWASP IaC Security Cheat Sheet, SLSA v1.0, and CIS Benchmarks. Auto-invoked when reviewing Terraform, CloudFormation, or Pulumi configurations. Detects hardcoded secrets, public exposure patterns, encryption gaps, overly permissive IAM, and misconfigurations equivalent to Checkov, tfsec, and KICS rules. Produces a structured findings report with remediation guidance.

    Also in 4 projects that use this

  • UnitOneAISkill

    threat-modeling

    Runs a structured STRIDE threat model on any system design, API specification, or codebase. Auto-invoked when the user discusses architecture, shares a system diagram or design document, or asks "what could go wrong?" Produces threat actor profiles, component-threat matrix, a threat register with STRIDE classification, data-flow diagram template, trust boundary identification, and prioritized mitigations mapped to MITRE ATT&CK techniques.

    Also in 5 projects that use this

  • jefflesterSkill

    api-security

    API security best practices and common vulnerability prevention. Enforces security checks for authentication, input validation, SQL injection, XSS, and OWASP Top 10 vulnerabilities. Use when building or modifying APIs.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run Trivy before every push.

    line 8
  2. Distinctive:

    Use Grype as a second scanner.

    line 14
  3. Very specific:

    Use distroless or scratch for runtime.

    line 28
  4. Very specific:

    Always create a non-root user and switch to it.

    line 32
  5. Distinctive:

    Use BuildKit secrets for credentials needed during build (e.g., private registry tokens).

    line 64
  6. Distinctive:

    Ensure secrets never enter the build context.

    line 89
  7. Distinctive:

    Verify signature before pull.

    line 116
  8. Distinctive:

    Create a Software Bill of Materials for every release.

    line 124
  9. Distinctive:

    Verify signature before deploying.

    line 197

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Image Scanning

Run Trivy before every push. Fail CI on HIGH or CRITICAL vulnerabilities.

trivy image myapp:latest --severity HIGH,CRITICAL --exit-code 1

Use Grype as a second scanner. Different scanners catch different CVEs.

grype myapp:latest --fail-on high

Store scan results as build artifacts for trending.

trivy image myapp:latest --format json --output scan-results.json

Minimal Base Images

Use distroless or scratch for runtime. Multi-stage builds separate build tools from runtime. See references/dockerfile-hardening.md for complete BAD/GOOD Dockerfile patterns for Go, Node.js, and static binaries.

Rootless Containers

Always create a non-root user and switch to it. For distroless, use the built-in nonroot user (UID 65532). See references/dockerfile-hardening.md for rootless patterns.

Secrets Management

BAD: Baking secrets into the image. They persist in layers even if deleted.

FROM node:24-alpine
ENV DATABASE_PASSWORD=supersecret
COPY . /app
CMD ["node", "server.js"]

GOOD: Inject secrets at runtime via environment variables or mounted files.

docker run -e DATABASE_PASSWORD="$(cat /secure/db-password)" myapp:latest

For Kubernetes, use Secrets mounted as volumes or environment variables.

env:
  - name: DATABASE_PASSWORD
    valueFrom:
      secretKeyRef:
        name: db-credentials
        key: password

Build-Time Secrets

Use BuildKit secrets for credentials needed during build (e.g., private registry tokens).

BAD: Copying .env file into the image.

COPY .env /build/.env
RUN npm install --registry=https://private.npm.com

GOOD: Mount secrets during build without persisting them.

# syntax=docker/dockerfile:1
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc \
    npm install --registry=https://private.npm.com

Build with:

docker buildx build --secret id=npmrc,src=.npmrc .

Audit .dockerignore

Ensure secrets never enter the build context.

.env
.env.*
*.key
*.pem
secrets/
credentials.json

Scan committed Dockerfiles for hardcoded tokens.

gitleaks detect --source . --no-git

Supply Chain Security

Sign Images with Cosign

Sign after building. Verify before deploying.

cosign sign myregistry.com/myapp:v1.0.0

Verify signature before pull.

cosign verify --key cosign.pub myregistry.com/myapp:v1.0.0

Generate SBOM

Create a Software Bill of Materials for every release.

syft myapp:latest -o json > sbom.json
trivy image --format cyclonedx --output sbom.json myapp:latest

Attach SBOM to the image as an OCI artifact.

cosign attach sbom --sbom sbom.json myregistry.com/myapp:v1.0.0

Pin Dependencies by Digest

BAD: Using mutable tags. Tags can be overwritten.

FROM node:24-alpine

GOOD: Pin by digest. Digest is immutable.

FROM node:24-alpine@sha256:abc123...

Find digests with:

docker pull node:24-alpine
docker inspect node:24-alpine | jq -r '.[0].RepoDigests[0]'

Runtime Policies

Admission control (Gatekeeper, Kyverno), seccomp profiles, and Falco runtime monitoring. See references/runtime-security.md for policy YAML examples and Falco rules.

CI Checklist

  1. Lint Dockerfile with Hadolint.
hadolint Dockerfile
  1. Scan for secrets in build context.
gitleaks detect --source . --no-git
  1. Build and scan image.
docker build -t myapp:latest .
trivy image myapp:latest --exit-code 1 --severity HIGH,CRITICAL
  1. Sign image and generate SBOM.
cosign sign myregistry.com/myapp:v1.0.0
syft myapp:latest -o json > sbom.json
  1. Push to registry with immutable tag.
docker tag myapp:latest myregistry.com/myapp:v1.0.0
docker push myregistry.com/myapp:v1.0.0
  1. Verify signature before deploying.
cosign verify --key cosign.pub myregistry.com/myapp:v1.0.0

Dockerfile Best Practices

Complete BAD/GOOD Dockerfile comparisons and common mistakes. See references/dockerfile-hardening.md for full examples.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.