Sophia
Hart

Mastra npm Supply-Chain Attack Compromises 144 AI Framework Packages

Sophia Hart

Jun 18, 2026

6 min read

mastra npm compromise

TL; DR

  • Attackers used a hijacked current contributor’s npm account to publish malicious Mastra package versions.
  • A malicious dependency called easy-day-js delivered malware through 144 compromised Mastra packages.
  • The payload was executed during npm installation through a malicious postinstall hook.
  • Developer workstations, CI runners, and build environments may be exposed before affected packages are imported or used in application code.

The Mastra npm compromise highlights how a single overlooked access permission can ripple through an entire software ecosystem. Security researchers reported that 144 npm packages associated with the Mastra scope (@mastra/*) were modified to include a dependency on a malicious third-party package after attackers hijacked a current contributor’s npm account.

Mastra is an open-source JavaScript and TypeScript framework used to build AI applications. Public reporting indicates the attack relied on trusted package distribution mechanisms rather than a disclosed application vulnerability or user-driven malware download. Instead, attackers abused trust already embedded in the package distribution process.

For organizations building or deploying AI-powered applications, the attack serves as a reminder that software supply-chain security extends beyond code reviews and dependency scanning. Access governance can be just as important.

Improve enterprise security using Hexnode

How a Trusted Contributor Account Became the Entry Point

Researchers traced the malicious package publications to the npm account of a current Mastra contributor. Public reporting indicates the account retained publishing permissions after the contributor was no longer actively involved with the project.

According to researchers, the attack was enabled by:

  • A current contributor account that still had publishing access.
  • Unauthorized access to that account.
  • The ability to publish updates across the Mastra package scope.

No vulnerability in Mastra itself has been publicly identified as the initial cause of the incident. Instead, attackers appear to have abused trusted publishing access to distribute malicious package updates.

This incident highlights how unmanaged publishing permissions can become a software supply-chain risk, particularly in projects with multiple contributors and maintainers.

Why a Single Dependency Reached 144 Packages

Researchers found that 144 compromised packages within the Mastra scope included a dependency on easy-day-js, a malicious clone of the legitimate Day.js library.

According to SafeDep, easy-day-js was initially published as a clean copy of Day.js before later versions introduced malicious functionality.

Rather than modifying each package individually, the attackers used the dependency to distribute malware across affected package versions. The incident illustrates how a single compromised dependency can extend risk across an entire package ecosystem.

Inside the easy-day-js Payload Chain

The malware chain relied on npm’s package installation process rather than application execution. Researchers reported that easy-day-js contained a malicious post-install script. When an affected package was installed, the script automatically executed without requiring developers to import the library into their projects.

According to public analyses, the malware:

  • Executed an obfuscated JavaScript loader.
  • Retrieved a second-stage payload from attacker-controlled infrastructure.
  • Disabled TLS certificate validation.
  • Launched a detached background process.
  • Attempted to remove loader artifacts after execution.

Researchers reported that the final payload was capable of:

  • Collecting browser history.
  • Harvesting data from more than 160 cryptocurrency wallet browser extensions.
  • Installing persistence mechanisms on Windows, macOS, and Linux systems.
  • Exfiltrating data to command-and-control infrastructure.
  • Receiving and executing additional attacker commands.

The payload executed during installation, potentially exposing developer environments before the affected package was actively used by an application.

Why Developer Environments Face Elevated Risk

The Mastra compromise affected packages used in AI development workflows, where developer systems may store high-value credentials and operational secrets. Examples include:

  • Model provider API keys.
  • Cloud platform credentials.
  • GitHub and GitLab access tokens.
  • Package publishing credentials.
  • Kubernetes secrets.
  • Deployment automation tokens.

The malware executed during installation, potentially exposing affected systems before developers even used the package. A compromised developer workstation may provide access to build systems, deployment pipelines, cloud environments, and software distribution channels.

As organizations expand AI development initiatives, frameworks that operate within these workflows can expose valuable credentials and operational access if compromised through a supply-chain attack.

Operational Summary

Category Details
Incident Type Software supply-chain attack
Affected Platform Packages within the Mastra scope (@mastra/*)
Packages Impacted 144
Distribution Method Malicious dependency insertion
Malicious Package easy-day-js
Execution Method npm postinstall hook
Primary Risk Endpoint compromise and potential credential theft
High-Value Exposure Points Developer endpoints and CI/CD systems

What Security Teams Should Verify First

Although the full impact of the incident remains under investigation, organizations should review systems that may have installed affected package versions.

Developer Workstations

Review endpoint telemetry for suspicious Node.js activity, persistence creation, and unusual outbound connections.

Build Pipelines

Examine CI/CD runners and build logs for affected package versions and installation activity.

Secrets and Tokens

Consider rotating repository tokens, cloud credentials, API keys, package publishing tokens, and deployment secrets associated with affected systems.

Package Governance

Review contributor permissions, publishing controls, and dependency monitoring processes for similar exposure points.

building a cybersecurity framework
Featured resource

Building a cybersecurity framework for your enterprise

Explore cybersecurity frameworks and how UEM strengthens security, visibility, compliance, and organizational resilience.

DOWNLOAD

How Hexnode Supports Investigation and Response

Incidents like the Mastra compromise often require teams to determine which systems installed affected packages, whether malicious activity occurred after installation, and what devices may need remediation.

Hexnode XDR unifies endpoint telemetry, automated alert correlation, process analysis, and threat hunting capabilities to support investigation and response for malicious software execution on managed endpoints. Analysts can use the threat hunting query engine of  XDR to search historical process and endpoint event data for indicators of compromise across managed endpoints.

Hexnode UEM helps organizations maintain device compliance, enforce configuration policies, manage applications, and perform remote actions across supported Windows, macOS, and Linux endpoints.

Conclusion

The Mastra npm compromise demonstrates how a single compromised account can affect an entire package ecosystem when trusted publishing access is abused. The incident also shows how malware delivered through software dependencies can reach developer workstations and build environments before affected code is ever used.

As organizations expand AI development initiatives, maintaining control over contributor access, package publishing permissions, and dependency monitoring remains essential for reducing software supply-chain risk.

FAQs

The Mastra npm compromise involved attackers publishing malicious versions of 144 packages within the Mastra package scope after hijacking a current contributor’s npm account.

easy-day-js is a malicious npm package that cloned the legitimate Day.js library and was used to deliver malware through compromised Mastra package versions.

The malicious dependency used an npm postinstall hook, allowing malware to run during package installation without requiring developers to import or execute the affected package.

Share

Sophia Hart

A storyteller for practical people. Breaks down complicated topics into steps, trade-offs, and clear next actions—without the buzzword fog. Known to replace fluff with facts, sharpen the message, and keep things readable—politely.