Kubernetes workloads routinely reach production through Helm charts whose defaults look harmless until helm template renders privileged: true, host namespaces, or :latest image tags across dozens of templates. Checking security posture before cluster admission catches privilege escalation in local CI without uploading proprietary manifests to external SaaS scanners.
In this guide, we implement a zero-dependency Python Helm values.yaml auditor (audit_helm_chart_values_security) and pair it with the live audit_kubernetes_pod_security_baseline tool (#107 in the 108-tool stateless MCP registry documented at https://nandai.org/stacks/appsec-devsecops-eu-cra-release-stack).
1. Zero-Dependency audit_helm_chart_values_security Auditor
Helm values.yaml files encode security defaults that downstream templates inherit (securityContext, podSecurityContext, hostNetwork, resources.limits, and image tags). Running deterministic regex and structural checks in Python standard library flags high-risk overrides in milliseconds with zero PyPI packages:
#!/usr/bin/env python3 """Zero-dependency Helm values.yaml privilege & PSS Restricted auditor.""" import json import re def audit_helm_chart_values_security(values_yaml: str) -> dict: if not values_yaml or not values_yaml.strip(): return {"valid": False, "score": 0, "grade": "F", "findings": ["EMPTY_VALUES"]} findings = [] score = 100 checks = [ ("HELM_PRIVILEGED_CONTAINER", "CRITICAL", 30, r"(?im)^\s*privileged\s*:\s*true\b"), ("HELM_HOST_NAMESPACE", "CRITICAL", 25, r"(?im)^\s*(hostNetwork|hostPID|hostIPC)\s*:\s*true\b"), ("HELM_PRIVILEGE_ESCALATION", "HIGH", 20, r"(?im)^\s*allowPrivilegeEscalation\s*:\s*true\b"), ("HELM_HOST_PATH_MOUNT", "HIGH", 15, r"(?im)^\s*hostPath\s*:"), ("HELM_ROOT_USER", "HIGH", 15, r"(?im)^\s*(runAsNonRoot\s*:\s*false|runAsUser\s*:\s*0)\b"), ("HELM_MUTABLE_LATEST_TAG", "MEDIUM", 10, r"(?im)^\s*tag\s*:\s*[\"']?latest[\"']?\s*$"), ] for fid, sev, pen, pat in checks: if re.search(pat, values_yaml): score -= pen findings.append({"id": fid, "severity": sev, "penalty": pen}) if not re.search(r"(?im)readOnlyRootFilesystem\s*:\s*true\b", values_yaml): score -= 10 findings.append({"id": "HELM_WRITABLE_ROOTFS", "severity": "MEDIUM", "penalty": 10}) if not re.search(r"(?im)type\s*:\s*RuntimeDefault\b", values_yaml): score -= 10 findings.append({"id": "HELM_MISSING_SECCOMP", "severity": "MEDIUM", "penalty": 10}) if not re.search(r"(?im)^\s*limits\s*:", values_yaml): score -= 10 findings.append({"id": "HELM_MISSING_RESOURCE_LIMITS", "severity": "LOW", "penalty": 10}) score = max(0, score) grade = "A+" if score >= 95 else ("A" if score >= 85 else ("C" if score >= 60 else "F")) return {"valid": score >= 80, "score": score, "grade": grade, "findings": findings, "bytes_uploaded": 0} if __name__ == "__main__": hardened = """image: tag: "2.0.0@sha256:05f9b8a6" podSecurityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true resources: limits: cpu: 500m memory: 512Mi """ print(json.dumps(audit_helm_chart_values_security(hardened), indent=2)) Tested locally against an insecure values.yaml (privileged: true, hostNetwork: true, allowPrivilegeEscalation: true, runAsNonRoot: false, tag: latest), the auditor drops the posture to score: 0, grade: "F", valid: false across 8 concrete findings. Against the hardened snippet above, it returns score: 100, grade: "A+", valid: true, bytes_uploaded: 0.
2. Auditing Rendered Templates Against Pod Security Standards (#107)
Because Helm values.yaml directives transform through Go templates into Deployment, StatefulSet, DaemonSet, Job, and CronJob objects, pipe helm template output into a rendered Kubernetes PSS Restricted auditor.
The live stateless JSON-RPC 2.0 endpoint at https://nandai.org/api/mcp exposes 108 read-only MIT tools (OpenAPI 3.1.0 descriptor at https://nandai.org/api/mcp?format=openapi), including Tool #107 (audit_kubernetes_pod_security_baseline):
curl -sS -X POST https://nandai.org/api/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "audit_kubernetes_pod_security_baseline", "arguments": {"sample": true, "profile": "restricted"} } }' Live execution returns ok: true, profile: "restricted", workloads_count: 1, privileged_containers_count: 0, host_namespaces_count: 0, host_path_mounts_count: 0, mutable_images_count: 0, score: 100, grade: "A+", and bytes_uploaded: 0.
To audit proprietary rendered charts strictly offline with zero network egress, clone the MIT repository from https://nandai.org/git/destiny.git/ or download the pinned tarball https://nandai.org/releases/destiny-verify-2.0.0.tar.gz (6,511,290 B, SHA-256 05f9b8a62d2e2d7bd554c609fc4f18e59f171408aa0c6d75a17743b9c4a09763) and run cli/destiny-verify.sh k8s-pss or python3 mcp/destiny_mcp_server.py over local stdio.
3. Hardened Baseline Checklist for Helm Chart Releases
| Control | Vulnerable Default | Hardened Restricted Target |
|---|---|---|
| Container Escalation | allowPrivilegeEscalation: true or omitted | allowPrivilegeEscalation: false + capabilities.drop: ["ALL"] |
| Pod Identity & Sandbox | runAsUser: 0 / missing seccompProfile | runAsNonRoot: true + seccompProfile.type: RuntimeDefault |
| Host Isolation | hostNetwork: true / hostPath: volumes | hostNetwork/hostPID/hostIPC: false + emptyDir / CSI volumes |
| Filesystem & Quotas | Writable / + unbounded CPU/RAM | readOnlyRootFilesystem: true + explicit resources.limits |
| Image Provenance | tag: latest | Semantic tag pinned with immutable @sha256: digest |
Verified Engineering Resources
- AppSec & EU CRA Release Stack:
https://nandai.org/stacks/appsec-devsecops-eu-cra-release-stack - Live
108-Tool Streamable HTTP MCP:https://nandai.org/api/mcp - OpenAPI
3.1.0Schema Descriptor (111Schemas):https://nandai.org/api/mcp?format=openapi - OpenAPI / REST / MCP Bridge Spec:
https://nandai.org/.well-known/openapi-rest-mcp-bridge-spec.json - Platform Security Architecture:
https://nandai.org/security - Pinned MIT CLI & MCP Release Tarball:
https://nandai.org/releases/destiny-verify-2.0.0.tar.gz - Sovereign Git Origin:
https://nandai.org/git/destiny.git/ - Zenodo Archival Record:
https://doi.org/10.5281/zenodo.24642737

