Mastra exposes the fragility of the supply chain npm: 144 compromised packages and a post-install that steals secrets

Author: Published 4 min de lectura 167 reading

The images in this article were generated with artificial intelligence. How we publish

A wide attack on the supply chain has committed up to 144 npm packages under the name space @ mastra, exploiting a massive installation of malicious versions that added a stranded dependence called "easy-day-js". According to analysis of several response teams, the vector was not clearly malicious code within each package, but a chain of installation: the false bookstore is run in a post-install hook, download a charger that disables the TLS validation, recover a second stage from a server controlled by the attackers and deploy a multiplatform stealer capable of exfiltering browser history, data from cryptomoneda coin extensions and persisting in Windows, macOS and Linux.

The attacker took advantage of the commitment of a legitimate ecosystem account to publish - in minutes - more than 140 malicious versions within the Mastra scope, taking advantage that the project policy allowed to publish with a personal token without demanding the atestaciones de provencia (SLSA) generated by the CI. This shows the practical difference between generating CI integrity tests and requiring them as a publication requirement: if the verification of signatures or atestations had been mandatory, the versions would have been automatically rejected.

Mastra exposes the fragility of the supply chain npm: 144 compromised packages and a post-install that steals secrets
Image generated with IA.

The implications are critical: popular packages such as @ mastra / core(with hundreds of thousands of weekly downloads) amplify the impact, and since the payload is run during the installation, a simple execution of npm install in a local development or CI runners can compromise secrets before even the developer imports the bookstore into its code. In addition to key theft, the ability of malware to delete prints and operate on background makes forensic detection difficult.

If your organization uses @ mastra / * or has recently run facilities, treat each host, runner and building environment as potentially compromised. Among the immediate actions to consider are: reverse to verified versions or to trusted commitments; revoke and rotate all the tokens and credentials that could have been used by runners or developers; revoke personal tokens and reissue with more restrictive policies; and rebuild images and runners from unchangeable origins. It is also essential to audit systems in search of postinstall execution signs: child processes launched from node _ modules folders, persistence entries (systemd services, launchd, programmed tasks, Run keys in Windows), and connections to the IP addresses observed by researchers (known C2 servers have been identified for the campaign to be checked).

In terms of medium-term and long-term mitigation, the lessons are clear: to require provenance and signature of packages, to limit and control NPM tokens with minimum permits, to use policies that verify signatures during installation and to promote reproducible and audited installation. Integrate SBOMs into the pipelines, restrict facilities in non-isolated runners and centralize approved units in a private proxy reduces the attack surface. Implementing egress controls and traffic monitoring from runners and developers helps to detect suspicious downloads at the time they occur.

Mastra exposes the fragility of the supply chain npm: 144 compromised packages and a post-install that steals secrets
Image generated with IA.

For those who manage open source projects, the recommendation is to review the management process of partners and scopes: revoke access to taxpayers who no longer participate, force publication from CI flows with SLSA atstations and audit personal tokens regularly. Good supply chain practices - such as requiring SLSA, signing artifacts and adopting verification policies at the facility - are no longer optional if you want to maintain confidence in external units.

If you need technical guidance on how to demand aestations and signatures in your workflow, the SLSA specification and security recommendations in the supply chain are useful resources: see the SLSA documentation in https: / / slsa.dev / and the community good practice guide on supply chain security in https: / / owasp.org / www-project-supply-chain-security /. For specific guidance on npm safety policies and practices see https: / / docs.npmjs.com / about-security.

In short, the incident affecting @ mastra / * highlights the fragility of the implicit confidence in the package ecosystem: protecting itself requires combining technical controls (signatures, atstations, runners isolation) with governance (access management and tokens). Act quickly to contain exposure, thoroughly audit affected environments and evolve your pipelines so that a single committed token can no longer cause a massive release of malicious code.

Coverage

Related

More news on the same subject.