System compromised by crypto-miner, Am I alone?

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
lost
Posts: 728
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

System compromised by crypto-miner, Am I alone?

Post by lost »

Hello,

For the 1st time my PI hosting Domoticz was compromised: 1st noticed this from the widgets showing CPU/RAM usage. CPU was near to 100% and DDR to ~80% with no visible issue from user POV (webUI still responsive etc). So this looked quite well calibrated to use as many ressources as possible without a user likely to notice.

=> As (see hereunder) the starter code of this was in my ~/domoticz, even if I could not trace were this exactly came from, I advise everyone to check its system load (widgets, if setup, or using top utility for instance).

Another consequence was core temp at 70°C instead of usual 45/50°C (with only passive cooling glued on SoC/memory in my system).

This lasted about 24h before I notice.

Usual process monitoring tools (ps, top...) dit not show anything but process usage added from top output being far from 100% (this was at most 8/10%, so a big and suspect gap). The load was userspace (labelled us in top), so not kernel related (interrupt storm due to faulty HW...).

If you see high loads, go ahead:

Checking socket stat quickly shows a process with a tcp connection active (remote port being https/443), but no name shown. So a process using network was somehow hidden.

To check this:

Code: Select all

ss -tup
This will show active tcp/udp connections with associated process... If you see a line with no process name shown, you may be in same situation as me.

The easy way (not modifying system tools/LD_PRELOADing a library affecting their behavior or kernel patch) to hide a process is to remounts it's /proc/PID tree somewhere else (to a tmpfs in my case).

Code: Select all

mount | grep proc
On a Debian system if you have anything added after /proc and both lines showing binfmt_misc this is a sign of something bad. This will also show the remount point for the process PID.

I 1st tried to kill it but came back almost immediately but load started to decrease before being back to ~100%. So the culprit was this hidden process.

So I did last step again to get the new PID and this time did an unmount of the shadow mount point from hereupper command.

This revealed a ~/domoticz/.sysinit hidden executable (another [process] named between squares, to have a "kernel process look"/avoid suspicion, was in cgroups: This is the one that was restarting the process responsible for the load). Searching for this in the whole SD card did show 2 callers: An added root cron line for reboot (that could be also seen using "crontab -l" as root) and in /root/.bashrc file executed when connection is done as root user: Exactly what I did when this started on saturday at ~16h45, as I did not restarted my since a few days.

=> So I presume compromise happened between this last reboot on tuesday after some apt update needing it (otherwise load would probably have risen immediately) and my connection as root for administrative tasks on last saturday.

Unfortunately, I don't keep logs for long (SD card storage...) so I could not get more clues. Only this .sysinit file in domoticz tree makes me think this could have something to do with Dz but as root anyone can setup anything where it decides to.

I also did a mistake by doing a move (mv ~/domoticz/.sysinit ~) of the file to keep it out of it's known start path, in case there is unseen starters: This kept the inode and the file was destroyed at both found processes kill. Should have done a cp instead... So no more investigation possible from there. Google search shows load and dissimulation techniques may point to some crypto-miner (on a PI, that's a bit surprising as this need some horsepower).

There was also 2 directories (.global), empty at time of check, lying in domoticz and plugin roots. They may be some remaining traces of the install path.

This looks now quiet since yesterday, but I'll probably have to wipe a just installed system (less than a month)...

Just wanted to know if I'm alone or not?
Post Reply