Secrets injected at runtime (not in manifest or image).
NetworkPolicy default-deny applied.
Image signed and SBOM generated.
Pod Security Standard: restricted level.
1---2name: container-security3description: Skill — Container Security4---56# Skill — Container Security78## When this skill activates9Any task involving container image security, runtime hardening,10Kubernetes security policies, container secret management,11or supply chain integrity for containerized workloads.1213## Mandatory actions when this skill is active1415### Before writing any code161. Select base image strategy (distroless preferred, Alpine acceptable, Ubuntu last resort).172. Identify secrets required and injection mechanism (never env vars in manifests).183. Define network policy requirements (default-deny baseline).194. Determine Pod Security Standard level (restricted > baseline > privileged).2021### During implementation22- Pin base images by digest (not just tag) for reproducibility.23- Run as non-root user (UID > 10000).24- Set filesystem to read-only where possible.25- Drop all Linux capabilities, add back only what's needed.26- Never store secrets in image layers or environment variables in manifests.27- Use multi-stage builds to exclude build tools from runtime image.2829### After implementation30- Run Trivy/Grype scan — block on CRITICAL or HIGH CVEs.31- Sign image with cosign and generate SBOM.32- Verify Pod Security Standard compliance.33- Test NetworkPolicy blocks unauthorized traffic.34- Confirm secrets are injected at runtime (not baked in).3536## Image Scanning3738### CI Pipeline Integration39```yaml40# Block deployment if critical CVEs found41- trivy image --severity CRITICAL,HIGH --exit-code 1 $IMAGE42```4344### Scan Frequency45- On every build (CI gate).46- Weekly scheduled scan of running images (new CVEs discovered post-deploy).47- Before promotion between environments.4849### Vulnerability Management50- CRITICAL: Block deployment, fix immediately.51- HIGH: Block deployment, fix within 48 hours.52- MEDIUM: Track, fix within sprint.53- LOW: Backlog, fix opportunistically.5455## Base Image Strategy5657| Priority | Image Type | Use Case |58|----------|-----------|----------|59| 1 | `gcr.io/distroless/static` | Go binaries, no shell needed |60| 2 | `gcr.io/distroless/base` | C/C++ apps needing libc |61| 3 | `alpine:3.x` | When shell/package manager needed |62| 4 | `ubuntu:22.04-minimal` | Complex runtime dependencies |6364### Rules65- Pin by digest: `FROM alpine@sha256:abc123...`66- Rebuild weekly to pick up base image security patches.67- Never use `latest` tag in production.6869## Runtime Hardening7071### Pod Security Standards (Kubernetes)7273**Restricted (target for all workloads):**74```yaml75securityContext:76 runAsNonRoot: true77 runAsUser: 1000178 readOnlyRootFilesystem: true79 allowPrivilegeEscalation: false80 capabilities:81 drop: ["ALL"]82 seccompProfile:83 type: RuntimeDefault84```8586### Container Isolation87- Use gVisor or Kata Containers for untrusted workloads.88- Separate namespaces for different trust levels.89- Resource limits (CPU, memory) to prevent DoS.9091## Secrets Management9293### Injection Methods (Ranked)941. **External Secrets Operator** → syncs from Vault/AWS SM to K8s Secret → volume mount.952. **Vault Agent Sidecar** → injects secrets into shared volume at runtime.963. **CSI Secret Store Driver** → mounts secrets as files.974. **Sealed Secrets** → encrypted in Git, decrypted in cluster.9899### Anti-patterns (NEVER do)100- Secrets as environment variables in Pod spec/Deployment manifest.101- Secrets baked into container image.102- Secrets in ConfigMaps.103- Secrets committed to Git (even "encrypted" without proper tooling).104105## Network Policies106107### Default Deny Baseline108```yaml109apiVersion: networking.k8s.io/v1110kind: NetworkPolicy111metadata:112 name: default-deny-all113spec:114 podSelector: {}115 policyTypes:116 - Ingress117 - Egress118```119120Then explicitly allow required flows:121- Ingress: only from specific services/namespaces.122- Egress: only to required databases, APIs, DNS.123124## Supply Chain Integrity125126### Image Provenance1271. Sign all images with `cosign` in CI.1282. Generate SBOM (Software Bill of Materials) with `syft`.1293. Enforce signature verification in admission controller (Kyverno/OPA).1304. Use deterministic builds for reproducibility.131132### Admission Control133- Reject unsigned images.134- Reject images from untrusted registries.135- Reject images with known critical CVEs.136- Reject pods violating security context requirements.137138## Self-check139- [ ] Base image pinned by digest.140- [ ] Non-root user configured.141- [ ] Read-only filesystem enabled.142- [ ] All capabilities dropped (add back minimally).143- [ ] Image scanned with zero CRITICAL/HIGH CVEs.144- [ ] Secrets injected at runtime (not in manifest or image).145- [ ] NetworkPolicy default-deny applied.146- [ ] Image signed and SBOM generated.147- [ ] Pod Security Standard: restricted level.
Run npx skillmds@latest add sairam0424/container-security in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Skill — Container Security It is listed under Security on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
sairam0424 (@sairam0424) published this skill. Their other Agent Skills are listed on their SkillMD profile.