Kubernetes YAML Security Review Checklist Prompt
AI-driven security review of Kubernetes manifests — privilege, capabilities, network exposure, secret handling, and admission-policy compliance.
- Target user
- Platform & security engineers reviewing K8s manifests before they hit prod
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior cloud-native security engineer who has audited Kubernetes manifests for SOC 2, PCI, and HIPAA environments. You know what gets flagged by Falco, OPA/Gatekeeper, Kyverno, and Pod Security Standards. Review the Kubernetes manifest(s) I share. Apply this security checklist: 1. **Privilege & user** - `securityContext.runAsNonRoot: true` set? - `runAsUser` not 0 (root)? - `allowPrivilegeEscalation: false`? - `privileged: false` (never true unless documented for a CNI/CSI plugin)? 2. **Capabilities** - `capabilities.drop: ["ALL"]`? - Any added caps justified? (NET_ADMIN, SYS_ADMIN, etc. are red flags) 3. **Filesystem** - `readOnlyRootFilesystem: true`? - `emptyDir` mounts for writable scratch space if needed? 4. **Resources & limits** - Both requests AND limits set on all containers? - Limits within reasonable bounds for the workload type? 5. **Network exposure** - Service type appropriate (ClusterIP for internal, LoadBalancer only when external is intended)? - NetworkPolicy in place restricting ingress/egress? - No 0.0.0.0/0 ingress unless explicitly needed? 6. **Secrets** - Secrets referenced by name, not inlined as base64? - No credentials in `env` or `args` (use envFrom + Secret)? - Volumes mounting secrets are `defaultMode: 0400` or similar? 7. **Probes** - Liveness, readiness, and (where appropriate) startup probes defined? - Probe paths don't expose sensitive endpoints? 8. **Image hygiene** - Image pinned to a digest (`@sha256:...`) or specific tag, not `:latest`? - `imagePullPolicy: IfNotPresent` or `Always` as appropriate? 9. **Pod Security Standards** - Manifest passes "baseline" PSS? - Manifest passes "restricted" PSS (the high bar)? For each finding: **severity** (critical / high / medium / low), **resource and line**, **problem**, **fix as a YAML patch**. Manifest(s): ```yaml [PASTE] ```
Why this prompt works
K8s manifests fail security review for boringly consistent reasons: root, privileged, no limits, no NetworkPolicy, :latest images, secrets in env. This prompt enforces the same checklist a security engineer would run, and demands YAML patches — not vague advice.
How to use it
- Paste one complete manifest at a time. Don’t drop in 8 files; review them sequentially.
- After the review, ask: “rewrite the manifest applying every critical and high finding.”
- Run the result through
kubeconform,kube-score, andkubesecto catch what the AI missed.
Pair this with
kubesec— risk-score K8s manifestskube-score— production-readiness auditpolaris— config validationkyvernoor OPA Gatekeeper — admission-time enforcement
What good security review output looks like
CRITICAL — Deployment/api:30 — Container runs as root (no
securityContext.runAsUserand image’s USER is 0).Fix:
spec: template: spec: securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 1000 containers: - name: api securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: ["ALL"]
Related prompts
-
Dockerfile Security Review Prompt
AI security review of a Dockerfile — privilege, attack surface, secrets in layers, vulnerable bases, supply-chain risk.
-
Helm Chart Review Prompt
Get a senior-engineer review of a Helm chart — values hygiene, template correctness, security defaults, upgrade safety.
-
Kubernetes Pod Troubleshooting Prompt
Diagnose any misbehaving pod — pending, evicted, networking-broken, storage-stuck, or just plain slow — with a structured AI walkthrough.
-
Linux Server Hardening Prompt
Walk an AI through a CIS-style hardening review of a Linux server — services, users, SSH, kernel parameters, file permissions — with safe, ordered remediation.