
Exploit proof-of-concept per la divulgazione del token dell'account di servizio Kubernetes tramite montaggi hostPath; include YAML di pod vulnerabile e script Python per il furto del token.
# 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
Un pod monta la directory del token dell'account di servizio Kubernetes tramite hostPath invece del volume proiettato predefinito. Questo espone il token ad altri pod sullo stesso nodo se riescono a leggere il filesystem host, consentendo movimento laterale e compromissione del cluster.
hostPath per montare la directory del token SA bypassa la proiezione del token in memoria e rende il token un file persistente sul nodo.Distribuisci il pod vulnerabile, quindi da un altro pod con accesso host esegui:
python exploit_sa_token.py
Il token viene letto e può essere utilizzato per autenticarsi al server API.