Your Agent SDK Carried the Payload: Hardening Agent Build Pipelines After the Mastra npm Compromise
TL;DR
In June, an attacker Microsoft attributes with high confidence to Sapphire Sleet took over a maintainer’s npm account and republished more than 140 packages of Mastra, a TypeScript framework for building agents, each with one new dependency: a dayjs lookalike whose postinstall script dropped a remote access implant. Any laptop or build agent whose install pulled in one of those versions could be hit, whether or not its code ever imported Mastra.
Install from a lockfile, make new releases wait, turn off unreviewed install scripts and reject provenance downgrades where you can. Keep deployment credentials and unrestricted network access out of the build job.
In a hurry? Jump to what happened, the response runbook if you think an affected version reached you, or the five controls, then come back for the why.
Agent teams pull fast-moving frameworks onto machines that hold model keys, deployment identities and package feed credentials. That makes a routine install worth treating as a security boundary.




