Attacking a Cluster
One compromised pod, then the node under it, then every secret in the cluster.
What you will learn
- -Chain a pod foothold into node-level code execution
- -Abuse create-pod rights to mount the host filesystem
- -Turn stolen node credentials into cluster-wide access
You have in a . Maybe an got you there, maybe a vulnerable web app, maybe a supply-chain package. It does not matter how you arrived. What matters is the climb: pod to to . Each step trades a small foothold for a bigger one, and the cluster's own features do most of the lifting.
Step one: know your surroundings
Before any , answer three questions. What do you hold, from the last two lessons. Are you privileged. And can you see the .
$id; capsh --print 2>/dev/null$cat /proc/1/cgroup; ls -la /$env | grep -i kube$mount | grep -E 'docker|containerd|host'If you see /var/run/docker.sock mounted, or the pod runs privileged, you can escape to the node right now. If not, is your ladder.
Step two: create a pod that mounts the host
This is the workhorse escalation. If your token can create pods, you do not need a bug. You ask politely to schedule a pod that mounts the node's filesystem, then you read whatever you want from the host.
Apply it, exec in, and you are reading the node's disk as if you were sitting on the box.
$kubectl apply -f evil-pod.yaml$kubectl exec -it maint-check -- chroot /host bash$cat /host/etc/kubernetes/*.confThe type: Directory and a sleep keep it stable. Pin it with nodeName if you are hunting a specific node's .
Step three: harvest the node, reach the cluster
Once you are on the node filesystem, the loot is concentrated in a few places. Every pod scheduled on this node has its token sitting under the 's pod . The kubelet's own kubeconfig can talk to the . And if this is a -plane node, etcd and the admin kubeconfig are right there.
$find /host/var/lib/kubelet/pods -name token 2>/dev/null$cat /host/var/lib/kubelet/kubeconfig$ls /host/etc/kubernetes/pki 2>/dev/nullCollect tokens, replay them with kubectl --token=, and check each with auth can-i --list. One of them usually reaches further than the last. That is the pivot: a token from a sensitive pod that can read secrets cluster-wide, or an admin kubeconfig that ends the engagement.
The tokens worth stealing belong to pods in kube-: controllers, CNI agents, cloud provider integrations. They are often bound to broad ClusterRoles because they legitimately need them. Find a node running one, host-mount it, lift the token, and you frequently inherit cluster-admin-adjacent rights without touching an actual admin .
Host-mount escapes and token harvesting are full compromise techniques. Run them only on clusters you own or have explicit written to test, such as Kubernetes Goat or a scoped engagement. This activity is loud in and illegal without permission.
Your token cannot read secrets, but auth can-i shows you can create pods. Why does that still lead to the secrets?
You harvested a token file from /host/var/lib/kubelet/pods and want to see how far it reaches before using it. Write the kubectl command that lists that stolen token's full permission set.