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
- Kubernetes cannot revoke a client certificate. Rotate the cluster's certificate authority.
- Tokens from kubectl create token cannot be revoked. Recreate the service account.
- A mutating webhook can add a container to every new pod, clean replacements included.
- Static pods, the kubelet API, etcd, and the runtime socket bypass the audit log.
- Close every path in one window. One at a time warns the attacker.
Look here
| Bindings | kubectl get clusterrolebindings,rolebindings -A -o wide |
| Webhooks | kubectl get mutatingwebhookconfigurations,validatingwebhookconfigurations |
| Workloads that return | kubectl get daemonsets,cronjobs -A |
| Token Secrets | kubectl 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.