
Sophisticated Phishing Attack Bypasses 2FA to Hijack Popular NPM Package
In a stark reminder of the growing threats to the software supply chain, a recent security incident has highlighted how even security-conscious developers can fall victim to highly sophisticated phishing attacks. A popular npm package maintainer lost control of their account after being targeted by a meticulously crafted campaign, leading to the distribution of malicious code to an unknown number of users.
This event serves as a critical case study for all developers and organizations, demonstrating that even multi-factor authentication (2FA) is not an impenetrable shield against a determined attacker. Understanding the anatomy of this attack is the first step toward building a stronger defense.
The Anatomy of the Account Takeover
The attack wasn’t a brute-force attempt or a result of a weak password. Instead, it relied on clever social engineering and a flawless execution of a credential harvesting scheme.
Here’s how the threat actors successfully gained access:
The Deceptive Email: The developer received an email that appeared to be a legitimate security notification from npm. The message claimed that their two-factor authentication had been removed and prompted them to click a link to reset it and secure their account. The email was expertly designed, using official-looking branding and language that created a sense of urgency.
The Credential Harvesting Trap: The link in the email did not lead to the official
npmjs.comwebsite. Instead, it directed the developer to a near-perfect replica of the npm login page, hosted on a different domain. This fake page was designed to look and function exactly like the real one, reducing the chance of suspicion.Real-Time 2FA Interception: When the developer entered their username and password on the fake site, the attackers instantly captured them. The fraudulent page then presented a prompt for the 2FA one-time password (OTP). As the developer entered their valid 2FA code from their authenticator app, the attackers immediately used the captured credentials—username, password, and the time-sensitive 2FA code—to log into the real npm website in real-time.
Because the attackers used the 2FA code within its short window of validity, they successfully bypassed the security measure and gained full control over the developer’s account.
The Aftermath: Malicious Code in the Wild
Once in control, the threat actors wasted no time. They published new, malicious versions of the compromised npm package. The tainted code was identified as “protestware,” designed to perform destructive actions on systems it was installed on. Specifically, the malware would check the system’s IP address and, if it was located in Russia or Belarus, it would begin deleting files and overwriting them with a heart emoji.
The npm security team acted quickly to remove the compromised package versions, but the incident underscores the significant risk of software supply chain attacks. A single compromised developer account can have a ripple effect, impacting thousands of projects and applications downstream.
How to Protect Your Developer Accounts from Advanced Phishing
This attack proves that vigilance is paramount. Simply having 2FA enabled is not enough. Developers must adopt a more skeptical and security-first mindset. Here are actionable steps you can take to protect your accounts from similar attacks:
Scrutinize Every Security Email: Always treat unexpected security alerts with suspicion. Carefully inspect the sender’s email address and email headers. Attackers often use domains that are visually similar to legitimate ones (e.g.,
npm-security.cominstead ofnpmjs.com).Never Click Links in Emails: The safest practice is to avoid clicking links in security-related emails altogether. If you receive an alert, close the email and manually navigate to the official website by typing the URL directly into your browser. Log in there to check for any notifications.
Use a Password Manager: Password managers with browser extensions provide an excellent layer of defense. They associate login credentials with specific domains. If you land on a phishing site, the password manager will not auto-fill your credentials, which is a massive red flag that you are not on the legitimate website.
Upgrade to Phishing-Resistant 2FA: While OTP apps are good, they are not immune to real-time phishing. The gold standard for authentication is using a hardware security key that supports FIDO2/U2F protocols. These physical keys verify that you are on the correct domain before sending an authentication response, making it virtually impossible for a phishing site to intercept your login.
Enable Enhanced Login Verification on NPM: For npm accounts specifically, enable the “Enhanced Login Verification” feature in your account settings. This requires you to re-authenticate—often via a one-time code sent to your email—before performing sensitive actions like changing your password or publishing new package versions.
The security of the entire open-source ecosystem relies on the diligence of individual maintainers. By learning from these incidents and hardening our personal security practices, we can collectively build a more resilient and trustworthy software supply chain.
Source: https://www.helpnetsecurity.com/2025/09/09/npm-packages-supply-chain-compromise/


