The Ethereum community has recently been targeted by a series of malicious packages on the npm registry. These packages impersonate the Nomic Foundation's Hardhat tool and are designed to exploit the trust in open-source plugins.
Once installed, these counterfeit packages can infiltrate developer environments and steal sensitive data, including private keys and configuration details. The Socket research team has identified several of these malicious packages, such as @nomicsfoundation/hardhat-configure
and @monicfoundation/hardhat-config
.
Hardhat is an important development environment for Ethereum software, used for editing, compiling, debugging, and deploying smart contracts and decentralized applications (dApps). The malicious packages use functions like hreInit()
and hreConfig()
to collect sensitive information from the Hardhat environment and transmit it to servers controlled by the attackers.
One of the identified packages, @nomicsfoundation/sdk-test
, has already been downloaded over 1,000 times since its publication in October 2023.
The npm ecosystem is complex, with packages relying on numerous dependencies, making it difficult to navigate and review for security. This complexity allows malicious actors to introduce harmful code without detection.
The threat actor behind these attacks, known as "_lain," has acknowledged exploiting this complexity, recognizing that developers cannot scrutinize every package and its dependencies.
Another malicious npm package, ethereumvulncontracthandler
, has been discovered. This package pretends to be a library for detecting vulnerabilities in Ethereum smart contracts but actually deploys the Quasar Remote Access Trojan (RAT).
The trend of malicious npm packages has escalated, with some utilizing Ethereum smart contracts for command-and-control (C2) server address distribution, creating a blockchain-powered botnet called MisakaNetwork.
Fraudulent libraries have also been identified in other ecosystems, including PyPI and RubyGems. These libraries use out-of-band application security testing (OAST) tools to exfiltrate sensitive data to attacker-controlled servers.
For example, the npm package adobe-dcapi-web
collects system information while evading detection on Russian endpoints. Similar packages from PyPI and RubyGems transfer sensitive information through DNS queries.
The misuse of OAST methods, originally intended for ethical security assessments, is a concerning trend where tools designed to uncover vulnerabilities are repurposed for malicious activities.
This raises concerns about the integrity of software supply chains and the potential for widespread exploitation.
To mitigate the risks associated with these malicious packages, developers are advised to be cautious when interacting with npm and other package registries.
Verifying package authenticity, double-checking package names, and thoroughly inspecting source code before installation are essential practices to protect against potential threats.
As the cybersecurity landscape evolves, developers must remain vigilant and proactive in protecting sensitive information and maintaining the integrity of their development environments.
The ongoing challenges posed by malicious packages highlight the vulnerabilities in open-source ecosystems.
These attacks not only affect individual developers but also have implications for the entire ecosystem and its users.