Kubernetes penetration testing playbook. Use when targeting Kubernetes clusters via API server, RBAC enumeration, service account abuse, etcd access, Kubelet API, pod escape, cloud-specific metadata, admission webhook bypass, and registry secrets.
Detected risks:
An expert playbook for attacking Kubernetes clusters end to end. It walks through API server access (anonymous checks on ports 6443/8443/8080, service-account bearer tokens from inside a pod, and kubeconfig/certificate auth from common locations like /etc/kubernetes/admin.conf), then RBAC enumeration using kubectl auth can-i and SelfSubjectRulesReview, with a table of dangerous permissions (pods/exec, pods create, secrets get/list, serviceaccounts/token create, nodes/proxy, escalate, bind, impersonate) and the escalation each enables.
Subsequent sections cover service-account token abuse (locating and decoding the mounted JWT, dumping secrets, minting tokens, and deploying a privileged pod for node access), direct etcd access on port 2379 to extract secrets, and pod-escape vectors that map hostPID, hostNetwork, hostPath, and privileged containers to concrete commands like nsenter and chroot. It also covers the Kubelet API on ports 10250/10255, including exec that bypasses API-server RBAC and log reading, plus cloud-specific attacks against instance metadata on EKS, GKE, and AKS, including IMDSv1/IMDSv2 credential theft and EKS IRSA token locations.
It is intended for offensive security testing of clusters once you have some foothold or network reach, and emphasizes distinctions base models often miss, such as namespace-scoped vs cluster-scoped RBAC and the Kubelet's unauthenticated API. Related-routing links point to companion skills for container escape (pod-to-node), Linux privilege escalation and lateral movement once on a node, security-control bypass when Pod Security Standards or seccomp restrict actions, and SSRF for reaching the API server or cloud metadata indirectly.
Read the mounted service-account token and CA at /var/run/secrets/kubernetes.io/serviceaccount/, then send the token as a Bearer header to https://kubernetes.default.svc.
Critical ones include pods/exec, creating pods, get/list on secrets, serviceaccounts/token create, and escalate, bind, or impersonate; nodes/proxy is rated high for reaching the Kubelet.
AWS EKS, GCP GKE, and Azure AKS, including IMDSv1/IMDSv2 metadata credential theft and EKS-specific IRSA token locations.
On ports 10250/10255 it can allow anonymous pod listing, reading container logs, and exec into pods, which bypasses API-server RBAC.
Once you need to break out of a compromised pod to the underlying node; this skill gives quick K8s-specific vectors and routes detailed escape chains to the container-escape-techniques skill.
Quick Setup:
.claude/skills/Repository
yaklang/hack-skills