// guides

Kubernetes Penetration Testing: From Pod Foothold to Cloud IAM

Kubernetes penetration testing attack path from a compromised pod through RBAC and the node to cloud IAM

A Kubernetes penetration test starts from a realistic foothold, such as a running pod, a leaked CI token or an exposed API server, and follows RBAC, service account tokens and permissive pod specs to the node and then into cloud IAM. Configuration decides most outcomes, not kernel exploits, so the test plan should be built as an attack graph rather than a container-escape hunt.

The short answer

  • A Kubernetes penetration test starts from a realistic foothold and follows RBAC, service account tokens and permissive pods to the node and cloud IAM.
  • Most real takeovers are configuration paths: escalate/bind/impersonate rights, pod creation next to privileged ServiceAccounts, hostPath and privileged pods.
  • On managed clusters the control plane is out of scope; the prize is the node and workload cloud identity.
  • Admission control has predictable holes (exemptions, failurePolicy: Ignore, static pods), and every exploited path needs a matching alert or a detection-gap finding.

Key takeaways

  • Kubernetes takeovers usually run through RBAC, service account tokens, permissive pod specs and node IAM, not kernel exploits.
  • escalate, bind, impersonate, serviceaccounts/token, pod creation and CSR approval to system:masters are each effectively cluster-admin. system:masters bypasses RBAC.
  • Legacy Secret-based service account tokens never expire and survive upgrades. Projected tokens expire, but the API server cap is about one year by default.
  • On EKS, GKE and AKS the control plane is out of scope. The crown jewels are cloud IAM roles reachable from pods and nodes.
  • Static pods, PodSecurity exemptions and failurePolicy: Ignore let dangerous pods bypass admission entirely.

What actually happens in a Kubernetes penetration test?

A Kubernetes penetration test assumes a foothold and measures how far it reaches: inside the cluster, onto the node, then into the cloud account. The deliverable is proven paths, not a list of misconfigured fields.

Most incidents begin with a compromised workload or a leaked pipeline credential. An internet-only probe never walks the graph that defines your exposure.

  • Recon and unauthenticated surface. API server exposure (6443 on kubeadm, 443 on managed offerings), what system:unauthenticated can read, dashboards such as Kubernetes Dashboard and Argo CD, etcd on 2379, kubelets on 10250.
  • Authentication. Kubeconfigs and tokens in CI/CD, Git history and Helm values; OIDC mistakes; certificate issuance.
  • RBAC abuse. Enumerate with kubectl auth can-i --list, then chain permissions into higher identities.
  • Workload escalation. Privileged pods, hostPath and runtime sockets, host namespaces, added capabilities.
  • Node access. Static pod manifests, kubelet credentials, runtime and kernel patch level.
  • Node-to-cloud pivot. Instance metadata, workload identity, node IAM roles, registry credentials on disk.
  • Admission and detection. Policy exemptions and failure modes, and whether each phase above raised an alert.

How is this different from an image scan or a CIS benchmark?

Scanners list misconfigurations. A pentest proves which of them chain into cluster-admin or a cloud role.

Approach Finds Misses
Image scanning (Trivy and similar) Vulnerable packages, embedded secrets, bad base images Runtime identity, RBAC, cloud IAM
CIS and posture (kube-bench, Kubescape) Control-plane flags, kubelet settings, NSA/CISA and CIS gaps Transitive RBAC, cross-namespace paths, node-to-cloud pivots
Graph analysis (KubeHound, rbac-police, KubiScan) Candidate paths across identities Whether admission and detection stop the path
Manual attack-path testing Exploitable chains with prerequisites and detection coverage Breadth, unless paired with the tools above

Is the control plane in scope on a managed cluster?

No. On Amazon EKS, Google Kubernetes Engine and Azure Kubernetes Service, the provider owns the control plane. Terms prohibit testing it, along with denial of service and anything that touches other tenants. Read the current AWS, Google Cloud and Microsoft rules before every engagement.

That does not shrink the test much. RBAC, workload configuration, node IAM, network policy and admission control sit on the customer side of the shared-responsibility line, and that is where takeovers happen.

Managed (EKS, GKE, AKS) Self-hosted (kubeadm, OpenShift, Rancher)
Control plane Provider-owned, out of scope In scope with written authorization
Crown jewels Cloud IAM roles on nodes and service accounts etcd, admin.conf, CA keys, plus the cloud account
Cluster-admin mapping aws-auth, EKS Access Entries, cloud IAM bindings Client certs, OIDC, system:masters

