An 88-minute automated campaign targeting 8 million weekly downloads; what happened, who is exposed, and how to remediate.
Tl;dr: on June 17, 2026, North Korean state actor Sapphire Sleet compromised 140+ packages in the @mastra npm scope, exposing +8 million weekly downloads to a credential-stealing, persistent backdoor delivered through a routine package install.
What Happened
@mastra is an open-source TypeScript framework for building AI agents and workflows, with over 8 million weekly downloads across its packages, a foundational tool in enterprise and startup AI development pipelines worldwide.
At some point prior to June 17, 2026, North Korean hackers Sapphire Sleet social-engineered a @mastra publisher into clicking a malicious link via a fake LinkedIn account, gaining access to a stale npm (Node Package Management) account with publish rights across all @mastra packages.
On June 17, that access was weaponized.
From there, an 88-minute automated campaign started, which pushed a hidden malicious dependency into 140+ packages across the mastra and @mastra scopes on the npm registry.
Anyone who ran @mastra npm installs during that window automatically downloaded malware that stole credentials, targeted crypto wallets, and in some cases installed a persistent backdoor giving the attackers full remote control of the machine. The backdoor survived reboots and remained invisible to antivirus engines.
Who Was Affected
The attack is a high risk for any organization whose build pipelines automatically pull mastra dependencies.
Any developer workstation or CI/CD pipeline that ran npm install or npm update on any @mastra package between roughly June 16, 07:05 UTC and June 17, 01:20 UTC, per Microsoft’s attack timeline, could have been affected.
With packages reaching up to 8 million weekly downloads, the blast exposure is widespread.
Sapphire Sleet focuses primarily on the finance sector, including cryptocurrency, venture capital, and blockchain organizations; environments where credentials and API keys have direct monetary value, so these organizations should pay close attention to their repositories.
Developer machines and CI runners held the most valuable targets: credentials spanning cloud providers, source code repositories, package registries, deployment pipelines, and cryptocurrency wallets were all accessible to the malware without requiring administrative privileges.
A compromised CI or release job extends the blast radius beyond the runner itself. Any artifact produced after the malicious install, including npm packages, container images, binaries, and deployment archives, must be treated as potentially compromised.
Running inside Docker does not automatically limit the damage. Build-time secrets, registry credentials, cloud tokens, and SSH keys can all be present during container construction, and that assumption must be verified from build configuration and telemetry, not taken for granted.
Two-Stage Delivery Pattern and a 7-Step Progression
The fake package was delivered via a two-phase strategy:
Phase 1: the first published version (easy-day-js@1.11.21) was clean, containing only legitimate code, no postinstall hook. This version was published on June 16, at 07:05 UTC.
Phase 2: the second version (easy-day-js@1.11.22) was the weaponized one. This one added the payload (setup.cjs) and the postinstall hook. The dayjs.min.js file is byte-identical (the exact same binary sequence) between both versions. This version was published on June 17, 2026, at 01:20 UTC.
According to Kirill Boychenko, senior threat intelligence analyst at Socket, the operational pattern bears clear similarities to the Axios compromise, which has been attributed to the North Korean threat cluster UNC1069.
The entire attack followed a 7-step progression:
1. Account takeover: the attackers seized control of ehindero, an npm account belonging to a listed @mastra maintainer that held publish rights across the entire @mastra package scope.
2. Fake package (typosquat) setup: before the main attack, the threat actor published easy-day-js, a fake package designed to impersonate the legitimate dayjs library, using an anonymous email account.
3. Scope-wide poisoning: with the compromised maintainer account, the attackers released new versions of 140+ packages across the @mastra scope. Each updated package had easy-day-js@^1.11.21 injected as a new dependency, and every poisoned version was published under the latest tag to maximize adoption.
4. Delivery: any developer or CI/CD pipeline that ran npm install was automatically served the compromised versions. npm's semantic versioning logic resolved the ^1.11.21 range to 1.11.22 (the version carrying the malicious postinstall hook).
5. On-install execution: the moment the package installed, the postinstall hook fired an obfuscated 4,572-byte dropper. The dropper disabled TLS verification to avoid connection checks, wrote files to disk recording its successful execution, and called back to the attackers' remote server to signal a successful compromise and receive further instructions.
6. Second-stage deployment: the dropper downloaded the next stage of the malware from the attackers' server, saved it to disk under a random filename to avoid detection, and ran it as a hidden background process with no visible window, making it invisible to the user.
7. Post-compromise: on machines where the implant successfully called back to C2, Sapphire Sleet pushed a PowerShell backdoor from a separate infrastructure layer, established multiple persistence mechanisms, added exclusions to Microsoft Defender to suppress detection, and installed a service-level implant running under the SYSTEM security context.
Why Detection-Based and NPM Audit Engines Missed the Attack
The @mastra attack didn’t have a signature, meaning traditional vulnerability scanners had nothing to match against and no way to raise an alert during active exploitation.
Remember, the clean version came first, the weaponized one 18 hours later. The clean easy-day-js@1.11.21 would have returned a clean verdict; 1.11.22 carried the payload.
For organizations and individuals relying solely on detection-based engines, the attack was effectively invisible until Microsoft published its initial findings on the evening of June 17.
Recommended Remediation Steps
1. Treat it as a full compromise from the start: if the malicious package installed with lifecycle scripts enabled, assume infection code ran. Do not treat it as a routine dependency issue.
2. Freeze all automation: pause release workflows, deployments, scheduled updates, and package publishing from affected environments. If a compromised runner has tokens capable of modifying repositories or publishing packages, continued automation can make things worse.
3. Isolate affected machines: disconnect affected workstations or persistent runners from the network while keeping an evidence collection channel open. For ephemeral CI runners, prevent reuse and preserve snapshots or logs before terminating.
4. Preserve evidence: collect npm logs, shell history, process execution telemetry, EDR events, DNS and proxy logs, firewall records, CI job logs, lockfiles, and persistence definitions. Record all times in UTC.
5. Rebuild compromised systems: rebuild CI runners and build machines from a trusted base rather than cleaning in place. For developer workstations, a full OS rebuild provides stronger assurance than deleting known malicious files.
6. Rotate credentials from a clean device: rotating credentials on a compromised machine can immediately expose the replacement. Prioritize in this order: npm tokens, source control tokens, CI/CD identities, cloud provider keys, container registry credentials, SSH keys, Kubernetes credentials, database credentials, LLM API keys, and browser sessions. For cryptocurrency wallets on confirmed compromised machines, move assets to a new wallet generated from a fresh seed phrase on a clean device.
7. Review all downstream artifacts: any artifact produced after the malicious install must be treated as potentially infected and rebuilt from a verified clean state.
8. Validate recovery: recovery is only complete when all of the following are confirmed: affected versions no longer resolve, easy-day-js is absent from all manifests and caches, persistence has been removed or the host rebuilt, no suspicious Node.js processes remain, network controls block known attacker infrastructure, and audit logs show no continuing unauthorized use.
Detect What Signatures Miss
The @mastra attack is a precise use case of where signature-based detection ends and behavioral analysis begins. In this case, all conditions which make traditional scanning ineffective were met: no CVE, no malicious code in @mastra's own source, and a clean first version.
All conditions ultimately reduced the effectiveness of traditional signature-based scanning during the earliest stages of the attack.
Behavioral analysis addresses a different part of the problem by observing what a package does when it executes. Behaviors such as unexpected postinstall execution, outbound network connections, child process creation, or attempts to modify system configuration can provide indicators of compromise even when no known signature exists.
Platforms such as MetaDefender Cloud can contribute an additional layer of visibility by incorporating behavioral analysis, sandboxing, and reputation checks at the file-level.
However, it should be viewed as one component of a broader security strategy, not as a replacement for established controls, especially for npm supply chain, as secure dependency management, package integrity verification, least-privilege access, and code review all remain essential for reducing supply chain risk.
Frequently Asked Questions
What is the @mastra npm supply chain attack?
Following an account takeover, North Korea-backed attackers (Sapphire Sleet) published malicious packages across @mastra and mastra scope libraries. The malicious packages were then downloaded by developers, infecting systems with a postinstall hook which obfuscated its presence and connected to an attacker-owned C2 server. From there, attackers had full access to compromised systems where it deployed a cryptocurrency wallet stealer.
Who was affected by the @mastra npm attack?
Any developer workstation or CI/CD pipeline that ran npm install or npm update on any @mastra package between June 16, 07:05 UTC and June 17, 01:20 UTC was affected; Sapphire Sleet focuses primarily on the finance sector, including cryptocurrency, venture capital, and blockchain organizations.
Why did traditional scanners miss the @mastra attack?
Sapphire Sleet’s attack began with publishing a clean dependency, which would not have had any reason to be flagged by detection-based engines. The second package (the infected one) did not have a signature attached to it, therefore detection engines could not match it with anything in public databases.
What did the malicious npm package do?
The infected npm package carried a postinstall hook; the hook first performed obfuscating actions, then established connection with a remote server. On devices which successfully connected to the server, Sapphire Sleet pushed a PowerShell backdoor, established multiple persistence mechanisms, suppressed detection, and installed a service-level implant running under the SYSTEM security context.
How can organizations check if they were affected?
Organizations should review their package.json and lockfiles for any direct or transitive dependency on easy-day-js.
What should companies do first after detecting exposure?
If easy-day-js dependencies are found, orgs upgrade to clean versions, remove credentials (including LLM tokens) which could be reached, move their crypto wallets to clean devices. Then delete the LaunchAgent, systemd unit, kill the detached process, and clear the dropper markers.
How can behavioral analysis help detect npm supply chain attacks?
Behavioral analysis detonates the package in an isolated environment and records runtime behavior. In this case, the sandbox should have observed the postinstall hook firing, TLS verification being disabled programmatically and outbound connections to attacker C2 infrastructure; all indicators of malicious activity.
