How a 16-Month-Old Dormant Account Triggered a Major npm Supply Chain Attack
A sophisticated supply chain attack targeting the Mastra npm ecosystem has compromised more than 140 software packages with infostealer malware, sending shockwaves through the developer and cybersecurity communities. The Mastra npm supply chain attack was made possible by a single forgotten credential: a dormant contributor account that had not been used in 16 months but still retained full publishing rights on the npm registry. Attackers exploited this oversight to silently inject malicious payloads into dozens of widely used packages before the intrusion was detected.
Mastra is a popular open-source framework used by developers to build, test, and deploy AI agents and applications. Its packages are downloaded by thousands of development teams globally, making it an attractive and high-impact target for supply chain attackers. The incident highlights one of the most persistent and underappreciated vulnerabilities in modern software development: the sprawling, often unmonitored attack surface created by open-source package ecosystems like npm.

According to cybersecurity firm SafeDep, the attackers gained access to the account of a former Mastra contributor. Despite being inactive for over a year, the account had never been properly offboarded — it still held the permissions needed to publish new package versions to the npm registry. Attackers exploited this gap, using the account to push malware-laced versions of Mastra's packages without triggering any immediate alerts from the platform's trust mechanisms.
What the Mastra Malware Actually Does — and Why Crypto Wallet Users Are Most at Risk
The malicious code injected into the compromised packages is not a simple proof-of-concept. Researchers from multiple cybersecurity firms — including Socket, StepSecurity, JFrog, and Microsoft — have published detailed analyses confirming that the malware is a fully operational infostealer with platform-specific payloads designed for Linux, macOS, and Windows environments.
The infostealer is engineered to harvest a wide range of sensitive data from infected systems. Most critically, it targets browser history and stored data from more than 160 browser extensions associated with cryptocurrency wallets. For developers or business owners who use browser-based crypto wallets alongside their development environments, the risk is significant: credentials, seed phrases, and session tokens could all be silently exfiltrated without the user's knowledge.
Beyond data theft, the malware also establishes persistence mechanisms — meaning it is designed to survive a system reboot. This is a hallmark of professionally developed malware and indicates that the attackers were not interested in a one-time smash-and-grab. They wanted sustained access to infected developer machines, potentially enabling further reconnaissance, lateral movement within corporate networks, or ongoing credential harvesting over an extended period.
"Developers tend to trust packages published under familiar project namespaces. That's exactly what makes supply chain attacks through hijacked contributor accounts so devastatingly effective — the malware arrives wrapped in a layer of institutional trust."
— Security researcher, SocketWhat Microsoft, Socket, and JFrog Are Recommending Developers Do Right Now
The response from the cybersecurity community has been swift and coordinated. Multiple firms have released Indicators of Compromise (IoCs) — technical signatures and file hashes that allow organizations and individual developers to scan their systems and determine whether they have installed any of the compromised package versions. StepSecurity, JFrog, and Microsoft have all published detailed IoC lists alongside their technical analyses of the attack.
Microsoft's guidance is particularly actionable for development teams: downgrade affected Mastra packages to older, verified clean versions immediately, and enforce the use of lockfiles in your project dependencies. Lockfiles (such as package-lock.json or yarn.lock) pin dependencies to specific, audited versions, preventing npm from silently pulling in updated — and potentially compromised — package versions during fresh installs.

Socket, a firm that specializes in open-source supply chain security and is a recognized authority in this space, has issued a pointed warning for those with significant cryptocurrency holdings: if you have a high-value crypto wallet on any machine that installed affected Mastra packages, transfer funds to a new wallet as a precautionary measure. This reflects the severity of the threat — even if you are unsure whether your system was compromised, the potential financial loss may warrant the precaution.
Why the npm Ecosystem Remains a Prime Target for Supply Chain Attackers
The Mastra incident is far from isolated. Supply chain attacks targeting open-source package registries like npm, PyPI, and RubyGems have surged in recent years. According to research published by Sonatype in their annual State of the Software Supply Chain report, malicious packages in open-source ecosystems have grown at a significant rate year over year, with npm consistently representing the largest volume of reported incidents due to the sheer scale of its package catalog and contributor base.
The attack vector used here — compromising a dormant but still-privileged contributor account — is a well-documented technique in the supply chain threat playbook. Similar tactics were employed in the high-profile compromise of the event-stream npm package, as well as in attacks targeting the Python Package Index (PyPI). In many cases, the window of opportunity exists not because of a technical flaw in the registry itself, but because of poor access hygiene: contributors leave projects, but their accounts and permissions are never revoked.
| Attack Vector | Description | Mitigation |
|---|---|---|
| Dormant account hijacking | Inactive contributor accounts retain publish rights; credentials compromised after extended inactivity | Regularly audit and revoke permissions for inactive contributors |
| Malicious package version push | Attacker publishes new malware-laced versions under a trusted package name | Use lockfiles; monitor package integrity with tools like Socket or Snyk |
| Persistence mechanisms | Malware survives system reboots for long-term access | Run endpoint detection tools; audit startup scripts and scheduled tasks |
| Crypto wallet targeting | Infostealer harvests data from 160+ crypto wallet browser extensions | Move high-value assets to a new wallet if exposure is suspected |
| Cross-platform payloads | Unique malware variants for Linux, macOS, and Windows | Ensure endpoint protection is active on all developer workstations regardless of OS |
For organizations building on AI frameworks — a rapidly growing category as more companies integrate AI agents into their products — this attack is a stark reminder that the dependencies underpinning cutting-edge tooling carry their own risk profile. Mastra's focus on AI agent development means its users are often in fast-moving, innovation-first environments where dependency auditing may not always receive the attention it deserves. That combination of broad adoption and lighter security scrutiny makes AI development frameworks an increasingly attractive target.
The Forgotten Security Principle That Could Have Prevented This Attack
At the core of this incident is a failure of access lifecycle management — specifically, the principle of least privilege and timely privilege revocation. When a contributor leaves an open-source project or becomes inactive, their account and associated publishing rights should be revoked as a standard offboarding step. This is a foundational security control that is widely understood but inconsistently applied, particularly in volunteer-driven open-source communities where formal offboarding processes rarely exist.
The npm registry does offer two-factor authentication (2FA) for package publishers, and npm has made 2FA mandatory for maintainers of high-impact packages. However, as this attack illustrates, mandatory 2FA is only effective if active maintainers are the ones who hold publishing rights. A dormant account — even one with 2FA enabled — remains a liability if its credentials have been exposed through data breaches, phishing, or credential stuffing attacks over the months or years it sat unused.
Originally reported by Security.NL. Summarised and curated by European Purpose.