iac.htora.dev · security templates

Home/Refreshers/Clearing an attacker out of a cluster: refresher

Clearing an attacker out of a cluster

What outlives a deleted pod, where attackers persist in Kubernetes, and how to rotate what cannot be revoked.

Remember

  1. Kubernetes cannot revoke a client certificate. Rotate the cluster's certificate authority.
  2. Tokens from kubectl create token cannot be revoked. Recreate the service account.
  3. A mutating webhook can add a container to every new pod, clean replacements included.
  4. Static pods, the kubelet API, etcd, and the runtime socket bypass the audit log.
  5. Close every path in one window. One at a time warns the attacker.

Look here

Bindingskubectl get clusterrolebindings,rolebindings -A -o wide
Webhookskubectl get mutatingwebhookconfigurations,validatingwebhookconfigurations
Workloads that returnkubectl get daemonsets,cronjobs -A
Token Secretskubectl get secrets -A --field-selector type=kubernetes.io/service-account-token

Watch out

  • Approved signing requests are deleted after an hour. Only the audit log keeps them.
  • Old certificates work until the old authority is removed.
  • Replace compromised nodes. Do not clean them.
Check it worked

After rotation, an old kubeconfig is refused, and the audit log shows none of the attacker's identities.

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.