Self-hosted clusters need written scope for control-plane nodes, etcd and the underlying hosts. Unauthenticated etcd still shows up on lab and self-built clusters, and a direct read returns every Secret. Encryption at rest is opt-in through an EncryptionConfiguration. Base64 is not encryption.

One toolkit covers the phases: kube-bench and Kubescape for posture, Trivy for images and manifests, KubiScan and rbac-police for RBAC risk, KubeHound for graph paths, amicontained and kdigger for in-pod enumeration, kubeletctl for the kubelet API, and Peirates for post-exploitation. Kubernetes Goat is a reasonable environment for rehearsing the plan before touching production.

Kubernetes penetration testing attack graph from pod through service account and node to cloud IAM
The test follows identities outward: pod, service account, node, cloud role.

Which RBAC permissions are effectively cluster-admin?

Any permission that lets a subject mint, borrow or grant a more privileged identity is cluster-admin with extra steps. Kubernetes authorization is additive and has no deny rules, so effective rights are the union of every matching binding. Compute the transitive closure. Do not read roles one at a time.

  • escalate and bind on roles or clusterroles: create a role stronger than yourself, or bind an existing privileged role to yourself.
  • impersonate on users, groups or serviceaccounts: become anyone the rule allows.
  • create on serviceaccounts/token: the TokenRequest API mints a token for any ServiceAccount you can name.
  • create on pods, deployments, daemonsets, jobs or cronjobs: run a pod as any ServiceAccount in that namespace and read its token.
  • get, list or watch on secrets cluster-wide.
  • create on pods/exec, pods/attach or pods/portforward.
  • Write access to rolebindings, clusterrolebindings and webhook configurations.
  • certificatesigningrequests create, plus approval on the kubernetes.io/kube-apiserver-client signer: issue a client certificate with O=system:masters. Membership in system:masters is hardcoded to full cluster-admin in the API server and bypasses RBAC, so deleting RoleBindings cannot revoke it.
  • nodes/proxy: reach the kubelet API. GET requests through that subresource have historically bypassed API server audit logging, so treat it as node access. Apply the same caution to nodes/log, nodes/stats and nodes/spec.

The default roles are sharper than they look. edit can create pods, so it can borrow any ServiceAccount in the namespace. admin adds RoleBinding creation and Secret reads.

view is read-only and still exposes Secret metadata and ConfigMaps. A user with edit in a namespace that hosts a privileged controller ServiceAccount already holds that controller’s rights.

kubectl auth can-i does not show admission webhooks, aggregated API servers, non-RBAC authorizers, or pod-creation chains into other identities. Treat the command as a starting point, not an audit.

Kubernetes RBAC privilege escalation concept with keys that mint a master key, illustrating escalate and bind
escalate, bind and TokenRequest let a subject mint stronger identities.

Are short-lived service account tokens still a real risk?

Yes. The legacy tokens never left. Projected tokens, generally available since Kubernetes 1.22, are audience-bound and pod-bound, and the kubelet refreshes them, which sharply limits replay.

Total lifetime is still capped by the service-account token maximum expiry, about one year by default. Calling them short-lived is fair only next to a Secret that never expires. Auto-generation of Secret-based tokens stopped being the default in 1.24. Upgrades do not delete Secrets already stored.

Legacy Secret-based token Projected TokenRequest token
Lifetime Never expires Expires, kubelet-rotated, capped near one year
Audience and pod binding None Both
Where it leaks CI variables, Git history, Helm values, old namespaces Pod filesystem while the pod runs
Revocation Delete the Secret Delete the pod or wait for expiry

List every Secret of type kubernetes.io/service-account-token, search pipelines and repositories for those JWTs, and check automountServiceAccountToken on both the ServiceAccount and the Pod. The Pod spec wins. A ServiceAccount set to false proves nothing if a Deployment sets it to true.

What does a privileged pod give an attacker on the way to cloud IAM?

Each setting below is a configuration path to the node. None of them needs a CVE, and together they explain most real pod-to-node transitions.

