leoyeai/openclaw-master-skills/phy-k8s-security-audit

Claude Code and agent skill by leoyeai/openclaw-master-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Kubernetes manifest security auditor (CIS Kubernetes Benchmark). Scans all YAML/JSON manifests in your repository for privileged containers, hostNetwork/hostPID/hostIPC, dangerous hostPath mounts, missing resource limits/probes, latest image tags, RBAC over-permission (cluster-admin bindings, wildcard verbs), secrets in env vars, missing NetworkPolicy, missing seccomp/AppArmor profiles. Maps findings to CIS Benchmark controls and PSS (Pod Security Standards). Zero dependencies beyond PyYAML. Zero competitors on ClawHub.

Install

npx vskill@latest install leoyeai/openclaw-master-skills/phy-k8s-security-audit

SKILL.md

The same SKILL.md was published earlier as leoyeai/openclaw-master-skills/phy-k8s-security-audit.

phy-k8s-security-audit

Static security auditor for Kubernetes YAML manifests. Scans every Deployment, StatefulSet, DaemonSet, Pod, Job, CronJob, Role, ClusterRole, RoleBinding, ClusterRoleBinding, ServiceAccount, and NetworkPolicy in your repository against the CIS Kubernetes Benchmark v1.9 and Pod Security Standards (PSS). No cluster access required — works entirely on local manifest files.

Why Manifest Auditing Matters

  • Tesla's Kubernetes cluster was cryptojacked because their dashboard had no auth and pods ran privileged
  • Attackers with access to one container can escape to the node via privileged: true or hostPath mounts
  • Over-permissive RBAC (cluster-admin) is the #1 post-exploit persistence technique
  • automountServiceAccountToken: true (the default) leaks credentials into every pod

Checks: Pod / Container Level

CheckSeverityCIS / PSS
privileged: trueCRITICALCIS 5.2.1 / PSS Restricted
allowPrivilegeEscalation: true or missing (default true)HIGHCIS 5.2.5 / PSS Restricted
runAsNonRoot missing or falseHIGHCIS 5.2.6 / PSS Baseline
runAsUser: 0 (root)HIGHCIS 5.2.6
hostNetwork: trueHIGHCIS 5.2.4 / PSS Baseline
hostPID: trueHIGHCIS 5.2.2 / PSS Baseline
hostIPC: trueHIGHCIS 5.2.3 / PSS Baseline
hostPath volume mountHIGHCIS 5.2.11
capabilities.add with dangerous caps (SYS_ADMIN, NET_ADMIN, ALL)CRITICALCIS 5.2.8
Missing capabilities.drop: [ALL]MEDIUMCIS 5.2.7 / PSS Restricted
Missing resource requests and limitsMEDIUMCIS 5.2.13
image: *:latest or no tagMEDIUMBest practice
imagePullPolicy: Never with mutable tagMEDIUMBest practice
Missing readinessProbeLOWBest practice
Missing livenessProbeLOWBest practice
Secrets in env values (plaintext)HIGHCIS 5.4.1
Missing seccompProfileMEDIUMCIS 5.7.2 / PSS Restricted
Missing securityContext entirelyMEDIUMCIS 5.7.1
readOnlyRootFilesystem: false (or missing)MEDIUMPSS Restricted

Checks: RBAC Level

CheckSeverityCIS
ClusterRoleBinding to cluster-adminCRITICALCIS 5.1.1
Role/ClusterRole with verbs: ["*"]HIGHCIS 5.1.3
Role/ClusterRole with resources: ["*"]HIGHCIS 5.1.3
Role with secrets GET/LIST permissionHIGHCIS 5.1.2
ServiceAccount with automountServiceAccountToken: true in non-system namespaceMEDIUMCIS 5.1.5
Default service account used (no explicit serviceAccountName)MEDIUMCIS 5.1.5

Checks: Network Level

CheckSeverityCIS
No NetworkPolicy in namespace (detected from file dir)HIGHCIS 5.3.2
NetworkPolicy podSelector: {} (applies to all pods) without ingress rulesMEDIUMBest practice
Service type NodePort without explicit justification commentLOWCIS 5.4.2
Service type LoadBalancer exposing non-HTTP portMEDIUMCIS 5.4.2

Pod Security Standards Classification

Each Pod/Deployment spec is classified against PSS:

