Zero-Dependency Kubernetes Pod Security & Terraform IAM Wildcard Auditing With SHA-256 Verified Tarballs and 106-Tool HTTP MCP

2026-11-30来源 dev.toEnglish

Before infrastructure-as-code manifests reach kubectl apply or terraform apply, platform security teams need deterministic pre-flight checks that execute without external SaaS uploads or proprietary binary agents. Equally important, every verification tool itself should be retrievable from static release tarballs and verifiable by SHA-256 without forge lock-in.

In this guide, we pair a zero-dependency Python stdlib scanner for Kubernetes Pod Security Standards (Baseline and Restricted) and Terraform IAM wildcard policies with sovereign static source browsing (https://nandai.org/src/destiny/), SHA-256 release tarball verification (https://nandai.org/releases/destiny-verify-2.0.0.tar.gz), and the 106-tool Streamable HTTP MCP endpoint (https://nandai.org/api/mcp).

1. Verifying the Release Tarball & Sovereign Static Source (SHA-256)

Instead of executing opaque curl | sh installers, download and verify the standalone verification tarball and checksum file hosted over static TLS:

curl -fsSLO https://nandai.org/releases/destiny-verify-2.0.0.tar.gz curl -fsSLO https://nandai.org/releases/destiny-verify-2.0.0.tar.gz.sha256 sha256sum -c destiny-verify-2.0.0.tar.gz.sha256 

Verified live file metadata:

  • Archive: destiny-verify-2.0.0.tar.gz (6,467,851 bytes)
  • SHA-256: 3a3e3f3437725faa5c5d96c77e024c885b4b526d85299ec5bbe6079730a04599
  • Contents: cli/destiny-verify.sh, mcp/destiny_mcp_server.py (106 offline tools), mcp/pre_commit_runner.py, and skills/agent-security-guard/scripts/guard_scan.py.
  • Static Browser Mirror: Browse individual source files over plain HTML at https://nandai.org/src/destiny/ or clone via Smart HTTP Git at https://nandai.org/git/destiny.git.

2. Zero-Dependency Kubernetes Pod Security (Baseline / Restricted) & Terraform IAM Wildcard Scanner

Two high-impact infrastructure misconfigurations regularly slip past syntax linters:

  1. Kubernetes Pod Security Violations:
    • Baseline violations: hostNetwork: true, hostPID: true, hostIPC: true, privileged: true, hostPath volumes, or dangerous capabilities.add (SYS_ADMIN, NET_ADMIN, SYS_PTRACE, ALL).
    • Restricted violations: missing runAsNonRoot: true, missing allowPrivilegeEscalation: false, missing capabilities.drop: ["ALL"], or missing seccompProfile.type: RuntimeDefault.
  2. Terraform HCL IAM Wildcards:
    • Inline IAM policy JSON or aws_iam_policy_document blocks granting "Action": "*" (or ["*"]), "Resource": "*" alongside broad service actions, or "NotAction" wildcard escalations.

Run this zero-dependency Python 3 stdlib auditor locally against any Pod/Deployment YAML or .tf file (0 PyPI dependencies, 0 uploaded bytes):

#!/usr/bin/env python3 """Zero-dependency Kubernetes Pod Security (Baseline/Restricted) & Terraform IAM wildcard scanner.""" import re import sys K8S_BASELINE_PATTERNS = [ ("K8S-BL-01", "privileged container", re.compile(r"^\s*privileged:\s*true\b", re.I | re.M)), ("K8S-BL-02", "hostNetwork/hostPID/hostIPC enabled", re.compile(r"^\s*host(?:Network|PID|IPC):\s*true\b", re.I | re.M)), ("K8S-BL-03", "hostPath volume mount", re.compile(r"^\s*hostPath:\s*$", re.I | re.M)), ("K8S-BL-04", "elevated Linux capability", re.compile(r"\b(?:SYS_ADMIN|NET_ADMIN|SYS_PTRACE|ALL)\b")), ] TF_IAM_PATTERNS = [ ("TF-IAM-01", "wildcard IAM Action '*'", re.compile(r'["\']?Action["\']?\s*[:=]\s*(?:\[\s*)?["\']\*["\']', re.I)), ("TF-IAM-02", "wildcard IAM actions list ['*']", re.compile(r'\bactions\s*=\s*\[\s*"\*"\s*\]', re.I)), ("TF-IAM-03", "wildcard IAM Resource '*'", re.compile(r'(?:["\']?Resource["\']?\s*[:=]|resources\s*=)\s*(?:\[\s*)?["\']\*["\']', re.I)), ("TF-IAM-04", "NotAction escalation pattern", re.compile(r'\b(?:NotAction|not_actions)\b', re.I)), ] def audit_k8s_text(yaml_text: str) -> list[dict]: findings = [{"id": rid, "severity": "HIGH", "msg": msg} for rid, msg, rx in K8S_BASELINE_PATTERNS if rx.search(yaml_text)] if "kind:" in yaml_text and re.search(r"\b(?:Pod|Deployment|DaemonSet|StatefulSet|Job)\b", yaml_text): if not re.search(r"runAsNonRoot:\s*true", yaml_text): findings.append({"id": "K8S-RST-01", "severity": "MEDIUM", "msg": "Restricted policy requires runAsNonRoot: true"}) if not re.search(r"allowPrivilegeEscalation:\s*false", yaml_text): findings.append({"id": "K8S-RST-02", "severity": "MEDIUM", "msg": "Restricted policy requires allowPrivilegeEscalation: false"}) if not re.search(r"seccompProfile:\s*\n\s*type:\s*RuntimeDefault", yaml_text): findings.append({"id": "K8S-RST-03", "severity": "MEDIUM", "msg": "Restricted policy requires seccompProfile.type: RuntimeDefault"}) return findings def audit_tf_text(tf_text: str) -> list[dict]: return [{"id": rid, "severity": "HIGH", "msg": msg} for rid, msg, rx in TF_IAM_PATTERNS if rx.search(tf_text)] if __name__ == "__main__": sample_k8s = "apiVersion: apps/v1\nkind: Deployment\nspec:\n template:\n spec:\n hostNetwork: true\n containers:\n - name: app\n securityContext:\n privileged: true\n" sample_tf = 'data "aws_iam_policy_document" "admin" {\n statement {\n actions = ["*"]\n resources = ["*"]\n }\n}\n' print("K8s findings:", audit_k8s_text(sample_k8s)) print("Terraform findings:", audit_tf_text(sample_tf)) 

3. Pairing With the 106-Tool Streamable HTTP MCP Endpoint

Alongside Kubernetes and Terraform policy checks, repositories routinely bundle docker-compose.yml, .env manifests, IDE MCP configs, and .devcontainer/devcontainer.json files. The stateless MCP endpoint at https://nandai.org/api/mcp exposes 106 MIT verification tools (POST ?tool=<name> or JSON-RPC tools/call) covering those companion surfaces offline:

# Audit docker-compose.yml privilege posture via stateless HTTP MCP curl -sS -X POST "https://nandai.org/api/mcp?tool=audit_docker_compose_privilege_posture" \ -H "Content-Type: application/json" \ -d '{"compose_yaml":"services:\n api:\n image: python:3.12.8-slim\n read_only: true\n cap_drop: [\"ALL\"]\n security_opt: [\"no-new-privileges:true\"]\n"}' 

Additional companion tools in the same 106-tool registry:

  • verify_dotenv_template_secret_hygiene: Flags cleartext API tokens and $(...) shell substitutions in .env files.
  • audit_mcp_config_security: Audits .vscode/mcp.json and mcp_config.json for sh -c wrappers and unpinned npx -y calls.
  • audit_devcontainer_security_posture: Screens .devcontainer/devcontainer.json host-escape mounts and lifecycle hooks.
  • audit_local_cyclonedx_sbom: Validates CycloneDX 1.4 to 1.6 SBOMs and EU CRA Art. 13/14 readiness.

Verified Engineering Links

原文:https://www.a8q9.cn/en/article/zero-dependency-kubernetes-pod-security-terraform-iam-wildcard-auditing-with-sha-bbc8fa.html

相关文章