Mastra AI Hit By npm Compromise
The unknown threat actor gained unauthorized access to legitimate npm accounts, allowing them to inject malicious dependencies into widely used packages.

The unknown threat actor gained unauthorized access to legitimate npm accounts, allowing them to inject malicious dependencies into widely used packages.
June 17, 2026 | 2 min read

Microsoft security researchers have uncovered a significant supply chain attack targeting the Mastra-AI npm ecosystem, resulting in the compromise of over 80 packages via account takeover. The incident used a "phantom dependency" injection technique designed to evade detection while establishing persistent C2 communication.
The unknown threat actor gained unauthorized access to legitimate npm accounts, allowing them to inject malicious dependencies into widely used packages, most notably mastra@1.13.1. The attack leverages a typosquatting strategy; the injected dependency, easy-day-js@1.11.22, masquerades as the legitimate dayjs library. Mastra has an open-source platform for building AI agents, as well as some add-on capabilities for observability and other functions.
Mastra co-founder Sam Bhagwat said that the company has confirmed the compromise and said the incident was the result of one of the product’s maintainers being compromised.
“Reports are accurate. We have been hit by a supply chain attack. A malicious postinstall script that exfiltrated credentials and then self-deleted was added to specific versions of our packages. The incident is over -- we have unpublished or deprecated the relevant package versions,” Bhagwat said.
“The root cause is that one of our maintainers was compromised. Between 6:12 PM and 6:37PM PT yesterday, a token associated with their account published 116 malicious packages, almost all in the @mastra/ namespace.”
Upon installation, the malicious dependency executes a post-install script (setup.cjs), which functions as a loader for the secondary payload.
Technical Analysis of the Payload
The setup.cjs script has a number of capabilities:
Affected Packages
The breach is extensive, affecting more than 100 packages within the Mastra-AI ecosystem. Key identified packages include:
Remediation Recommendations
Given the nature of the post-install exploitation, security teams should prioritize the following actions:
Mastra’s Bhagwat said the company has disabled token-based publishing capabilities for npm and is now requiring MFA for all publishes.
June 17, 2026 | 2 min read
Dennis Fisher is an award-winning journalist and author. He is one of the co-founders of Decipher and Threatpost and has been writing about cybersecurity since 2000. Dennis enjoys finding the stories behind the headlines and digging into the motivations and thinking of both defenders and attackers. He is the author of 2.5 novels and once met Shaq. Contact: dennis at decipher.sc.