ProfileDescription
PrivilegedNo restrictions — flag all workloads at this level
BaselineNo privileged, no host namespaces, no hostPath — minimum for most apps
RestrictedAll of Baseline + non-root, no privilege escalation, seccomp, drop ALL caps

Implementation

python
#!/usr/bin/env python3
"""
phy-k8s-security-audit — CIS Kubernetes Benchmark manifest scanner
Usage: python3 audit_k8s.py [path] [--json] [--ci] [--min-severity HIGH]
Requires: pip install pyyaml (almost always already installed)
"""
import argparse
import json
import os
import re
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Optional
try:
import yaml
HAS_YAML = True
except ImportError:
HAS_YAML = False
print("Warning: PyYAML not found. Install with: pip install pyyaml", file=sys.stderr)
sys.exit(1)
CRITICAL, HIGH, MEDIUM, LOW = "CRITICAL", "HIGH", "MEDIUM", "LOW"
SEV_ORDER = {CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3}
ICONS = {CRITICAL: "🔴", HIGH: "🟠", MEDIUM: "🟡", LOW: "⚪"}
# Capabilities that are effectively root
DANGEROUS_CAPS = {
"SYS_ADMIN", "NET_ADMIN", "SYS_PTRACE", "SYS_MODULE", "SYS_RAWIO",
"ALL", "SYSLOG", "DAC_READ_SEARCH", "LINUX_IMMUTABLE",
"NET_BROADCAST", "IPC_LOCK", "WAKE_ALARM", "BLOCK_SUSPEND",
}
# RBAC verbs that indicate over-permission
SENSITIVE_RBAC_VERBS = {"*", "create", "delete", "deletecollection", "patch", "update"}
SECRET_VERBS = {"get", "list", "watch", "*"}
@dataclass
class Finding:
file: str
resource_kind: str
resource_name: str
check_id: str
severity: str
title: str
detail: str
remediation: str
cis_ref: Optional[str] = None
pss_profile: Optional[str] = None
def get_name(obj: dict) -> str:
return obj.get("metadata", {}).get("name", "<unnamed>")
def get_namespace(obj: dict) -> str:
return obj.get("metadata", {}).get("namespace", "default")
def check_container_security(
container: dict,
file: str,
kind: str,
resource_name: str,
is_init: bool = False,
) -> list[Finding]:
findings = []
sc = container.get("securityContext", {})
cname = container.get("name", "<unnamed>")
label = f"{resource_name}/{cname}" + (" (init)" if is_init else "")
def add(check_id, sev, title, detail, remediation, cis=None, pss=None):
findings.append(Finding(file, kind, label, check_id, sev, title, detail, remediation, cis, pss))
# Privileged container
if sc.get("privileged") is True:
add("C001", CRITICAL, "Privileged container",
f"securityContext.privileged: true — container has full host access",
"Remove privileged: true. Use specific capabilities instead.",
"CIS 5.2.1", "PSS Restricted")
# Privilege escalation
if sc.get("allowPrivilegeEscalation") is True:
add("C002", HIGH, "Privilege escalation allowed",
"allowPrivilegeEscalation: true — setuid binaries can gain root",
"Set allowPrivilegeEscalation: false in securityContext.",
"CIS 5.2.5", "PSS Restricted")
elif "allowPrivilegeEscalation" not in sc:
# Default is true — flag unless privileged is already flagged
if not sc.get("privileged"):
add("C002b", MEDIUM, "allowPrivilegeEscalation not explicitly set (defaults to true)",
"Default allows setuid escalation. Explicitly disable.",
"Add allowPrivilegeEscalation: false to securityContext.",
"CIS 5.2.5")
# Root user
if sc.get("runAsUser") == 0:
add("C003", HIGH, "Container runs as root (runAsUser: 0)",
"Explicitly running as UID 0 — root in container maps to root on host in many configs.",
"Use a non-root UID: runAsUser: 1000 or higher.",
"CIS 5.2.6")
elif not sc.get("runAsNonRoot") and "runAsUser" not in sc:
add("C004", MEDIUM, "runAsNonRoot not enforced",
"Neither runAsNonRoot: true nor a non-zero runAsUser is set.",
"Add runAsNonRoot: true to securityContext.",
"CIS 5.2.6", "PSS Baseline")
# Capabilities
caps = sc.get("capabilities", {})
added_caps = caps.get("add", [])
for cap in added_caps:
if cap.upper() in DANGEROUS_CAPS:
add("C005", CRITICAL, f"Dangerous capability added: {cap}",
f"capabilities.add: [{cap}] grants near-root privileges.",
f"Remove {cap} from capabilities.add. Use least-privilege capabilities only.",
"CIS 5.2.8", "PSS Baseline")
if "drop" not in caps or "ALL" not in [c.upper() for c in caps.get("drop", [])]:
add("C006", MEDIUM, "capabilities.drop: [ALL] missing",
"Not dropping all Linux capabilities — container retains default set.",
"Add capabilities.drop: [ALL] and add back only what's needed.",
"CIS 5.2.7", "PSS Restricted")
# Read-only root filesystem
if not sc.get("readOnlyRootFilesystem"):
add("C007", MEDIUM, "readOnlyRootFilesystem not set",
"Writable root filesystem — malware can install binaries/modify configs in-container.",
"Set readOnlyRootFilesystem: true; use emptyDir or PVC for writable paths.",
"PSS Restricted")
# seccompProfile
if "seccompProfile" not in sc:
add("C008", MEDIUM, "seccompProfile not set",
"No seccomp profile — container can make any syscall.",
"Add seccompProfile: {type: RuntimeDefault} or a custom profile.",
"CIS 5.7.2", "PSS Restricted")
# Resource limits
resources = container.get("resources", {})
limits = resources.get("limits", {})
requests = resources.get("requests", {})
if not limits.get("memory") or not limits.get("cpu"):
add("C009", MEDIUM, "Missing resource limits",
f"No CPU/memory limits — container can starve other pods (DoS).",
"Set resources.limits.cpu and resources.limits.memory.",
"CIS 5.2.13")
if not requests.get("memory") or not requests.get("cpu"):
add("C010", LOW, "Missing resource requests",
"No CPU/memory requests — scheduler cannot make accurate placement decisions.",
"Set resources.requests.cpu and resources.requests.memory.")
# Image tag
image = container.get("image", "")
if image.endswith(":latest") or (":" not in image.split("/")[-1]):
add("C011", MEDIUM, "Image uses 'latest' tag or no tag",
f"Image '{image}' — non-specific tags break reproducibility and rollbacks.",
"Pin images to a specific digest: image: myapp:v1.2.3@sha256:...")
# Secrets in env
for env in container.get("env", []):
val = str(env.get("value", ""))
name = env.get("name", "")
if re.search(r'(?i)(password|secret|key|token|credential|private)', name) and val:
add("C012", HIGH, f"Secret in plain env var: {name}",
f"Env var '{name}' contains a secret value in plaintext.",
"Use secretKeyRef: kubectl create secret generic my-secret --from-literal=key=value\n"
"Then env: [{name: MY_SECRET, valueFrom: {secretKeyRef: {name: my-secret, key: key}}}]",
"CIS 5.4.1")
# Probes
if not container.get("readinessProbe"):
add("C013", LOW, "Missing readinessProbe",
"No readinessProbe — pod may receive traffic before it's ready.",
"Add readinessProbe with appropriate httpGet/tcpSocket/exec.")
if not container.get("livenessProbe"):
add("C014", LOW, "Missing livenessProbe",
"No livenessProbe — stuck processes won't be restarted automatically.",
"Add livenessProbe with appropriate httpGet/tcpSocket/exec.")
return findings
def check_pod_spec(pod_spec: dict, file: str, kind: str, resource_name: str) -> list[Finding]:
findings = []
sc = pod_spec.get("securityContext", {})
name = resource_name
def add(check_id, sev, title, detail, remediation, cis=None, pss=None):
findings.append(Finding(file, kind, name, check_id, sev, title, detail, remediation, cis, pss))
# Host namespaces
if pod_spec.get("hostNetwork"):
add("P001", HIGH, "hostNetwork: true",
"Pod shares host network namespace — can sniff all node traffic, bind privileged ports.",
"Remove hostNetwork: true. Use ClusterIP services for internal communication.",
"CIS 5.2.4", "PSS Baseline")

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
2,157
Repository forks
324
7-day trend score
43

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/leoyeai/openclaw-master-skills/phy-k8s-security-audit/badge)](https://verified-skill.com/skills/leoyeai/openclaw-master-skills/phy-k8s-security-audit)

Something wrong with this skill or its page? Tell us.