Contract
- Input: container runtime (Docker, Kubernetes, ECS, GKE), workload architecture, compliance requirements.
- Output: container security baseline + image scan policy + runtime rules + K8s security policies.
- Scope: designs and audits container security; does not deploy or patch workloads.
- Rule: designs and audits container security; does not deploy or patch workloads.
- Rule: documented standards override defaults; explicit project rules take precedence.
- Rule: if blocked by missing context or dependencies, surface the blocker before proceeding.
Provenance
| Question |
Answer |
| What is the source of truth? |
The user's request, originating spec/issue, and the skill's declared outputs |
| What is in scope? |
Work covered by the skill's acceptance criteria and completion rules |
| What is explicitly out of scope? |
Files, behaviors, and decisions outside the skill's declared boundary |
| Who or what consumes this artifact afterward? |
The next skill in the workflow or the user |
| What evidence proves it is done? |
Completion criteria met, artifact saved, validation passed |
| What risk remains? |
Subjective judgment calls, missing context, or external dependency failures |
Artifact
Emit ContainerSecurityArtifact as both:
- JSON:
.agents/skills/platform/artifacts/container-security/{identifier}.json
- Markdown view: same filename with
.md extension
Container Security
Secure container workloads — image hygiene, runtime protection, Kubernetes policies, and orchestration controls — for Docker and Kubernetes.
Process
1. Image security baseline
- Base image: use minimal, distroless, or scratch images; pin digests (not tags) in production.
- Non-root: run containers as non-root user (USER directive); avoid running as root in Dockerfile or pod spec.
- Read-only filesystem: mount root filesystem read-only where possible; use emptyDir for writable paths.
- Capabilities: drop ALL Linux capabilities; add back only what is required (NET_BIND_SERVICE for port < 1024).
- Privileged mode: never run privileged containers in production; use specific capabilities instead.
- Resource limits: set CPU and memory limits; enable QoS class for critical workloads.
Completion criterion: image baseline documented; Dockerfile template created.
2. Image scanning and CI/CD gate
- Scan types: vulnerability (CVE), secrets (API keys, tokens), malware, license compliance.
- Tooling: Trivy, Grype, Snyk, Anchore, Docker Scout; integrate into CI/CD pipeline.
- Gate policy: block critical and high-severity CVEs; medium requires approval with justification; low tracked in backlog.
- SBOM: generate Software Bill of Materials (SPDX, CycloneDX) for each image; store in registry or artifact store.
- Signing and verification: sign images (Cosign, Notary); enforce signature verification in admission controller.
Completion criterion: scan policy defined; CI/CD gate implemented; SBOM generation automated.
3. Pod Security Standards (Kubernetes)
- Restricted (production default): must run as non-root; no privilege escalation; read-only root filesystem; drop all capabilities; seccomp profile RuntimeDefault.
- Baseline: prevents known privilege escalations; allows more flexibility than restricted.
- Privileged: unrestricted; only for system / infrastructure namespaces with explicit approval.
- Enforcement: use Pod Security Admission (enforce / audit / warn); migrate from PodSecurityPolicy (deprecated).
- Namespace labels: set pod-security.kubernetes.io/{enforce,audit,warn} labels per namespace.
Completion criterion: Pod Security Standards configured; production namespaces enforce restricted; exceptions documented.
4. Runtime security
- Seccomp profiles: apply RuntimeDefault or custom seccomp profiles; block dangerous syscalls (mount, ptrace, kexec).
- AppArmor / SELinux: apply mandatory access control profiles; use container-default profiles and customise for workload needs.
- Falco / runtime detection: deploy Falco for runtime anomaly detection (unexpected process execution, file modification, network connections).
- Admission control: enforce policies at admission time (Kyverno, OPA Gatekeeper); validate image provenance, resource limits, security context.
Completion criterion: runtime security rules documented; admission control configured; Falco rules deployed.
5. Kubernetes access control
- RBAC: least-privilege roles; avoid cluster-admin; use namespace-scoped roles; bind service accounts to specific roles.
- Service accounts: disable automountServiceAccountToken where not needed; use distinct service accounts per workload.
- Network policies: default-deny ingress and egress; allow only required traffic; use namespace-scoped policies.
- API server hardening: enable RBAC, Node Authorization, AlwaysPullImages; disable anonymous auth; enable audit logging.
Completion criterion: RBAC and NetworkPolicy templates created; cluster hardening checklist complete.
6. Secrets management in containers
- Avoid env vars: do not pass secrets via environment variables; use mounted secrets or volume projection.
- External Secrets Operator: sync secrets from Vault / AWS Secrets Manager / GCP Secret Manager into Kubernetes secrets.
- CSI volume drivers: mount secrets as files via CSI (secrets-store.csi.k8s.io); in-memory or encrypted volume.
- KMS integration: use envelope encryption for etcd; encrypt Kubernetes secrets at rest with KMS.
Completion criterion: secrets management design documented; injection method defined.
7. Monitoring and compliance
- Audit logging: enable Kubernetes audit logs; log to immutable storage; alert on suspicious RBAC changes.
- Image attestation: verify image provenance in admission control; reject unsigned or untrusted images.
- Compliance checks: CIS Kubernetes Benchmark; NSA / CISA Kubernetes Hardening Guide; SOC 2 controls.
- Vulnerability management: track CVEs by image and namespace; prioritise by severity and exploitability.
Completion criterion: monitoring and compliance runbook saved.
Rules
- Rule: never run containers as root; enforce non-root in Pod Security Standards and Dockerfile.
- Rule: pin image digests in production; block mutable tags (latest, stable) in deployment pipelines.
- Rule: scan every image before it reaches production; block critical and high-severity findings automatically.
- Rule: default-deny all network traffic; allow only required ingress and egress paths with NetworkPolicy.
- Rule: store secrets in external secret stores (Vault, KMS, cloud secret manager); never embed secrets in images, ConfigMaps, or env vars.
- Rule: enable runtime security (Falco, Seccomp, AppArmor) and admission control for production clusters.
- Rule: apply least-privilege RBAC; review role bindings and service accounts quarterly; remove unused permissions.
Completion
- the skill's completion criteria are explicitly checked
- the artifact is saved and validated
- any blockers or skipped validations are documented
- the next consumer is identified or the work is handed off
@include .agents/skills/platform/contract-base.xml
1---2name: "container-security"3category: "sec"4maturity: "stable"5version: "1"6description: "Container security (Docker, Kubernetes, image scanning, runtime security, pod security policies)"7license: "MIT"8capabilities:9 - apply container security methods within explicit sec boundaries10 - analyze container security (docker, kubernetes, image scanning, runtime security, pod security policies) with assumptions, constraints, and failure modes11 - produce and validate a sec artifact with evidence, decisions, and next steps12outputs: "container security baseline + image scan policy + runtime rules + K8s security policies."13sideEffects: []14dependencies: []15stopCondition: "Container baseline saved; image scan policy defined; runtime rules documented; K8s security policies complete."16risk: "medium"17trustTier: "3"18maxIterations: "6"19promptVersion: "2.0"20artifactType: "security"21modelTier: "reasoning"22evaluators: ["behavioral", "regression"]23fixturesPath: .agents/skills/platform/fixtures/behavioral/container-security.json24diataxis: "how-to"25tags: ["sec"]26compatibility: []27approvalRequired: "true"28approvalFor: []29metadata:30 source: https://skillmd.com/skills/quantumquirkxyz/container-security31---3233## Contract3435- Input: container runtime (Docker, Kubernetes, ECS, GKE), workload architecture, compliance requirements.36- Output: container security baseline + image scan policy + runtime rules + K8s security policies.37- Scope: designs and audits container security; does not deploy or patch workloads.38- Rule: designs and audits container security; does not deploy or patch workloads.39- Rule: documented standards override defaults; explicit project rules take precedence.40- Rule: if blocked by missing context or dependencies, surface the blocker before proceeding.4142## Provenance4344| Question | Answer |45|---|---|46| What is the source of truth? | The user's request, originating spec/issue, and the skill's declared outputs |47| What is in scope? | Work covered by the skill's acceptance criteria and completion rules |48| What is explicitly out of scope? | Files, behaviors, and decisions outside the skill's declared boundary |49| Who or what consumes this artifact afterward? | The next skill in the workflow or the user |50| What evidence proves it is done? | Completion criteria met, artifact saved, validation passed |51| What risk remains? | Subjective judgment calls, missing context, or external dependency failures525354## Artifact5556Emit `ContainerSecurityArtifact` as both:57- JSON: `.agents/skills/platform/artifacts/container-security/{identifier}.json`58- Markdown view: same filename with `.md` extension596061# 62# 63# Container Security6465Secure **container workloads** — image hygiene, runtime protection, Kubernetes policies, and orchestration controls — for Docker and Kubernetes.6667## Process6869### 1. Image security baseline70- **Base image:** use minimal, distroless, or scratch images; pin digests (not tags) in production.71- **Non-root:** run containers as non-root user (USER directive); avoid running as root in Dockerfile or pod spec.72- **Read-only filesystem:** mount root filesystem read-only where possible; use emptyDir for writable paths.73- **Capabilities:** drop ALL Linux capabilities; add back only what is required (NET_BIND_SERVICE for port < 1024).74- **Privileged mode:** never run privileged containers in production; use specific capabilities instead.75- **Resource limits:** set CPU and memory limits; enable QoS class for critical workloads.7677**Completion criterion:** image baseline documented; Dockerfile template created.7879### 2. Image scanning and CI/CD gate80- **Scan types:** vulnerability (CVE), secrets (API keys, tokens), malware, license compliance.81- **Tooling:** Trivy, Grype, Snyk, Anchore, Docker Scout; integrate into CI/CD pipeline.82- **Gate policy:** block critical and high-severity CVEs; medium requires approval with justification; low tracked in backlog.83- **SBOM:** generate Software Bill of Materials (SPDX, CycloneDX) for each image; store in registry or artifact store.84- **Signing and verification:** sign images (Cosign, Notary); enforce signature verification in admission controller.8586**Completion criterion:** scan policy defined; CI/CD gate implemented; SBOM generation automated.8788### 3. Pod Security Standards (Kubernetes)89- **Restricted (production default):** must run as non-root; no privilege escalation; read-only root filesystem; drop all capabilities; seccomp profile RuntimeDefault.90- **Baseline:** prevents known privilege escalations; allows more flexibility than restricted.91- **Privileged:** unrestricted; only for system / infrastructure namespaces with explicit approval.92- **Enforcement:** use Pod Security Admission (enforce / audit / warn); migrate from PodSecurityPolicy (deprecated).93- **Namespace labels:** set pod-security.kubernetes.io/{enforce,audit,warn} labels per namespace.9495**Completion criterion:** Pod Security Standards configured; production namespaces enforce restricted; exceptions documented.9697### 4. Runtime security98- **Seccomp profiles:** apply RuntimeDefault or custom seccomp profiles; block dangerous syscalls (mount, ptrace, kexec).99- **AppArmor / SELinux:** apply mandatory access control profiles; use container-default profiles and customise for workload needs.100- **Falco / runtime detection:** deploy Falco for runtime anomaly detection (unexpected process execution, file modification, network connections).101- **Admission control:** enforce policies at admission time (Kyverno, OPA Gatekeeper); validate image provenance, resource limits, security context.102103**Completion criterion:** runtime security rules documented; admission control configured; Falco rules deployed.104105### 5. Kubernetes access control106- **RBAC:** least-privilege roles; avoid cluster-admin; use namespace-scoped roles; bind service accounts to specific roles.107- **Service accounts:** disable automountServiceAccountToken where not needed; use distinct service accounts per workload.108- **Network policies:** default-deny ingress and egress; allow only required traffic; use namespace-scoped policies.109- **API server hardening:** enable RBAC, Node Authorization, AlwaysPullImages; disable anonymous auth; enable audit logging.110111**Completion criterion:** RBAC and NetworkPolicy templates created; cluster hardening checklist complete.112113### 6. Secrets management in containers114- **Avoid env vars:** do not pass secrets via environment variables; use mounted secrets or volume projection.115- **External Secrets Operator:** sync secrets from Vault / AWS Secrets Manager / GCP Secret Manager into Kubernetes secrets.116- **CSI volume drivers:** mount secrets as files via CSI (secrets-store.csi.k8s.io); in-memory or encrypted volume.117- **KMS integration:** use envelope encryption for etcd; encrypt Kubernetes secrets at rest with KMS.118119**Completion criterion:** secrets management design documented; injection method defined.120121### 7. Monitoring and compliance122- **Audit logging:** enable Kubernetes audit logs; log to immutable storage; alert on suspicious RBAC changes.123- **Image attestation:** verify image provenance in admission control; reject unsigned or untrusted images.124- **Compliance checks:** CIS Kubernetes Benchmark; NSA / CISA Kubernetes Hardening Guide; SOC 2 controls.125- **Vulnerability management:** track CVEs by image and namespace; prioritise by severity and exploitability.126127**Completion criterion:** monitoring and compliance runbook saved.128129## Rules130131- Rule: never run containers as root; enforce non-root in Pod Security Standards and Dockerfile.132- Rule: pin image digests in production; block mutable tags (latest, stable) in deployment pipelines.133- Rule: scan every image before it reaches production; block critical and high-severity findings automatically.134- Rule: default-deny all network traffic; allow only required ingress and egress paths with NetworkPolicy.135- Rule: store secrets in external secret stores (Vault, KMS, cloud secret manager); never embed secrets in images, ConfigMaps, or env vars.136- Rule: enable runtime security (Falco, Seccomp, AppArmor) and admission control for production clusters.137- Rule: apply least-privilege RBAC; review role bindings and service accounts quarterly; remove unused permissions.138139## Completion140141- the skill's completion criteria are explicitly checked142- the artifact is saved and validated143- any blockers or skipped validations are documented144- the next consumer is identified or the work is handed off145---146@include .agents/skills/platform/contract-base.xml