Penetration Testing A Kubernetes Environment
The Kubernetes cluster had overly permissive RBAC, allowing a user to create pods with host mounts and host namespaces. An attacker with kubectl access could use kubectl debug to run a privileged pod on a node and read the node's service account token and SSH keys.
Published on infosecwriteups.com
To read for free/Friends Link https://bobvanderstaak.medium.com/72719f9e1010?source=friendslink&sk=2fddd1540d46a67aa517b210aea1313e
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the cluster's RBAC was configured with wildcard permissions, granting full access to all resources, and pods were allowed to use host mounts and host namespaces without restriction.
Impact
An attacker with kubectl access could obtain the node's service account token and root SSH keys, potentially leading to full cluster compromise; the attack is noisy and requires high privileges.
What the attacker needed
Kubectl access to the cluster; permissions to create pods and debug nodes
The fix
Implement strong RBAC rules to enforce least privilege and restrict pod capabilities such as host mounts and host namespaces.
How it was found
- Check your permissions with kubectl auth can-i --list.
- List the nodes with kubectl get nodes.
- Run kubectl debug on a node with an image, which creates a pod with a host mount.
- Read the service account token from the host mount.
- Read the root SSH authorised keys from the host mount.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Kubernetes is a system for running containerised applications. RBAC controls who can do what. Here, the default permissions were too broad, letting a user start a debugging container on a cluster node. That container had access to the node's files, so the user could steal credentials.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.