Attackers are increasingly exploiting Node.js, a widely used open-source JavaScript runtime, to deliver advanced malware and steal sensitive data. These threats have evolved, leveraging both Node.js script execution and compiled malware to bypass traditional security mechanisms. Its cross-platform capabilities make it popular among developers for building scalable applications, but this same flexibility is now being weaponized by cybercriminals. Attackers inject malicious code into Node.js executables or npm packages, enabling them to evade detection while persisting within compromised environments.
One prominent technique involves malvertising, where attackers place malicious ads on legitimate websites to trick users into downloading infected software. These trojanized installers, often bundled with Node.js and Wix, drop malicious DLLs that use Windows Management Instrumentation (WMI) for system reconnaissance. The malware establishes persistence through scheduled tasks that execute PowerShell commands, allowing attackers to maintain access. This attack model shows how threat actors exploit the popularity of software tools by embedding malware within them to avoid detection.
Supply chain attacks have also become a primary focus for cybercriminals, as they hijack legitimate npm packages or create lookalike ones to distribute malware.
A notable example is the malicious pdf-to-office npm package, which targeted cryptocurrency wallet software like Atomic Wallet and Exodus. This package injected obfuscated JavaScript that rerouted cryptocurrency transactions, abusing trusted npm packages and the Electron framework’s architecture. Tools like the pkg npm module further package Node.js applications into standalone executables, facilitating the spread of malware like XMRig miners and information stealers.
Emerging attack vectors involve direct script execution via Node.js in command-line environments, allowing attackers to run JavaScript that steals credentials and establishes persistence.
Malicious scripts are often obfuscated to evade antivirus detection, with attackers using tools like Cloudflare tunnels to disguise their command-and-control traffic. Few antivirus signatures exist for Node.js-compiled binaries, especially those larger than 35MB, making detection more difficult. To mitigate these threats, organizations are advised to download software only from trusted sources, monitor script execution, and deploy EDR/XDR solutions for suspicious activity detection.