r/servers • u/Dapper_Fun_8513 • May 06 '26
Question Found a cryptominer on my dev server — cleaned it up but still can't figure out how they got in

So this happened yesterday and I'm still trying to piece together the full picture. Noticed my server was running at nearly 200% CPU. Checked htop and found two processes called `cpu-logind` each eating ~98% CPU. Sketchy name designed to look like a legit Linux daemon, but it was XMRig — a Monero miner.
Here's what I found after digging in:
- The binary was sitting in `/var/tmp/cpu-logind` with a `config.json` alongside it
- They had a `@reboot` crontab entry to restart it on every reboot
- They'd even compiled XMRig directly in the home directory of the dev user — so they were comfortable enough to build software on my server
- Auth logs showed 3 different attacker SSH keys across `dev`, `forge`, and `root` accounts
- They had root access at least twice (May 5 and May 6)
I've cleaned everything up — killed the miner, removed the crontab, deleted the binary.
Planning to revoke the deploy keys on GitHub, and rebuilding the server from scratch since root was compromised.
**But I still can't figure out the original entry point and it's bugging me.**
Here's what I've ruled out so far:
- No webshells found anywhere in the app directory
- Vite dev server wasn't exposed publicly (no `--host`, no nginx proxy to port 5173)
- No suspicious POST requests in nginx logs
- Bash history of the dev user was clean — just normal Node/PM2 stuff, so they likely cleared their tracks
- GitHub repo had zero commits after May 1st — source code wasn't touched
What I do know:
- On May 3rd there were repeated failed SSH attempts using old `ssh-dss` (DSA) keys — all rejected by modern OpenSSH
- Then on May 5th at 08:52 UTC, a successful login happened using a real RSA key belonging to me
- The app is a React/Node.js admin panel managed via Laravel Forge
- The compromised keys included the Forge worker key and two of my personal keys
So either my machine was compromised and my private key was stolen, or the key leaked somewhere (GitHub history, Pastebin, etc). I've searched old commits and found nothing, but I'm not 100% sure.
Has anyone seen this pattern before? Specifically the DSA probing followed by a switch to a working RSA key — does that suggest they had a database of stolen keys they were cycling through? Or is there another explanation I'm missing?
Any help figuring out the original vector would be really appreciated. Want to make sure the new server doesn't get hit the same way.
36
u/Live-Juggernaut-221 May 06 '26
You.... Still trust this machine?
Full reinstall otherwise just assume it's still owned. Any keys that were on this machine should be rotated and never used again.
Edit: kept reading.
You need to rotate every key you have and wipe any machines that those keys had access to.
5
u/hendrik43 May 06 '26
Im not too well versed on this topic, but an initial thought that comes to mind is, what if you put yourself in the position of a threat actor?
What ports are public facing? is your machine up to date, any recent CVE's effecting those public facing services?
Then, what if you used a tool threat actors use to scan your machine for privilege escalation, something that comes to mind is https://github.com/peass-ng/PEASS-ng/tree/master/linPEAS
Think of this exercise as an internal pentest you can conduct yourself.
18
u/Lucky-Double-4494 May 06 '26
Root obtained more than once. Machine might as well be theirs. Wipe it all.
3
u/__vlad_ May 06 '26
This came in through one of the react dependencies, had the same experience in December, it affected react and next.js applications, after cleaning it up, delete node modue, and upgrade to the latest version. It's a really annoying hack
3
u/sp_dev_guy May 07 '26
I assume/hope the device is question is no longer running. If they have reverse shell or anything like that blocking inbound connections won't stop them
--- if you really want to get into it..
Have you done a lookup of the IPs you saw connecting? Probably other compromised devices/jump servers, if you scan them you might find they all run Apache or WordPress or something in common with you.
Do you have ample time to hunt them a la the cuckoos egg?
If you still have the device does the command history show you anything interesting ? Do you have (external?) logging you can parse?
Sounds like you have ssh keys just chilling on machines to get scooped up. Password managers, mfa, zero trust tools can help with preventing that avenue
My guess is the key to this one is patching
2
u/Past_External7849 May 07 '26
If they had entire root access fully reinstall and reformat drives. Extract your logs for analysis and learn from it. ;)
36
u/dutchman76 May 06 '26
It may have been a supply chain attack, if you did any kind of 'npm update' or 'npm install' at the wrong time, you could have downloaded a malicious payload and that's how they got in.
1
u/rootkode May 07 '26
I hope you’re not still using this machine. It’s completely compromised.
1
u/Cracknel May 07 '26
1
u/mixedliquor May 07 '26
Sounds like a key compromise issue. It probably all started there.
1
u/Ok-Count-3366 May 08 '26
Probably through an old next.js vuln. Was everything up to date?
2
u/nian2326076 May 07 '26
Double-check your server's SSH security. Weak passwords or outdated software are easy ways in. If you haven't already, set up SSH key authentication. Check for any user accounts you don't recognize and make sure your firewall settings are solid. Look for unpatched vulnerabilities in your web server and any apps. For future protection, tools like Fail2Ban can help monitor and block suspicious activity. Reviewing logs is important—check both system logs and specific service logs (like your web server) for unusual access patterns before the miner showed up. Good luck!
2
u/c0psrul3 May 07 '26
wipe and rebuild
1
u/rankinrez May 06 '26
Could be a supply chain thing.
Or depending where this host is the recent cPanel vulnerability.
1
u/Mediocre_Contract984 May 07 '26
How are people hacking into a Linux server?
1
u/Upper_Geologist_5762 May 07 '26
Router fw port open and your stuff on 0.0.0.0?
1
u/marrsd May 08 '26
Check what version of React you were using. There was a recent exploit (maybe 6 months old) with React & Next that allowed a malicious actor to access the filesystem via the web server. Any keys stored in your env vars or home dir could have been accessed.
1
u/Pose1d0nGG May 08 '26
Well between CopyFail and Dirty Frag or even the cPanel/WHM exploit going around. Dirty Frag is just like CopyFail, but has a public PoC with no patch luckily it's mainly only affecting systems running as an IPSec VPN server
1
u/AdditionalBelt9719 May 08 '26
Do you happen to have an old ubiquity controller running on it? As I recall the exploit came along with a dependency that (in my case) was installed with the UBNT controller, but I suppose it could come with anything that also uses that dependency.
Did a bit of digging through my tickets. Look for "log4j" on your system " find /usr/lib -name "*log4j*" -ls"
Since they had your RSA key...It points more toward the machine you use being hacked. I don't know the methods used by the log4j issue, it seems unlikely it is giving up a private key unless you are logging to a remote machine using that key.
1
u/SnooDingos8194 May 08 '26
What's your servers address? Please post your credentials here so we can make sure that your server is safe from hackers. Lol.
1
u/Sorry-Committee4443 May 09 '26
Wipe and reinstall!
0
u/[deleted] May 06 '26
[deleted] — view deleted comment
2
u/[deleted] May 06 '26
[removed] — view removed comment