Attackers escape a container to compromise a Kubernetes cluster by abusing a pod's configuration, a privileged pod, a hostPath mount of the node or the container runtime socket, a host namespace like hostPID, or a dangerous Linux capability, with runtime bugs such as runc CVE-2024-21626 as the fallback. Pwned Labs teaches this full chain hands-on in live clusters, through Academy labs and the Kubernetes Attack and Defense bootcamp that leads to the KRTP certification. Once on the node, the kubelet credentials and the node's cloud identity turn one pod into the whole cluster and often the cloud account behind it.
Kubernetes runs production workloads across all three major clouds, and it is often the platform that red teamers and penetration testers understand least. That gap is the point. The API server sits in front of a datastore, RBAC decides who can do what, and service account tokens and node identity quietly bridge the cluster to the cloud account behind it. Those mechanics create attack paths that go unnoticed by testers who treat a cluster like a normal network. This guide explains how Kubernetes clusters are actually attacked, the methodology and tools a professional uses, and how to learn the discipline to a level an employer can verify.
What is Kubernetes penetration testing?
Kubernetes penetration testing is a controlled, authorized security assessment that simulates how an attacker would compromise a Kubernetes cluster and the infrastructure around it. It goes beyond scanning container images for known vulnerabilities. A real test looks at how identity, access control, workload isolation, and cloud integration combine into exploitable attack paths. Most engagements are grey box: the tester is given access to a container or a low privilege account, which mirrors the most common real world starting point, a single compromised workload. From there the goal is to prove how far that foothold can be taken. Pwned Labs assesses exactly this, a full compromise of a live cluster and the cloud account behind it, in the hands-on KRTP certification exam.
The Kubernetes attack surface
A cluster introduces a set of components that each carry their own risk. Understanding them is the foundation of any assessment.
- The API server. The control plane front door. Every action is an authenticated, authorized API call, so an exposed or weakly protected API server is a direct route to the cluster.
- RBAC. Role-based access control decides which identities can perform which verbs on which resources. Overly permissive roles are the single most common path to cluster compromise.
- Service account tokens. Pods are issued tokens that authenticate to the API server. A mounted token combined with permissive RBAC is a ready-made privilege escalation primitive.
- Pods, containers, and nodes. Workloads share the kernel of the node they run on. Privileged containers, host path mounts, and host namespaces let an attacker break out of a container and take the node.
- etcd and secrets. The cluster datastore holds every secret. Reaching it, directly or through the API server, exposes credentials for the whole environment.
- Admission controllers and webhooks. These intercept API requests and can enforce or, if abused, subvert policy. They are also a persistence and tampering target. See what a Kubernetes admission controller is for detail.
- The cloud identity bridge. On EKS, GKE, and AKS, a pod can reach the cloud metadata service and assume a cloud role through IRSA, EKS Pod Identity, GKE Workload Identity, or AKS workload identity. This is how a cluster foothold becomes a cloud account compromise.
Pwned Labs turns this surface into a hands-on exercise in its Exploit Kubernetes Overly Permissive RBAC lab, where a service account token and permissive RBAC become cluster control.
How Kubernetes clusters are actually compromised
Rather than a list of features, it helps to follow the chain that a real attack takes. A Kubernetes penetration test is judged on how completely a tester can walk this path in a live cluster.
- Enumerate the cluster from an unauthenticated external position and from a low privilege pod foothold, mapping the API server, namespaces, workloads, and what the current identity is allowed to do.
- Analyze the service account token and RBAC to find verbs that are equivalent to cluster-admin, for example the ability to create pods, exec into pods, read secrets, or impersonate other accounts.
- Escalate through RBAC misconfigurations to cluster-admin, turning a single workload compromise into full control of the cluster.
- Escape the container to the node by abusing a privileged pod, a host path mount, or host namespace access, then dump every secret the cluster holds.
- Pivot into the cloud account by reaching the instance metadata service from a pod and abusing node IMDS credentials, IRSA, or EKS Pod Identity on EKS, and workload identity on GKE and AKS.
- Establish persistence in the cluster and in the cloud, weaponizing admission webhooks, and reading Kubernetes audit logs to understand exactly what a defender would see.
Pwned Labs runs several links in this chain as hands-on labs, including exploiting overly permissive RBAC, escalating from a server side template injection into EKS, and going from prototype pollution to an EKS takeover.
How do attackers escape a container to compromise a Kubernetes cluster?
Container escape is the step that turns a foothold in one pod into control of the node and everything scheduled on it. A container is a process with namespaces and cgroups wrapped around it, so an escape is any path that lets that process act outside those boundaries. In practice the paths are well known, and almost all of them come from configuration rather than exotic exploits.
- Privileged pods. A pod running with
privileged: truegets the host's devices and capabilities. From there an attacker can mount the node's disk, read the kubelet's credentials, and run commands as root on the host. - Host namespaces and mounts.
hostPIDlets a process see and enter host processes withnsenter. AhostPathmount of/, or of the container runtime socket (docker.sockorcontainerd.sock), hands over the host file system or the ability to start a new privileged container. - Dangerous capabilities.
CAP_SYS_ADMINon a cgroup v1 host enables the classicrelease_agentescape, andCAP_SYS_PTRACEcombined withhostPIDallows injecting into host processes. - Runtime and kernel bugs. When the configuration is sound, attackers reach for software flaws such as runc CVE-2024-21626 (Leaky Vessels, January 2024), which let a container image or an exec break out through a leaked file descriptor.
Once on the node the chain continues. The kubelet's client certificate and the node's cloud instance identity, reachable through the metadata service unless it is blocked, give access to every pod on that node and often to the cloud account itself. That is why a Kubernetes penetration test does not stop at the escape: it follows the identity into the cloud, which is exactly the path the Pwned Labs Escalate from SSJI to EKS lab walks.
Common Kubernetes misconfigurations and vulnerabilities
Most findings in a Kubernetes penetration test are misconfigurations rather than software bugs, though both matter. Pwned Labs works the container-escape and RBAC-abuse routes end to end in its Escalate from Prototype Pollution to EKS Takeover lab.
- Overly permissive RBAC. Roles that grant dangerous verbs such as create on pods, pods/exec, get on secrets, or impersonate are effectively cluster-admin. Since Kubernetes v1.22, the tokens projected into pods are bound and short lived by default, and since v1.24 the control plane no longer auto-generates the legacy long lived Secret tokens, but a workload that can create pods or read secrets can still escalate.
- Privileged and over-permissioned pods. Containers run with the privileged flag, extra Linux capabilities, host path volumes, or host network and PID namespaces provide a straightforward container escape to the node.
- Exposed control plane and kubelet. An API server, kubelet, or dashboard reachable without strong authentication is a direct entry point.
- Over-mounted service account tokens. Default automounting of tokens into workloads that do not need API access widens the blast radius of any single container compromise.
- Vulnerable cluster components. Ingress controllers, admission webhooks, and add-ons expand the attack surface. The 2025 IngressNightmare vulnerabilities in the Ingress NGINX controller, chained through the admission controller, allowed unauthenticated remote code execution and cluster secret access on exposed clusters, a reminder that a single add-on can compromise the whole environment.
Real-world Kubernetes compromises
The chain above is not theoretical. Three public incidents, years apart and against well-resourced targets, show each link being used.
Tesla, February 2018
Researchers at RedLock found a Tesla Kubernetes console reachable from the internet with no password. Inside one pod sat AWS credentials for an account holding an S3 bucket of telemetry data, and the attackers were already running a cryptominer from a pod, pointed at an unlisted mining pool behind Cloudflare on a non-standard port to stay quiet. An exposed control plane, a credential inside a workload, and a cloud pivot, all from one unauthenticated endpoint (Infosecurity Magazine).
Dero cryptojacking campaign, March 2023
CrowdStrike reported the first cryptojacking campaign built specifically for Kubernetes. The operators scanned for API servers exposed to the internet with anonymous authentication enabled, then used that access to deploy a DaemonSet named proxy-api that placed a Dero miner, disguised as the pause container, on every node. No vulnerability was involved. A single setting, --anonymous-auth=true on an internet-facing API server, was enough to hand over the whole cluster (CrowdStrike).
IngressNightmare, March 2025
Wiz disclosed CVE-2025-1974 and three related flaws in the Ingress NGINX Controller, rated 9.8. The validating admission webhook accepted unauthenticated requests on the pod network, and a crafted Ingress object injected directives into the NGINX configuration that the controller then tested with the NGINX binary, giving remote code execution inside a component that can read secrets in every namespace. The lesson for testers is that admission controllers sit at the heart of the cluster, and an exposed one is a cluster takeover (Wiz Research).
The Pwned Labs Kubernetes Attack and Defense bootcamp rebuilds these attack chains in live clusters, together with the telemetry a defender would see.
Kubernetes penetration testing methodology
A repeatable methodology keeps an assessment thorough and defensible. A typical Kubernetes engagement moves through these phases.
- Scoping and reconnaissance. Agree the authorized scope, then map exposed endpoints, the API server, and cluster metadata.
- Enumeration and access review. From the given foothold, enumerate namespaces, workloads, and the effective permissions of the current identity.
- Privilege escalation. Turn permissive RBAC and mounted tokens into higher privilege, up to cluster-admin.
- Lateral movement and container escape. Move between workloads and break out to the node where isolation is weak.
- Cloud pivot. Use node or workload identity to reach the cloud account and assess the blast radius beyond the cluster.
- Persistence and detection review. Understand what an attacker could leave behind, and what the cluster's audit logging and detections would catch.
- Reporting. Document the attack chain, the impact, and prioritized, practical remediation.
The Pwned Labs KRTP curriculum follows this same sequence, from enumeration through RBAC escalation and container escape to the cloud pivot.
Tools for Kubernetes penetration testing
Tooling supports the methodology, it does not replace it. The core toolkit includes:
- kubectl and curl for interacting with the API server and inspecting permissions, including kubectl auth can-i for effective access review.
- kdigger and peirates for in-cluster context discovery and escalation workflows during authorized testing.
- kube-bench for configuration and CIS benchmark posture, and k8scout for attack path analysis from a pod foothold. It maps RBAC, tokens, workloads and cloud identity bindings into escalation chains to cluster-admin, the node and the cloud account, each mapped to MITRE ATT&CK. kube-hunter still shows up in older guidance, but its last release was in 2022 and it is no longer maintained.
- Cloud provider tooling to enumerate the account once you pivot, since a Kubernetes test that stops at the cluster edge misses the real impact.
On the defensive side, the same testing informs guardrails such as least privilege RBAC, Pod Security Standards, and policy engines. You can see the defensive counterpart in the Pwned Labs securing Kubernetes with OPA Gatekeeper lab.
How do I secure a Kubernetes cluster against real attacks?
The defenses that matter are the ones that break the attack chain, so the most useful way to harden a cluster is to work through the chain in order and close each link.
- Close the front door. Never expose the API server or a dashboard to the internet without authentication. Disable anonymous auth, use OIDC or your cloud provider's IAM for access, and keep the control plane behind a private endpoint or an allowlist.
- Make RBAC least privilege real. Audit every binding to cluster-admin, remove wildcard verbs, and treat
geton secrets,createon pods,pods/exec, andimpersonateas admin-equivalent. SetautomountServiceAccountToken: falseon pods that do not call the API. - Enforce Pod Security Standards. Apply the restricted profile by default and block privileged pods,
hostPID,hostNetwork,hostPathmounts of sensitive paths, and added capabilities. This removes most container escape paths before an attacker lands. - Segment the network. Apply default-deny NetworkPolicies and open only the flows each workload needs, so a foothold in one namespace cannot freely reach the API server, the metadata service, or other tenants.
- Starve the cloud pivot. Block or filter the instance metadata service from pods (IMDSv2 with a hop limit of 1 on AWS, or a metadata proxy), and give workloads their own narrowly scoped cloud identities (IAM Roles for Service Accounts, Workload Identity, Managed Identity) instead of the node's role.
- Keep admission control strong and patched. Admission controllers and policy engines such as OPA Gatekeeper or Kyverno are where misconfigurations get stopped, but IngressNightmare shows they are also a target. Restrict who can reach webhooks and patch them promptly.
- Protect secrets. Encrypt secrets at rest, pull them from an external secrets manager where possible, and keep credentials out of images and environment variables.
- Watch and test. Turn on API audit logging, run runtime detection on nodes, and validate all of the above with an authorized Kubernetes penetration test rather than assuming the configuration holds.
Pwned Labs teaches these defenses from the attacker's side in the Kubernetes Attack and Defense bootcamp, so you can see which controls actually break the chain.
How do I learn Kubernetes penetration testing?
Kubernetes penetration testing is learned by doing it against real clusters, not by reading about features. This is the path we recommend, and the one the KRTP bootcamp follows.
- Get comfortable on Linux and with containers. You need the command line, and an understanding of how containers share a kernel. You do not need to be an expert.
- Learn Kubernetes fundamentals in a local cluster. Stand up minikube, read YAML and JSON fluently, and understand pods, services, namespaces, and RBAC.
- Study identity and access. Service account tokens, RBAC verbs, and how the API server authorizes requests are where most escalation happens.
- Attack a live cluster. Practice the full chain, enumeration to cluster-admin to node escape, in a cluster that is logging your activity, so you build blue team awareness as you go.
- Extend to managed Kubernetes. Learn how EKS, GKE, and AKS turn a service account token into a cloud credential, because that is where cluster compromise becomes cloud compromise.
- Validate with a hands-on certification. Prove the skill in a live assessment an employer can trust, rather than a multiple choice exam.
For practice environments, tools and courses beyond its own, Pwned Labs keeps an open list of Kubernetes pentesting labs, tools and training on GitHub. It covers vulnerable-by-design clusters such as Kubernetes Goat and Bad Pods, hosted CTF challenges such as Wiz's Cloud Security Championship, and tools such as Peirates and CDK.
Only ever test clusters you own or are explicitly authorized to assess. The techniques on this page are for professional, authorized security work.
Best Kubernetes security training and certification
The strongest Kubernetes security training is hands-on, offense-aware, and takes you all the way from a low privilege pod to the cloud account behind the cluster. The Pwned Labs Kubernetes Attack and Defense bootcamp is built to do exactly that. It starts from fundamentals in minikube and progresses into RBAC escalation, container escape, and cloud identity abuse across EKS, GKE, and AKS, then certifies you hands-on with the Kubernetes Red Team Professional (KRTP), a 24-hour, hands-on exam in a live cluster and the cloud account behind it, for $399 with two exam attempts. Because the labs run in production-like clusters with real telemetry, you also learn what defenders see, which is what separates a Kubernetes red teamer from someone who only ran a script. You do not need prior Kubernetes experience to start. For the wider curriculum, see the Pwned Labs Kubernetes and container security training overview. Our guide to choosing Kubernetes security training compares the main options and which one fits your goals.
KRTP compared to CKS
The two credentials solve different problems and complement each other.
| Aspect | KRTP | CKS |
|---|---|---|
| Orientation | Offense-led, with a strong blue-team detection focus | Defensive, hardening and operations |
| Format | Attack a live cluster, capture the flag | Configure and secure a cluster |
| Covers cloud pivot | Yes, EKS, GKE, and AKS identity abuse | No |
| Best for | Pentesters, red teamers, and the defenders and security engineers who want the attacker mindset to build detections | Platform and security engineers |
Ready to attack a live cluster? Explore the Kubernetes Attack and Defense bootcamp (KRTP).
Practice this at Pwned Labs
Pwned Labs runs these attack paths as hands-on labs in live Kubernetes clusters.
- Exploit Kubernetes Overly Permissive RBAC (Premium, Intermediate): from compromised credentials on an EC2 instance, abuse overly permissive Kubernetes RBAC to move laterally and gain root on the cluster.
- Escalate from SSJI to EKS (Premium, Beginner): chain server-side JavaScript injection through IAM and IDOR weaknesses to reach the Amazon EKS cluster behind the application.
- Escalate from Prototype Pollution to EKS Takeover (Premium, Intermediate): exploit prototype pollution in a Node.js app for code execution, break out of the container, and abuse RBAC to take over an EKS cluster.
- Secure Kubernetes using OPA Gatekeeper (Premium, Intermediate): write and apply OPA Gatekeeper policies in Rego to enforce standards and block the misconfigurations attackers abuse.
Frequently asked questions
Do I need Kubernetes experience to start Kubernetes penetration testing?
No. You need comfort on the Linux command line, the ability to read YAML and JSON, and a general security foundation. The KRTP bootcamp opens with fundamentals in minikube before moving into RBAC escalation, container escape, and cloud identity abuse, so the ramp is built into the path.
How do attackers escape a container to compromise a Kubernetes cluster?
Most escapes come from configuration rather than exploits: a privileged pod, hostPID with nsenter, a hostPath mount of the host file system or the container runtime socket, or a dangerous capability such as CAP_SYS_ADMIN. When the configuration is sound, attackers use runtime bugs such as runc CVE-2024-21626. Once on the node they take the kubelet's credentials and the node's cloud identity, which is what turns one pod into the whole cluster. Pwned Labs walks this escape-to-cloud chain in its Escalate from SSJI to EKS lab.
How do I secure a Kubernetes cluster against real attacks?
Work through the attack chain and close each link: keep the API server off the internet with anonymous auth disabled, make RBAC least privilege and stop auto-mounting service account tokens, enforce the restricted Pod Security Standard to remove escape paths, apply default-deny network policies, block the cloud metadata service from pods and use per-workload identities, keep admission webhooks restricted and patched, encrypt secrets, and verify it all with an authorized penetration test.
Is Kubernetes penetration testing legal?
Only when it is authorized. Test clusters you own or have explicit written permission to assess. Use dedicated practice environments, such as Pwned Labs labs and the KRTP bootcamp, to build skills safely and legally.
How long does it take to learn Kubernetes penetration testing?
With a general security foundation, a focused learner can reach practical competence in a few weeks of hands-on work. The KRTP bootcamp is on-demand with lifetime access, so you can move at your own pace and repeat the live environments as often as you need.
About Pwned Labs
Pwned Labs is a hands-on cloud and AI offensive security training platform. It runs real-world attack labs and bootcamps for AWS, Azure, GCP, Kubernetes and AI systems, including the ACRTP, MCRTP, GCRTP, KRTP and AISRTP certifications. Free labs are at pwnedlabs.io/explore.