Monero (XMR) is an open-source, privacy-oriented cryptocurrency that was launched in 2014. It uses a public distributed ledger containing technology that obscures transaction details to ensure the anonymity of its users. Monero maintains egalitarian mining, allowing anyone to participate. As tempting as it may seem, some go a step further and use the infrastructure of others to participate in mining.
Cryptocurrency mining was originally performed using CPUs, and Monero was no different. Over the years, mining capabilities have expanded to take advantage of the power of GPUs. Although for some cryptocurrencies both techniques have become obsolete, they are still widely used for mining XMR.
The attacker crouched in the shadows
It all started with a Reddit post, where u/TackleSouth6005 shared a tutorial on how to create a server-side Node.js Monero miner:
Figure 1 – Reddit post published on r/MoneroMining, accessed 30/06/2022
Inspired by the post, the attacker published the eazyminer-fsdjufhsdjf package, which shared code with eazyminer package–and which took the Mend research team only 34 seconds to spot.
Figure 2 – npm registry page of both packages
It’s worth noting that not only did the attacker steal the package name, but also the XMR address of the Reddit user used in the configuration files. The first malicious package in this attack was published on May 24, 2022 and shared the content of the original package.
En masse attacks
The attacker then stepped up efforts with an en masse attack that commenced on June 27, 2022, as hundreds of packages with the same behavior were uploaded. Over the course of the next few days, we spotted more attacks. With each attack, the time interval between successive publications of the packages decreased.
The packages were first released every five to six minutes, and the attack interval then shrunk to every minute. They initially came from a single account, and the attacker then expanded to use multiple accounts from the same domain. Once reported by Mend Research and blocked by npm, the attacker started using the “account per package” approach from another domain.
Figure 3 – Maciej’s tweet
At the time of writing this article, there are 601 npm packages sharing the same functionality:
Figure 4 – List of malicious packages accessed 30/06/2022
The attack vector
Although the eazyminer package provides clear install instructions, it is worth pointing out that we do not recommend installing it, and here’s why:
Figure 5 – Install instructions from the eazyminer package
Every time you require the miner, it executes the following code:
Each published package is relying on pool mining. Pool mining gives the miner frequent payouts. The amount of XMR (Monero tokens) they receive is correlated with their participation in the pool. Although the package theoretically allows miners to use both GPUs and CPUs, the attacker’s method primarily relies on CPUs.
Most of these malicious packages use unique names such as wbkvsaipmgythxkz, nwavbdqkkelfruoz, kqdxlgaurwyzbsjk, or puqjgilbnreysztf. One might ask, what are the chances of a successful typosquatting attack using names like these? Well, the attacker’s modus operandi seems different.
Systems that were targeted in this attack are security scanners and other automated systems. They install the packages and analyze their content. If they do not provide an initial configuration, the package is going to use the one provided in the config.base.json file, with the hard-coded XMR address. By doing so, the package will use the default XMR address and mine on behalf of the user from the config.
How to protect your organization
Supply chain attacks evolve and grow more frequent each day. The easiest way to protect this attack surface is to use an automated supply chain security solution such as Mend Supply Chain Defender that informs you when you import a malicious package from open source registries.
Mend enterprise customers using JFrog Artifactory as a private repository manager can prevent malicious open source software from entering their code base using the Mend Supply Chain Defender Integration with JFrog Artifactory.
Tamir Ben Ari is a malware researcher at Mend, investigating malicious behaviors such as typosquatting attacks, malicious takeovers, ATO attacks, Makefile pollution, Bitcoin mining, environment and credential-stealing, and dependency confusion. Previously, he held the role of security researcher at Mend, which included detailed vulnerability research in open source libraries.
Maria Korlotian is an experienced software developer at WhiteSource. She holds a degree in Mechatronics Engineering. In her free time, she enjoys learning new languages and solving algorithmic challenges.