Cybersecurity researchers have recently uncovered a backdoor in the widely-used @solana/web3.js npm library, a crucial package for developers building Node.js and web apps that interact with the Solana blockchain. The backdoor was found in versions 1.95.6 and 1.95.7, both of which have been removed from the npm registry. The malicious code was designed to steal private keys from developers and users, potentially enabling attackers to drain cryptocurrency wallets. With over 400,000 weekly downloads, this npm package is a significant target for attackers seeking to exploit vulnerabilities in the cryptocurrency ecosystem.
The backdoor specifically inserted an ‘addToQueue’ function in version 1.95.7, which was crafted to exfiltrate private keys via CloudFlare headers. These exfiltrated keys were then sent to a command-and-control (C2) server, “sol-rpc[.]xyz,” which has since been taken down. The attack appears to have been carried out by compromising a publish-access account for the library, likely through a phishing attack. Once the attackers gained access, they were able to publish the malicious versions that contained the backdoor code.
The compromised versions only affected projects that directly handled private keys and were updated during a specific time window on December 2, 2024. Developers who used these versions are urged to update to the latest release immediately to prevent any potential loss of funds. Additionally, users are advised to rotate their authority keys if they suspect any compromise of their private keys. The maintainers of the npm package have acknowledged the issue and are working to ensure the safety of the library moving forward.
This incident highlights the growing trend of supply chain attacks within the open-source ecosystem, where attackers exploit the trust placed in widely-used libraries. Similar attacks in the past have targeted packages like “crypto-keccak” and “crypto-jsonwebtoken,” which masquerade as legitimate libraries while stealing user credentials and wallet data. As the open-source community continues to grow, it is vital for developers to remain vigilant and follow best practices for securing their dependencies to avoid falling victim to such attacks.
Reference: