Cybersecurity researchers have uncovered two malicious npm packages, ethers-provider2 and ethers-providerz, designed to infect locally installed packages. The first package, downloaded 73 times since March 15, 2025, modifies the widely used ethers package. It works by replacing a legitimate file with a counterfeit version that fetches and executes a reverse shell payload from a remote server. The second package, ethers-providerz, targets the @ethersproject/providers package with similar tactics, although it has been removed by the malware author due to errors.
The malicious payload injected by ethers-provider2 operates in multiple stages.
Upon installation, it runs a trojanized version of the ssh2 npm package that downloads a secondary malware payload. This payload, in turn, watches for the ethers package and replaces one of its files, creating a reverse shell backdoor. This backdoor connects to the attacker’s server over SSH, allowing persistent access even if the malicious packages are uninstalled, as the modified ethers package remains compromised.
The attack highlights a novel approach to software supply chain attacks, as the compromise occurs locally rather than through the npm registry. Even if users remove the malicious packages, the backdoor persists within the compromised ethers package. Researchers emphasize that this tactic could serve as a persistent threat, as attackers can maintain long-term access without triggering typical security defenses or raising alarms from package downloads.
ReversingLabs advises developers to carefully scrutinize all packages downloaded from open-source repositories.
The malicious packages found in this attack were not widely downloaded, yet they demonstrate the potential for significant risk. Developers should check the legitimacy of packages, especially those that appear unusual or have obfuscated code, and use security tools like YARA rules to detect remnants of these types of threats.