Join our Newsletter — 33% off our NHI Course

Mastra supply chain attack: what AppSec teams need to re-check now

 

(@nhi-mgmt-group)
Member Moderator
Joined: 1 year ago
Posts: 16521
Topic starter  

TL;DR: A one-line dependency change in the compromised Mastra npm scope let npm resolve a malicious package that executed code at install time, hid behind a clean-looking carrier package, and enabled follow-on persistence and credential theft, according to Corgea. This is a reminder that published registry metadata, not just source diffs, now defines the real supply-chain trust boundary.

Editorial analysis by NHI Mgmt Group, based on content published by Corgea: “Mastra npm scope takeover used easy-day-js to Trojanize 141-143 packages”.

By the numbers:

  • Corgea says the attack affected 141 compromised @mastra/* packages plus the top-level mastra and create-mastra packages published on 17 June 2026.
  • Corgea says fresh installs that resolved [email protected] could execute attacker-controlled code at install time.

Key questions

Q: What breaks when a package adds a malicious dependency through semver?

A: A clean-looking package can still execute attacker-controlled code if a version range resolves to a malicious patch release.

Q: Why do credential-harvesting supply chain attacks create so much downstream risk?

A: Because stolen machine credentials are often more reusable than the code path that exposed them.

Q: What are the signs that a package release may have been tampered with?

A: Warning signs include a registry release with no matching Git tag, no corresponding commit history, unusual publication timing, and rapid community alerts from security researchers.

Practitioner guidance

  • Audit dependency ranges for semver-based carrier risk Review package.json, lockfiles, and published tarballs for dependency ranges that can resolve to newly added patch releases, especially where the dependency name resembles a benign or trusted package.
  • Block or inspect install-time scripts in high-trust build paths Treat postinstall and similar hooks as execution events and require extra approval for packages that run code during installation on CI runners or developer workstations.
  • Verify package provenance before accepting releases Check whether a package normally publishes from CI, whether the release came from an unexpected account, and whether registry metadata changed at the same time as the code.

Bottom line: A one-line dependency change was enough to turn a trusted-looking npm package into an install-time execution path.

Explore further

View Full Forum →  |  NHI Foundation Course →  |  Our Services →  |  Read the full analysis →



   
Quote
(@mr-nhi)
Member Moderator
Joined: 5 months ago
Posts: 17012
 

Semver carrier packages are now a real trust boundary: the attack did not rely on visibly malicious application code, only on a dependency range that resolved to a harmful patch release. That means package review has to include registry metadata, publish provenance, and install-time behaviour, not just repository contents. For AppSec teams, this is a release-governance problem as much as a code-review problem.

A few things that frame the scale:

  • 24,008 unique secrets were exposed in MCP configuration files in 2025 alone, the protocol's first year of widespread adoption, according to the State of Secrets Sprawl 2026.
  • 92% of organisations expose NHIs to third parties, raising concerns about supply chain security, according to the Ultimate Guide to NHIs.

A question worth separating out:

Q: How should teams respond when a fresh install could have executed malicious code?

A: Treat the installation as a host compromise until proven otherwise. Isolate the machine, preserve lockfiles and package caches, inspect for install-time hooks and follow-on processes, and rotate any secrets that were reachable from the affected environment. If persistence or C2 is present, scope the incident as an intrusion, not a dependency cleanup.

👉 Read our full editorial: Mastra npm supply chain compromise shows semver can hide malicious code



   
ReplyQuote
Share:

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.