A cluster's nodes are suddenly at 100% CPU and you find pods running `xmrig` in a namespace nobody owns. How do you respond?
IntermediateScenarioKubernetes Security
Answer
Situation read → Cryptomining is often the first visible sign of a compromise. Find the entry point, not just the miner.
What I'd do →
- Save the pod specs:
kubectl get pod -n x -o yaml > evidence.yaml, note the creator from audit logs (user.usernameon thecreateevent). - Isolate with a deny-all NetworkPolicy and scale the workloads down; block the mining pool domains at egress.
- Find the entry point: exposed dashboard, anonymous API access, leaked kubeconfig, vulnerable app with RCE, or a compromised CI token.
- Revoke the credential used, check for other persistence (DaemonSets, CronJobs, new RBAC bindings, mutating webhooks).
- Rebuild affected nodes if any pod was privileged or used hostPath.
Why → Deleting the miner without closing the hole means it is back in an hour.
Interview tip → Mention checking for malicious webhooks and CronJobs as persistence.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate