Quick reference
- A token is stolen — A compromised pod reads its mounted ServiceAccount token. · *token*
- List secrets — It reads Secrets in its namespace, including credentials. · *secrets*
- Find a privileged SA — A RoleBinding shows which ServiceAccount can create pods. · *rbac*
- Create a pod as that SA — The API server runs the new pod with the stronger identity. · *pod create*
- Mount the node — hostPath / exposes the node filesystem and kubelet creds. · *hostPath*
- Take the cloud role — Node instance profile gives the pod cloud rights. · *cloud*
Explained
The path
- A token is stolen. Every pod mounts a projected token at
/var/run/secrets/kubernetes.io/serviceaccount/tokenunless automount is disabled. A compromised container reads it first.
- List secrets. If the ServiceAccount can list Secrets in its namespace, credentials come back in plaintext: database passwords, API keys, sometimes a cloud key. It is the most common RBAC over-grant.
- Find a privileged SA. RoleBindings show which accounts can create pods. The CI account often can, and its Role may also allow Secrets or pods/exec.
kubectl auth can-i --list --as=system:serviceaccount:shop:apianswers it.
- Create a pod as that SA. Anyone who can create a pod can usually set serviceAccountName in the spec. The API server admits it; the kubelet mounts the stronger token.
- Mount the node. With hostPath: /, the container reads the node's filesystem, often including the kubelet kubeconfig.
- Take the cloud role. The metadata endpoint at 169.254.169.254 may return the node's instance profile credentials. The cluster admin is now the cloud account.
Where it stops
The honest caveat: Pod Security Admission at baseline or restricted rejects hostPath and privileged pods, so this chain needs a namespace that allows them. Inventory it first.
The lesson: the token is not the breach; the binding behind it is.
In one line
One pod is the whole cluster. A stolen token is a foothold; weak RBAC makes it the account.
Prove the path
kubectl auth can-i create podsMore notes: DevSecOps & cloud security
Open in the notes app: search, filters, copy This note on GitHub