Article Details
Scrape Timestamp (UTC): 2025-03-26 12:04:15.769
Source: https://www.bleepingcomputer.com/news/security/new-npm-attack-poisons-local-packages-with-backdoors/
Original Article Text
Click to Toggle View
New npm attack poisons local packages with backdoors. Two malicious packages were discovered on npm (Node package manager) that covertly patch legitimate, locally installed packages to inject a persistent reverse shell backdoor. This way, even if the victim removes the malicious packages, the backdoor remains on their system. The new tactic was discovered by researchers at Reversing Labs, who warned about the risk it entails, even if the packages weren't downloaded in large numbers. "It's not unusual to encounter downloaders on npm; they are maybe not as common as infostealers, but they are far from uncommon," explains Reversing Labs. "However, this downloader is worth discussing because of the exceptional strategies employed by the attackers to hide the malicious payload it delivered." Injecting a reverse shell The two packages discovered by Reversing Labs during routine security investigations on the open-source supply chain are 'ethers-provider2' and 'ethers-providerz.' The first package, which is still available on npm at the time of writing, is based on the popular 'ssh2' npm package but with a modified 'install.js' script that downloads a second-stage payload from an external source, which is executed and then deleted when finished to wipe all traces. The second stage monitors for the legitimate 'ethers' package, and once it finds it, it replaces the legitimate 'provider-jsonrpc.js' file with a trojanized version. The injected file now fetches a third-stage payload from the remote host, which enables a reverse shell using a modified SSH client, mimicking the legitimate SSH2 client behavior. What makes this attack so dangerous is even if 'ethers-provider2' is uninstalled, the backdoor on the ethers package won't be removed, and so the legitimate package remains infected. The 'ethers-providerz' package features similar behavior but targets the @ethersproject/providers package instead. Its ultimate goal based on code analysis is also to patch the target package with a reverse shell that points to the same malicious IP address (5[.]199[.]166[.]1:31337) Reversing Labs reports that early versions of this package had path errors, which prevented it from working as intended. The author has removed it from npm and may plan to reintroduce it after fixing those errors. The researchers also mentioned two more packages, namely 'reproduction-hardhat' and '@theoretical123/providers', that appear to be linked to the same campaign. Reversing Labs has included a YARA rule to detect known malware associated with this campaign, so developers should use it to scan their environments for remnant threats. In general, when downloading packages from package indexes like PyPI and npm, it is recommended to double-check their legitimacy (and that of their publisher) and examine their code for signs of risk, such as obfuscated code and calls to external servers. Top 10 MITRE ATT&CK© Techniques Behind 93% of Attacks Based on an analysis of 14M malicious actions, discover the top 10 MITRE ATT&CK techniques behind 93% of attacks and how to defend against them.
Daily Brief Summary
Two harmful npm packages, 'ethers-provider2' and 'ethers-providerz,' were uncovered, containing code that patches other legitimate packages to introduce backdoors.
The malicious packages exploit legitimate local installations by inserting a reverse shell backdoor, ensuring persistence even after the original malware is removed.
Reversing Labs identified the attack during a routine security review, noting the sophisticated nature of the threat due to its covert operations and persistence mechanisms.
The reverse shell patches legitimate files within the npm ecosystem, with 'ethers-provider2' targeting the 'ssh2' package and 'ethers-providerz' aiming at the @ethersproject/providers.
Even if the original malicious package is uninstalled, the patched legitimate package retains the malware, continuing to compromise the system.
Some earlier versions of these packages contained flaws that prevented full functionality, but corrections and reintroductions seem likely in the future.
Reversing Labs also developed a YARA rule to aid developers in scanning their environments for remnants of these and related threats.
General advice given includes stringent verification of package legitimacy and scrutiny of package code for any suspicious elements like obfuscated commands or external calls.