The alert that mattered: how a dev server ended up mining crypto
One of our development servers was taken over through an unpatched Next.js vulnerability. What happened, what we learned, and why we built HardenKit.
- Author
- The HardenKit team
- Published
A development server of ours was broken into. The attacker did not steal anything we could find. They installed a crypto miner and let it run.
The way in was a known vulnerability in Next.js. A fix existed. We had not applied it on that server.
This post is about why that happened, because we think the reason is common, and it is the reason HardenKit exists.
What happened
We run several applications on Next.js. One of them had an old copy running on a development server. Nobody was working on that copy, so nobody was upgrading it.
A vulnerability in Next.js let an attacker run their own code on the server. They used it to start a miner. We found out because the machine was busy when it should have been idle.
Why we missed it
We did not miss the vulnerability because nobody told us. We missed it because too many things told us.
Dependency alerts arrive every day. Most are marked high or critical. Most of them are in code paths we never run, or need conditions that do not exist in our setup. After a while, a critical alert stops meaning anything.
The alert for this vulnerability looked like all the others. What was different about it was not its severity score. It was that attackers were already using it, and that fact was nowhere on the screen.
There was a second gap. Our checks ran on repositories. The server that was broken into was not in any pipeline. It was just running.
What we changed
Three things would have prevented it, and they became the plan for HardenKit.
- Rank by attacks, not by score. A vulnerability that is being exploited today goes to the top, whatever its number. Two public sources make this possible: CISA publishes the vulnerabilities known to be exploited, and FIRST publishes a daily estimate of which ones will be next.
- Turn the list into upgrades. Three hundred findings are not a task. "Upgrade this package to this version" is.
- Look at servers, not only repositories. The copy nobody deploys any more is the one that gets broken into.
The first two are in HardenKit Scan, which is free and open source. The third is HardenKit Watch, which we are building now.
Check your own servers
If you run a server and you are not sure what is on it, this takes a minute:
curl -sSfL https://hardenkit.com/install.sh | sh
hardenkit scan /path/to/your/app
Anything under FIX NOW is being exploited in the wild. Start there.
If you find a server that was already taken over, upgrading is not enough. Treat every secret on that machine as stolen, replace them, and rebuild the server from a clean image.