
Proof-of-concept exploit for Kubernetes service-account token disclosure via hostPath mounts; includes vulnerable pod YAML and Python token-theft script.
# vulnerable-pod.yaml - Pod that mounts /var/run/secrets/kubernetes.io/serviceaccount into a hostPath
apiVersion: v1
kind: Pod
metadata:
name: sa-token-leak
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: sa-token
volumes:
- name: sa-token
hostPath:
path: /var/run/secrets/kubernetes.io/serviceaccount # Writable by container? Not needed.
type: Directory
A pod mounts the Kubernetes service account token directory via hostPath instead of the default projected volume. This exposes the token to other pods on the same node if they can read the host filesystem, allowing lateral movement and cluster compromise.
hostPath to mount the SA token directory bypasses the in‑memory token projection and makes the token a persistent file on the node.Deploy the vulnerable pod, then from another pod with host access, run:
python exploit_sa_token.py
The token is read and can be used to authenticate to the API server.