StegaBin Campaign Compromises 26 npm Packages, Deploys Multi-Stage Credential Stealer Using Typosquatting Techniques

StegaBin Campaign Exploits 26 Malicious npm Packages to Deploy Multi-Stage Credential Stealer

A recent software supply-chain attack, identified as StegaBin, has infiltrated the npm ecosystem, compromising 26 packages over a two-day period. This campaign employs typosquatting techniques and a multi-stage infection process to discreetly deploy credential-stealing malware on developers’ systems.

Infection Mechanism:

The attack initiates during the installation of the malicious npm packages. Each package’s `package.json` file contains an install script that automatically executes upon installation. This script triggers a loader designed to appear as a legitimate cryptographic library, which then decodes hidden command-and-control (C2) addresses embedded within seemingly innocuous Pastebin content. The malware cycles through multiple Vercel-hosted domains until it connects with an active C2 server, from which it downloads and executes additional payloads.

Payload and Persistence:

Once the connection is established, the malware installs a remote access trojan (RAT) that communicates with a specific IP address and port. This RAT is capable of downloading modules that target various sensitive data, including Visual Studio Code settings, Git repositories, SSH keys, browser data, and local secret files. To maintain persistence, the malware modifies Visual Studio Code’s `tasks.json` file, inserting a malicious task that runs automatically when a project folder is opened. The malicious command is obfuscated by preceding it with numerous spaces, effectively hiding it from casual inspection.

Implications and Recommendations:

The StegaBin campaign underscores the critical importance of vigilance in managing software dependencies. Developers are advised to:

– Verify Package Authenticity: Scrutinize package names and sources to avoid typosquatting traps.

– Review Installation Scripts: Examine `package.json` files for unexpected install scripts that may execute malicious code.

– Monitor Network Activity: Be alert to unusual network requests during package installation, which may indicate malicious behavior.

– Implement Security Tools: Utilize security tools that can detect and block malicious packages and scripts.

By adopting these practices, developers can mitigate the risks associated with supply-chain attacks and protect their systems from unauthorized access and data theft.