Setting What it yields Block first?
privileged: true All capabilities and devices; host disk mounts; no seccomp or AppArmor Yes
hostPath of /, /etc/kubernetes, /var/lib/kubelet, containerd.sock or docker.sock Node filesystem, kubelet credentials, or control of the runtime Yes
hostPID: true Other processes’ environments, which often hold secrets Yes
hostNetwork: true Node-local services and instance metadata Yes, especially on cloud nodes
CAP_SYS_ADMIN, CAP_SYS_PTRACE, CAP_DAC_READ_SEARCH Escape and credential-theft primitives Drop ALL, add back narrowly

Even default pods keep CAP_NET_RAW, enough for ARP spoofing where the CNI does not enforce policy.

A manifest written to /etc/kubernetes/manifests makes the kubelet start a static pod directly. The kubelet runs it regardless of what PodSecurity, Gatekeeper or Kyverno would have said.

Kernel and runtime bugs are patch context, not the usual route: runc CVE-2024-21626 (Leaky Vessels) and CVE-2019-5736, containerd CVE-2020-15257, Dirty Pipe (CVE-2022-0847), and OverlayFS CVE-2023-0386. CVE-2022-0185 is a container-adjacent kernel bug in fs_context, not a primary escape.

Before claiming the cgroup v1 release_agent path (CVE-2022-0492), confirm the host is not on cgroup v2. Modern distributions use cgroup v2 by default.

EKS, GKE and AKS: stop at proof of the node identity

Check whether a pod can obtain the node’s cloud identity and what that identity can do. Stop at proof. Do not act on the account.

  • EKS. Request the instance profile from IMDS at 169.254.169.254 from a normal pod and from a hostNetwork pod. IMDSv2 requires a PUT for a session token. The hop limit defaults to 1, which blocks that PUT from containers on the pod network. Raising the hop limit to 2 for pods that genuinely need metadata access is a trade-off to document, not a default setting. IRSA and EKS Pod Identity give opted-in pods their own credentials and do not remove the node role. Then check write access to the aws-auth ConfigMap in kube-system, which can map IAM principals into system:masters, and review EKS Access Entries alongside it.
  • GKE. With Workload Identity Federation and --workload-metadata-from-node=SECURE, pods do not see the node’s service account. Node pools set to EXPOSED hand that token to every pod. Autopilot blocks privileged pods and hostPath, which changes what you can test.
  • AKS. Azure IMDS only requires a Metadata: true header, so test whether pods can fetch the kubelet or node managed identity. Clusters still using the deprecated aad-pod-identity deserve extra attention. Azure Workload Identity replaced it.

Also look for registry pull credentials and kubeconfigs on node disk. The finding is usually what the node role can reach: object storage, secrets managers, other clusters. That is where AWS penetration testing and the Kubernetes test should share one attack graph.

How do you test PodSecurity, Gatekeeper and Kyverno for gaps?

Try to create the dangerous pods from the previous section in every namespace, as every identity you hold, and record which ones the policy layer admits.

PodSecurity admission replaced PodSecurityPolicy, removed in Kubernetes 1.25, with three levels set by namespace label. restricted blocks privileged mode, hostPath, host namespaces and root, and it requires seccomp RuntimeDefault with all capabilities dropped.

  • Namespaces labeled privileged or baseline, or with no enforce label at all.
  • Cluster exemptions for namespaces, usernames and runtimeClasses. kube-system is commonly exempt, so anyone who can create pods there wins.
  • Who can edit namespace labels, because that person can switch enforcement off.
  • Static pods, which never pass through admission.

For OPA Gatekeeper, Kyverno and Kubewarden, read the webhook objects themselves. failurePolicy: Ignore means an engine outage admits everything. namespaceSelector, objectSelector and matchConditions carve holes. Anyone who can write a MutatingWebhookConfiguration can rewrite every pod spec in the cluster.

Teams moving to in-tree ValidatingAdmissionPolicy, generally available in Kubernetes 1.30, need the same scrutiny on bindings and match scope.

Do namespaces isolate tenants?

Start from a pod in one tenant namespace and try to reach services, pods and node ports in another. Namespaces separate names and RBAC. They do not separate traffic.

NetworkPolicy does nothing unless the CNI, such as Calico or Cilium, enforces it. The default is allow-all until a default-deny policy exists. Mesh mTLS proves workload identity and authorizes nothing without an Istio AuthorizationPolicy or the equivalent.

CVE-2020-8554 still matters: Services with externalIPs can intercept traffic, and the practical control is an admission policy that restricts them. Put ResourceQuotas and LimitRanges in the same test. A tenant without them can starve neighbors.

Which audit signals prove these Kubernetes attack paths are detectable?

Match every exploited path to the alert it raised, or report it as a detection gap. A path with no alert is a separate finding. Tie each signal to the phase that produced it.

  • API server audit (authentication and RBAC phases): pods/exec and pods/attach, Secret reads, RBAC and webhook writes, serviceaccounts/token creates, CSR approvals, aws-auth edits, and any system:anonymous request.
  • Runtime, during workload and node phases (Falco, Tetragon, Sysdig, Aqua, Microsoft Defender for Containers): privileged pod creation, hostPath mounts of sensitive paths, shells spawned in containers, metadata endpoint access, writes to the static pod directory.
  • Cloud logs (node-to-cloud phase): node role credentials used from unexpected sources.

This is OWASP Kubernetes Top 10 item K05, Inadequate Logging and Monitoring. State the gap in the report next to the path the control failed to catch.

What should the report contain, and how often should you retest?

Open with an attack graph: foothold, intermediate identities, then cluster-admin or a cloud role, with prerequisites and detection coverage on each edge. Order fixes by paths broken per unit of effort. That order almost always puts RBAC and cloud IAM reductions ahead of patch-level findings.

Map findings to the OWASP Kubernetes Top 10: K01 workload configuration, K03 RBAC, K04 policy enforcement, K07 segmentation and K08 secrets. Record control plane, node, kubelet, runtime and CNI versions. A cluster on an end-of-life minor is a finding on its own.

Retest at least annually and after a new cluster, a minor-version upgrade, a policy-engine migration, or new multi-tenant workloads. PCI DSS 4.0 requirement 11.4 calls for penetration and segmentation testing. DORA brings threat-led testing for in-scope financial entities. NIS2 and SOC 2 auditors expect evidence of technical testing.

Cite CIS Kubernetes and the provider-specific CIS benchmarks, the NSA/CISA Kubernetes Hardening Guide, NIST SP 800-190 and MITRE ATT&CK for Containers alongside the findings.

Image-level work sits next to this test, not in place of it. A container security assessment covers what goes into the pod. The cluster test covers what the pod can reach.

Privileged pod with hostPath mount breaking into the node during a Kubernetes penetration test
Privileged pods and hostPath mounts turn the container floor into the node.

FAQ

What is Kubernetes penetration testing?

It starts from a realistic foothold, such as a compromised pod or a leaked CI token, and proves how far an attacker can reach through RBAC, service account tokens, node access and cloud IAM. It also checks whether admission control and monitoring stop or detect those paths.

Can you pentest EKS, GKE or AKS without violating the cloud provider's terms?

Yes, if you stay on the customer side: workloads, RBAC, node configuration, IAM and network policy. The managed control plane, denial of service and other tenants are off limits. Check the provider's current rules of engagement before starting.

Does a pod-to-node move require a kernel exploit?

Rarely. Privileged pods, hostPath mounts of the node filesystem or the runtime socket, and hostPID are configuration issues that give node access without a CVE.

Is kubectl auth can-i enough to audit RBAC?

No. It misses admission webhooks, aggregated API servers, non-RBAC authorizers and chains where creating a pod borrows another ServiceAccount. Effective rights are the union of every binding, and RBAC has no deny rules.

Are projected service account tokens safe by default?

They are safer than legacy Secrets: audience-bound, pod-bound and refreshed by the kubelet since Kubernetes 1.22. They are not minute-lived. The API server maximum expiry defaults to about one year, and Secret-based tokens created before 1.24 remain until someone deletes them.

How often should Kubernetes penetration testing be repeated?

At least annually, and again after a new cluster, a minor upgrade, a policy-engine migration or new multi-tenant workloads. PCI DSS 4.0 requirement 11.4, DORA threat-led testing, and NIS2 or SOC 2 evidence requests are the usual compliance drivers.

agent::offense runs Kubernetes penetration testing from a realistic foothold to cluster-admin and cloud IAM, with detection coverage mapped on every path. For clusters that share an account with the rest of your estate, we scope it inside broader cloud and container penetration testing.



// get started

Work with AgentOffense

Tell us about your target and goals. We’ll reply with scope and a fixed-price quote — usually within one business day.

./request_engagement