iac.htora.dev · security templates

Home/Refreshers/Kubernetes for defenders: refresher

Kubernetes for defenders

The common paths through a cluster, where each one leaves traces, and what stops it.

Attack pathLook inStop it with
Privileged pod or host mountAudit log: a pod with privileged, hostPath, or hostPIDAn admission policy
Stolen service account tokenRuntime: the token read by a shell or curlNo token where none is needed
Exec into a podAudit log: pods/exec, get or createFew people allowed pods/exec
The node's cloud credentialsCloud audit log: the node's role used elsewhereOn EKS, IMDSv2 with a hop limit of 1
A borrowed workload identityAudit log, and the cloud audit logFew people allowed to create pods in that namespace
A new role bindingAudit log: bindings to cluster-adminFew people with bind and escalate

Commands

Who may execkubectl auth can-i create pods/exec --as <user> -n <namespace>
Find cluster-admin bindingskubectl get clusterrolebindings -o wide | grep cluster-admin
Save a pod's definitionkubectl get pod <pod> -o yaml > pod.yaml
Logs from before a restartkubectl logs <pod> --previous

Watch out

  • EKS keeps its audit log off until you switch it on.
  • GKE records admin actions by default. Reads of secrets are Data Access logs, off by default.
  • Whoever can create a pod with a service account bound to a cloud role has that role.
Check it worked

A test kubectl exec appears in the audit log, with the user, within minutes.

Read the full pageDownload PDF

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.