Back to portfolio
Guide · Kubernetes security

Defending Kubernetes against supply-chain attacks

A compromised dependency can smuggle a cryptominer into your build, past code review, and quietly burn CPU on a production node with no application symptoms at all. Here is how that attack works and the pipeline and runtime defenses that stop it.

By Vitor Schiavo Updated October 2026 ~6 min read

The scariest class of compromise is the quiet one. No outage, no error spike, no alert from the application. Just a node running hotter than it should, with a process like xmrig (a Monero cryptominer) burning CPU inside an otherwise normal container. This is a write-up of how that happens through the software supply chain, and the layered defenses that make it both hard to pull off and fast to catch.

How a miner gets in without touching a pull request

The dangerous part of a supply-chain attack is that the malicious code is never in a diff anyone reads. A package deep in the dependency tree (a transitive dependency of a dependency) is compromised upstream. When the frontend builds, the bad code is pulled in and assembled into the bundle. Code review structurally cannot catch this, because reviewers look at the change set, not at every line of every transitive package. The result ships to production looking completely normal.

Why code review is the wrong layer for this

Human review inspects what changed in the pull request. A poisoned transitive dependency changes nothing in the diff; it changes what gets downloaded and built. That is why supply-chain defense has to live in the pipeline and the runtime, not in the review.

Detection: watch the node, not just the app

Because the application behaves normally, the only early signal is at the infrastructure layer. A cryptominer's whole purpose is to consume CPU, so node-level CPU anomaly detection is the tripwire. Concretely:

Containment, if one gets in

The response is standard Kubernetes hygiene, done quickly:

The defenses that actually stop it

Detection and cleanup are the last resort. These are the layers that prevent it, or neuter it if it still gets through.

Defense in depth, in one sentence

CI audit and image scanning make it hard to get in, lockfiles and pinning make it hard to come back, Pod Security Standards make it hard to escalate, default-deny egress makes it useless if it does get in, and node CPU anomaly alerts make it fast to catch. No single layer has to be perfect.

What I would tell someone hardening a cluster