Inferensys

Prompt

Kubernetes Manifest Security Review Prompt Template

A practical prompt playbook for using a Kubernetes Manifest Security Review Prompt Template in production AI workflows to detect privilege escalation, network gaps, and container escape risks.
Risk analyst performing AI risk assessment on laptop, risk matrices visible, casual office risk session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal integration point, user, and boundaries for the Kubernetes Manifest Security Review prompt before it reaches a production cluster.

This prompt is designed for platform and security engineering teams who need to automate the security review of Kubernetes YAML manifests before they reach a cluster. It is intended to be integrated into a CI/CD pipeline or a PR review workflow where a raw manifest diff is the input. The prompt instructs the model to act as a security reviewer, rank findings by exploitability, and produce a structured, machine-readable report. It is not a replacement for a full penetration test or a live cluster audit. Use it as a fast pre-merge gate that catches high-signal misconfigurations before they become production vulnerabilities.

The ideal input is a unified diff of Kubernetes YAML manifests against a known baseline, such as the main branch. The prompt expects the model to reason about privilege escalation paths, network policy gaps, container escape risks, and RBAC misconfigurations. It is most effective when applied to namespace-scoped resources like Deployments, Pods, Services, and NetworkPolicies. The output is a structured JSON report with findings ranked by exploitability, each mapped to a specific resource and line reference, making it directly actionable for developers and CI systems.

Do not use this prompt as a standalone security audit for a live cluster or as a substitute for a penetration test. It cannot reason about runtime behavior, kernel vulnerabilities, or multi-step attack chains that span multiple clusters. It is also not designed for reviewing non-Kubernetes infrastructure, such as Terraform plans or cloud IAM policies. For those, use the dedicated playbooks in this pillar. Always pair this prompt with a human approval step for findings rated 'critical' or when the diff includes changes to ClusterRole, ClusterRoleBinding, or hostPath volumes.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Kubernetes Manifest Security Review prompt is effective and where it falls short.

01

Good Fit: Pre-Merge Security Review

Use when: Platform teams gate PRs that modify Kubernetes YAML in CI/CD pipelines. The prompt excels at catching privilege escalations, hostPath mounts, and overly permissive RBAC before they reach production. Guardrail: Run as a required status check with a clear severity threshold for blocking merges.

02

Bad Fit: Runtime Intrusion Detection

Avoid when: You need real-time detection of active container escapes or live cluster attacks. This prompt reviews static manifests, not running process behavior or syscall anomalies. Guardrail: Pair with a runtime security tool like Falco; use this prompt only for pre-deployment manifest review.

03

Required Input: Complete Resource Context

What to watch: Reviewing a single Deployment in isolation misses namespace-scoped risks from RBAC, NetworkPolicy, or PodSecurityPolicy interactions. Guardrail: Always include the full namespace manifest bundle—Deployment, ServiceAccount, RoleBinding, and NetworkPolicy—in the review context.

04

Operational Risk: False Positive Fatigue

What to watch: The prompt may flag low-risk findings like readOnlyRootFilesystem: false in debugging sidecars, leading teams to ignore or disable the check. Guardrail: Implement a suppression file with justification tracking for accepted risks, and review suppressions quarterly.

05

Operational Risk: Base Image CVE Noise

What to watch: The prompt cannot scan container images for CVEs; it only reviews Kubernetes resource configuration. Teams expecting full vulnerability coverage will have a gap. Guardrail: Combine this prompt with an image scanning tool (Trivy, Grype) in the pipeline and clearly document the split of responsibilities.

06

Bad Fit: Multi-Tenant Hardening Guarantees

Avoid when: You need a formal security boundary guarantee between hostile tenants sharing a cluster. The prompt identifies common misconfigurations but cannot prove kernel isolation or side-channel resistance. Guardrail: Use this prompt as a first-pass filter, not as a substitute for a full security audit by a specialist.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for reviewing Kubernetes manifests for security risks, privilege escalation, and network policy gaps.

This template is designed to be pasted directly into your AI harness, LLM playground, or automated review pipeline. It accepts a Kubernetes manifest, optional namespace context, and a configurable risk tolerance level. The prompt instructs the model to produce a structured security assessment ranked by exploitability, with specific focus on privilege escalation paths, container escape risks, and network policy misconfigurations. Replace each square-bracket placeholder with the actual values before sending the request to the model.

text
You are a Kubernetes security reviewer. Analyze the following Kubernetes manifest for security risks. Rank findings by exploitability (Critical, High, Medium, Low). For each finding, provide the exact resource path, the security control violated, the exploitation scenario, and a specific remediation.

Focus your analysis on:
- Privilege escalation paths (privileged containers, hostPath mounts, CAP_SYS_ADMIN, etc.)
- Container escape risks (unrestricted seccomp/AppArmor profiles, hostPID, hostNetwork)
- Network policy gaps (missing ingress/egress restrictions, default-deny absence)
- RBAC misconfigurations (overly broad rules, wildcard verbs/resources)
- Secret handling (plaintext secrets in env, unencrypted ConfigMaps)
- Image supply chain risks (latest tags, unsigned images, unknown registries)

[CONTEXT]
Target Namespace: [NAMESPACE]
Cluster Security Policy Reference: [POLICY_REFERENCE]
Risk Tolerance: [RISK_LEVEL]

Manifest to review:
```yaml
[MANIFEST_YAML]

[OUTPUT_SCHEMA] Return a JSON object with this exact structure: { "summary": { "total_findings": <integer>, "critical": <integer>, "high": <integer>, "medium": <integer>, "low": <integer>, "overall_risk": "<CRITICAL|HIGH|MEDIUM|LOW>" }, "findings": [ { "id": "<K8S-SEC-XXX>", "severity": "<CRITICAL|HIGH|MEDIUM|LOW>", "category": "<privilege_escalation|container_escape|network_policy|rbac|secret_handling|image_supply_chain>", "resource_path": "<kind>/<name>/<field-path>", "control_violated": "<specific security control or policy name>", "exploitation_scenario": "<step-by-step attack path description>", "remediation": "<specific YAML change or kubectl command>", "false_positive_risk": "<LOW|MEDIUM|HIGH>" } ], "namespace_scoped_notes": ["<context-specific observations about namespace isolation, existing policies, or compensating controls>"] }

[CONSTRAINTS]

  • Do not flag resources that inherit security contexts from namespace-level defaults unless the override is dangerous.
  • If a PodSecurityPolicy or Admission Controller would block the finding, note it in false_positive_risk and namespace_scoped_notes.
  • For network policy findings, assume a zero-trust model unless [POLICY_REFERENCE] specifies otherwise.
  • Do not flag latest tags if the image digest is pinned in the same manifest.
  • If [RISK_LEVEL] is "LOW", suppress findings that require cluster-admin access to exploit.

Adapt this template by adjusting the [CONSTRAINTS] section to match your organization's specific admission controller policies, Pod Security Standards level, and allowed image registries. For production CI/CD pipelines, wire the [OUTPUT_SCHEMA] into a JSON validator that rejects malformed responses and triggers a retry with the error message appended to [CONTEXT]. Always require human review for findings with severity "CRITICAL" or category "container_escape" before allowing deployment to proceed. For namespace-scoped resources, pre-populate [NAMESPACE] and [POLICY_REFERENCE] from your cluster metadata to reduce false positives on inherited security contexts.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Kubernetes Manifest Security Review prompt. Validate each variable before calling the model to prevent garbage-in-garbage-out results and ensure consistent security findings.

PlaceholderPurposeExampleValidation Notes

[MANIFEST_YAML]

The complete Kubernetes manifest to review, including all resources in the scope

apiVersion: apps/v1 kind: Deployment metadata: name: payment-api namespace: production spec: template: spec: containers: - name: app image: payment-api:v1.2.3 securityContext: privileged: true

Must be valid YAML. Parse with a YAML validator before passing. Reject empty inputs. Multi-document YAML is allowed but each document must be parseable. Size limit: 50KB to avoid context window exhaustion.

[NAMESPACE_CONTEXT]

The target namespace and any namespace-scoped policies, RBAC bindings, or network policies already in effect

Namespace: production Existing NetworkPolicies: deny-all-ingress, allow-from-ingress-gateway Existing PodSecurityPolicy: restricted Existing RBAC: service-account-payment-api bound to role payment-api-role

Optional but strongly recommended. If absent, the prompt cannot assess namespace-scoped privilege escalation or network policy gaps. Set to null if unknown, but flag findings as 'namespace context missing' in output.

[CLUSTER_POLICIES]

Cluster-wide policies that apply regardless of namespace, such as OPA/Gatekeeper constraints, PodSecurity admission, or Kyverno policies

OPA Constraint: block-privileged-containers (enforced) PodSecurity Admission: restricted (enforce) Kyverno Policy: require-image-digest (audit) NetworkPolicy: default-deny-all (global)

Optional. If absent, the prompt cannot detect violations of cluster-level guardrails. Set to null if unknown. Validation: must be a structured list of policy names and enforcement modes (enforce/audit/dry-run).

[IMAGE_REGISTRY_POLICIES]

Organizational policies for allowed registries, required image digests, and signing requirements

Allowed Registries: gcr.io/my-org, my-org.azurecr.io Require Image Digest: true Require Image Signature: true (cosign) Blocked Tags: latest, dev, staging

Optional. If absent, the prompt cannot flag image sourcing violations. Set to null if unknown. Validation: each policy must have a boolean or list value. Reject ambiguous entries like 'secure images only'.

[SECURITY_CONTEXT_CONSTRAINTS]

Platform-level security context constraints or PodSecurity standards enforced on the cluster

PodSecurity Standard: restricted Allowed Capabilities: NET_BIND_SERVICE AllowPrivilegeEscalation: false SeccompProfile: RuntimeDefault required SELinux: MustRunAs enforced

Optional. If absent, the prompt uses Kubernetes upstream defaults for assessment. Set to null if unknown. Validation: must map to known PodSecurity fields. Reject free-text descriptions without field mappings.

[EXCEPTIONS_LIST]

Known exceptions, accepted risks, or previously reviewed findings that should not be re-flagged

Exception-001: privileged container in kube-system/audit-logger (accepted risk, reviewed 2024-11-15) Exception-002: hostNetwork in monitoring/fluentd (required for log collection, reviewed 2024-10-01)

Optional. Use to suppress false positives for previously accepted risks. Validation: each exception must include a unique ID, resource identifier, justification, and review date. Reject exceptions without justification.

[OUTPUT_SCHEMA]

The expected structure for security findings, including severity levels, finding types, and required fields

{ "findings": [ { "id": "string", "severity": "critical|high|medium|low|info", "category": "privilege_escalation|network_exposure|container_escape|rbac_misconfig|image_risk|resource_limits|secret_exposure|policy_violation", "resource": "string", "field": "string", "description": "string", "exploitability": "immediate|conditional|theoretical", "remediation": "string", "false_positive_risk": "low|medium|high" } ], "summary": { "total_findings": 0, "critical": 0, "high": 0, "requires_immediate_escalation": false } }

Required. The prompt must produce structured output matching this schema. Validation: parse the model response against this JSON schema. Retry once on schema mismatch. If retry fails, return raw output with a schema_violation flag set to true.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Kubernetes Manifest Security Review prompt into a CI/CD pipeline or security review application.

Integrating this prompt into a production workflow requires more than a single API call. The prompt is designed to be a step in a deterministic pipeline that validates inputs, enforces a structured output schema, and gates deployment based on findings. The primary integration points are pull request checks in CI/CD systems (GitHub Actions, GitLab CI, Jenkins) or as a service behind a security review chatbot. The prompt expects a raw Kubernetes manifest YAML string as [INPUT] and a [RISK_LEVEL] threshold, and it must return a structured JSON object that downstream tooling can parse without human interpretation.

The implementation harness should enforce a strict contract. Before calling the model, validate that the [INPUT] is valid YAML and does not exceed a maximum size (e.g., 50KB) to prevent context-window overflows and cost spikes. After receiving the model's response, use a JSON schema validator to confirm the output contains the required fields: findings (array), risk_score (integer 0-100), and must_fix (boolean). If validation fails, implement a retry loop with a maximum of two attempts, appending the validation error to the prompt as a correction instruction. Log every raw request, response, and validation result to an immutable audit store for compliance and debugging. For high-risk environments, route any finding with exploitability: high or privilege_escalation_possible: true to a human review queue (e.g., a Jira ticket or Slack alert) before allowing a merge.

Model choice matters for this workflow. Use a model with strong reasoning capabilities and a large context window, such as claude-sonnet-4-20250514 or gpt-4o, as manifest analysis requires tracing relationships across multiple YAML documents. Avoid smaller, faster models for initial review; they can be used in a secondary judge role to verify the primary model's output consistency. Do not use this prompt as the sole gatekeeper for production deployments. Always pair it with static analysis tools (e.g., kubesec, checkov) and use the prompt's output to contextualize and prioritize those findings. The next step is to build a set of golden-test manifests with known vulnerabilities and benign configurations to measure false positive and false negative rates before enabling the check on critical deployment pipelines.

IMPLEMENTATION TABLE

Expected Output Contract

Schema contract for the JSON object returned by the Kubernetes Manifest Security Review prompt. Use this to validate model output before surfacing findings to a dashboard or ticketing system.

Field or ElementType or FormatRequiredValidation Rule

findings

Array of objects

Must be a JSON array. If no findings, return an empty array, not null or a string.

findings[].id

String (kebab-case)

Must match pattern ^[a-z]+(-[a-z]+)*$. Must be unique within the array.

findings[].severity

Enum: CRITICAL, HIGH, MEDIUM, LOW, INFO

Must be one of the listed enum values. CRITICAL is reserved for container escape or cluster-admin escalation paths.

findings[].resource_kind

String

Must be a valid Kubernetes resource kind (e.g., Deployment, Pod, NetworkPolicy). Case-sensitive.

findings[].resource_name

String

Must match the metadata.name field from the input manifest. If the resource is unnamed, use the value unnamed.

findings[].exploitability

Enum: PROVEN, LIKELY, POSSIBLE, UNLIKELY, NONE

PROVEN requires a direct reference to a known CVE or published exploit chain. NONE is only valid for INFO severity.

findings[].remediation

String

Must be a non-empty string containing a specific, actionable YAML snippet or configuration change. Generic advice like 'apply least privilege' is invalid.

findings[].policy_reference

String or null

If present, must reference a specific organizational policy ID or a well-known benchmark rule (e.g., CIS 5.2.6). Null is allowed.

PRACTICAL GUARDRAILS

Common Failure Modes

Production failure patterns observed when using LLMs to review Kubernetes manifests and how to prevent them before they reach a merge decision.

01

Privilege Escalation Blind Spots

What to watch: The model misses indirect privilege escalation paths such as automountServiceAccountToken combined with overly permissive RBAC, or hostPath mounts that bypass container isolation. It often flags the obvious privileged: true but overlooks chained misconfigurations that achieve the same effect. Guardrail: Maintain a checklist of privilege escalation primitives (capabilities, host volumes, service account bindings) and require the model to cross-reference each against the pod's effective permissions before assigning severity.

02

Network Policy Gap Hallucination

What to watch: The model confidently reports missing network policies without checking whether a default-deny policy exists in the namespace or whether the manifest targets a namespace that uses a mesh-wide policy. This produces high false-positive rates on namespace-scoped resources. Guardrail: Require the prompt to accept an optional [EXISTING_NETWORK_POLICIES] input. When absent, instruct the model to flag network exposure as a finding with a caveat rather than a confirmed vulnerability.

03

Context Window Truncation on Large Manifests

What to watch: Multi-document YAML files or Helm-rendered output exceeding the model's effective context window cause silent omissions. The model reviews only the first portion and returns a clean bill of health for the unexamined remainder. Guardrail: Split large manifests into individual resource documents before review. Implement a pre-check that counts resources and warns if the count exceeds a threshold. Run the review per-resource or per-namespace rather than as a single monolithic pass.

04

Severity Inflation on Non-Exploitable Findings

What to watch: The model assigns Critical or High severity to findings that require unrealistic attack preconditions, such as requiring cluster-admin access to exploit a misconfiguration. This desensitizes reviewers and leads to alert fatigue. Guardrail: Include explicit severity definitions in the prompt that tie exploitability preconditions to severity levels. Require the model to state the minimum attacker privilege required for each finding and downgrade severity when preconditions are prohibitive.

05

Container Image Tag Drift Assumptions

What to watch: The model treats latest tags, unpinned digests, or public registry images as critical vulnerabilities without considering organizational policy exceptions or the fact that the image may be mirrored internally. It also misses supply chain risks in pinned digests from unverified registries. Guardrail: Provide an [ALLOWED_REGISTRIES] and [IMAGE_POLICY] input. Instruct the model to differentiate between policy violations and best-practice recommendations, and to flag image provenance rather than only tag hygiene.

06

Namespace-Scoped Resource Confusion

What to watch: The model evaluates namespace-scoped resources (Roles, RoleBindings, NetworkPolicies) as if they have cluster-wide impact, or conversely, evaluates cluster-scoped resources without considering namespace-level compensating controls. This produces both false positives and false negatives. Guardrail: Require the model to explicitly state the scope of each resource before evaluating its security impact. Include a [NAMESPACE_CONTEXT] input describing existing namespace-level policies and compensating controls.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing output quality before shipping this prompt to production. Use these standards to evaluate model responses against known-good and known-bad Kubernetes manifests.

CriterionPass StandardFailure SignalTest Method

Finding Completeness

All privilege escalation paths, network policy gaps, and container escape risks in the test manifest are identified with a severity ranking

A known high-severity finding (e.g., hostPath mount with no readOnly) is missing from the output

Run against a golden manifest containing 5 known vulnerabilities; verify all 5 appear in the findings array

False Positive Rate

Zero false positives on namespace-scoped resources with standard configurations

Output flags a compliant resource (e.g., a Deployment with securityContext.runAsNonRoot: true) as a HIGH severity finding

Test against a clean manifest with 10 namespace-scoped resources that pass organizational policy; expect empty findings array

Severity Ranking Accuracy

Findings are ranked by exploitability: container escape > privilege escalation > network exposure > misconfiguration

A hostPath mount is ranked below a missing resource request, or network policy gaps are ranked above privileged container access

Provide a manifest with mixed severity issues; verify the output order matches the exploitability hierarchy in the prompt instructions

Evidence Grounding

Each finding includes a specific manifest path (e.g., spec.template.spec.containers[0].securityContext.privileged) and the violating value

A finding states 'container may be insecure' without referencing a specific field or line in the manifest

Parse the output JSON; confirm every finding object has a non-empty 'location' field with a valid JSONPath or YAML path

Remediation Guidance

Each finding includes a concrete fix suggestion that references the correct Kubernetes API field and value

Remediation suggests 'use security context' without specifying which field to set or what value to use

Check that every finding with severity HIGH or CRITICAL has a 'remediation' field containing a specific field name and recommended value

Output Schema Compliance

Output is valid JSON matching the specified schema with all required fields present

Output is missing the 'findings' array, or findings objects lack required 'severity' or 'description' fields

Validate output against the JSON schema defined in the prompt; reject any response that fails schema validation

Namespace Scope Awareness

Findings correctly distinguish between cluster-scoped and namespace-scoped resources; no cluster-admin warnings for namespaced roles

A namespaced Role with limited permissions is flagged as a cluster-wide privilege escalation risk

Test with a manifest containing both a ClusterRole and a namespaced Role; verify the output correctly scopes each finding

Human Approval Trigger

Output includes an 'requires_immediate_escalation' flag set to true when privileged containers, hostPath mounts, or cluster-admin bindings are detected

A manifest with spec.containers[].securityContext.privileged: true returns 'requires_immediate_escalation: false'

Submit a manifest with a privileged container; assert that the top-level escalation flag is true and the finding severity is CRITICAL

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON output schema, require CVE references for known misconfigurations, include namespace and cluster context in the input, and wire the output into a ticketing system. Add retry logic for malformed JSON.

Prompt modification

Add to [CONSTRAINTS]: Output must validate against the provided JSON schema. Include a 'review_id' field matching the input manifest hash. If a finding maps to a known CVE or MITRE ATT&CK technique, include the reference.

Watch for

  • Silent format drift when the model adds extra fields outside the schema
  • False positives on namespace-scoped resources that appear overprivileged without cluster-wide context
  • Missing human review step before auto-opening tickets
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.