Home › Intelligence › Brief
BREACH BRIEF🟠 High ThreatIntel

North Korean State Actor Hijacks npm @mastra Scope, Injects Malicious Post‑install Payload into 140+ Packages

Microsoft Threat Intelligence uncovered a supply‑chain attack where the North Korean group Sapphire Sleet compromised the npm @mastra scope, publishing a typosquatted package that executed a malicious post‑install dropper on any workstation or CI/CD pipeline that ran npm install. The incident highlights gaps in third‑party risk oversight and software‑integrity controls, a key concern for audit readiness.

LiveThreat™ Intelligence · 📅 November 18, 2026· 📰 microsoft.com
🟠
Severity
High
TI
Type
ThreatIntel
🎯
Confidence
High
🏢
Affected
3 sector(s)
✅
Actions
3 recommended
📰
Source
microsoft.com

North Korean State Actor Hijacks npm @mastra Scope, Injects Malicious Post‑install Payload into 140+ Packages

What Happened — Microsoft Threat Intelligence identified a large‑scale npm supply‑chain attack attributed to the North Korean group Sapphire Sleet. The adversary compromised the ehindero maintainer account, used its publish rights across the @mastra scope, and released a typosquatted package easy‑day‑js that added a malicious post‑install hook. Over 140 Mastra packages were republished with the malicious dependency; when developers or CI/CD pipelines ran npm install they automatically executed an obfuscated dropper that disabled TLS verification, contacted C2, and deployed a second‑stage Node.js payload with persistence on Windows, macOS and Linux.

Microsoft Threat Intelligence announced on June 19 2026 that the supply‑chain attack was linked with the North Korean state‑sponsored group Sapphire Sleet, which habitually targets the financial sector. The campaign, which also followed a separate npm compromise of the popular Axios client in April 2026, involved more than 140 packages under the mastra and @mastra scopes on the npm registry. After the findings were shared with npm’s security team, the poisoned packages were removed and the attacker’s publish rights to the @mastra scope were revoked.

The intrusion began when the threat actor seized control of the ehindero npm maintainer account, a credential that held publish permissions across the entire Mastra ecosystem. Using that foothold they introduced easy‑day‑js, a malicious typosquat of the widely used dayjs library (which averages 57 million weekly downloads). The first clean version of easy‑day‑js (1.11.21) appeared at 07:05 UTC on June 16 2026, and a weaponized version (1.11.22) with a post‑install hook was pushed at 01:01 UTC on June 17 2026. The compromised ehindero account then published new releases of over 140 Mastra packages, each injected with the dependency easy‑day‑js@^1.11.21 and marked as the latest version, causing npm’s semantic‑versioning resolver to automatically pull the malicious 1.11.22 release during any npm install or update.

When the poisoned packages were installed, the post‑install script launched an obfuscated 4,572‑byte dropper ( setup.cjs ) that first disabled TLS certificate verification, then reached out to a command‑and‑control server at 23.254.164.123:443. The dropper wrote a randomly named .js file, spawned it as a detached, window‑hidden Node.js process, and fetched a second‑stage payload. On systems that established C2 contact, Sapphire Sleet deployed a PowerShell backdoor from separate infrastructure, added persistence mechanisms, created Microsoft Defender exclusions, and installed a service‑level implant that runs with SYSTEM privileges.

Microsoft identified the breach by spotting anomalous publishing behavior on the mastra package. All versions up to v1.13.0 had been published via GitHub Actions OpenID Connect, whereas v1.13.1 was manually uploaded by ehindero using the anonymous Tutamail address ehindero2016@tutamail.com. The only difference was the added easy‑day‑js@^1.11.21 dependency; no code changes appeared in the Mastra GitHub repository. The typosquat’s maintainer, sergey2016@tutamail.com, also used Tutamail and copied the legitimate dayjs repository URL. The dropper’s obfuscation relied on a shuffled array of 40 Base64‑encoded strings seeded with 0x4c11d, which decoded to reveal the C2 address and calls to node:child_process, node:os, writeFileSync and rmSync. Microsoft Defender Antivirus, Defender for Endpoint, and Defender XDR now provide detections for the suspicious Node.js activity associated with this campaign.

The dropper first disables TLS verification by setting NODE_TLS_REJECT_UNAUTHORIZED to ‘0’, allowing the compromised Node.js process to talk to the command‑and‑control (C2) server without valid certificates. It then writes two marker files into the system’s temporary folder – one named .pkg_history containing the install path of the malicious package, and another called .pkg_logs holding the package name encoded with an XOR 0x80 mask. With those preparations complete, the payload issues a GET request to hxxps://23.254.164[.]92:8000/update/49890878 and treats the response as a ~41 KB cross‑platform Node.js tasking client. Unlike a simple data stealer, this implant establishes sign‑in persistence, sends an initial beacon, and then repeatedly polls the C2 for tasks, which it can execute via built‑in Node and shell runners. On Windows, the client also performs reflective .NET assembly injection for in‑memory code execution.

On Windows hosts the implant conducts reconnaissance by enumerating installed applications from three sources – Start Menu entries via Get‑StartApps, registry Uninstall keys, and UWP packages via Get‑AppxPackage – wrapping each call in silent try/catch blocks. The deduplicated list is exfiltrated for victim profiling, helping the attacker spot security products and high‑value software. A secondary PowerShell script receives two C2 URLs through the SCRIPT_ARGS environment variable, disables SSL validation, and defines an HTTP POST routine that Base64‑encodes bodies while spoofing an IE8 user‑agent. The script first downloads a .NET DLL, loads it directly into memory via reflection, and then invokes the Extension.SubRoutine.Run2 method with a second payload, the path to cmd.exe, and the C2 callback address. This fileless injection chain injects the payload into a cmd.exe process that talks back over HTTPS on port 443, leaving no disk artifacts.

Persistence is installed on all three major operating systems using a unified “NVM/Node” masquerade. On Windows, a registry Run key under HKCU\…\CurrentVersion\Run points to C:\ProgramData\NodePackages\NvmProtocal, launching a hidden PowerShell process that starts Node.js. macOS receives a LaunchAgent at ~/Library/NodePackages/com.nvm.protocal.plist with a RunAtLoad label, while Linux creates a systemd user unit ~/.config/systemd/nvmconf/nvmconf.service that restarts the implant after a five‑second delay on failure. Each persistence entry drops the implant as protocal.cjs (a deliberate misspelling) into directories crafted to resemble legitimate Node.js installations, using names such as NvmProtocal, com.nvm.protocal, and nvmconf.service to blend into developer workstations.

Before exfiltrating, the implant gathers a hard‑coded list of 166 cryptocurrency‑wallet browser‑extension IDs (including MetaMask, Phantom, Coinbase Wallet, Binance Wallet, TronLink, etc.) and matches them against Chrome, Edge, and Brave profiles. It copies each profile’s History SQLite database to a temporary folder prefixed with browser‑hist‑ and queries it via node:sqlite. Additional host data—hostname, architecture, platform, user ID, installed applications, and running processes—is collected. The data is sent to the C2 using a custom ICAP‑style protocol over HTTPS POST, employing reqmod, PrimaryUrl, and SecondaryUrl headers and a spoofed legacy IE8 user‑agent string. After successful exfiltration, the shell runner lets the operator switch from automated collection to interactive command execution. Microsoft noted that the actor later delivered a dedicated PowerShell backdoor from separate C2 infrastructure, escalating to persistent, actor‑controlled access on high‑value targets; the backdoor’s tradecraft matches that of the Sapphire Sleet group in earlier campaigns. Through the Node.js implant’s shell runner, Sapphire Sleet downloads and runs a PowerShell script from https://teams.onweblive.org/api/update/8555575039/4, which immediately erases its command‑history file and disables future history recording. The backdoor then creates a unique 16‑character alphanumeric victim ID, packages extensive host metadata—including username, OS version, boot time, admin status, installed AV products, and browser extensions—into a JSON beacon, and posts it to the C2. All communications continue to use the spoofed IE8 user‑agent, and the script enters an infinite loop, beaconing every 10 seconds and backing off to 180 seconds after a network failure.

The backdoor creates a hidden batch file at C:\ProgramData\system.bat and registers it under a deceptive Run‑key named MicrosoftUpdate. Each time a user logs on, the loader contacts the command‑and‑control server by POSTing the keyword “wwps”, pulls the latest payload, and stores it in a newly generated temporary PowerShell script ( %TEMP%\{GUID}.ps1 ). The script is then launched with ‑ExecutionPolicy Bypass in a hidden window, allowing the attacker to rotate the malicious code without ever touching the compromised host.

After gaining interactive access, the operator adds a Microsoft Defender exclusion for C:\Windows\System32 to hide the dropped tools, then installs a boot‑level service called scdev. The service is created with the command sc create scdev binPath= "c:\windows\system32\svchost.exe -k scdev" type= share start= auto and a registry entry points its ServiceDll to c:\windows\system32\scdev.dll. Running as a shared svchost.exe process under the SYSTEM account, the service provides the group—identified as Sapphire Sleet—with persistent, elevated access that survives reboots and does not depend on a user logon.

Microsoft Threat Intelligence recorded the supply‑chain activity on June 16 2026 07:05 UTC when easy‑day‑js @1.11.21 was published as a clean bait. The malicious version easy‑day‑js @1.11.22 appeared at 01:01 UTC on June 17, adding a post‑install hook that executes setup.cjs. By 01:20 UTC the compromised mastra @1.13.1 and more than 140 other @mastra/* packages were released with the tainted dependency. Microsoft’s monitoring saw easy‑day‑js @1.11.22 at 01:07 UTC and mastra @1.13.1 at 01:28 UTC on the same day. Packages published later by legitimate GitHub Actions CI/CD pipelines were not affected.

Sapphire Sleet, described by Microsoft as “a North Korean state actor that has been active since at least March 2020,” focuses on the finance sector—particularly cryptocurrency, venture capital and blockchain firms worldwide, with a strong emphasis on the United States, Asia and the Middle East. The group commonly initiates contact via LinkedIn, luring victims to malicious cloud‑storage links or spoofed financial‑institution domains, and uses fake Zoom meeting URLs. The campaign overlaps with activity tracked under aliases such as UNC1069, STARDUST CHOLLIMA, Alluring Pisces, BlueNoroff, CageyChameleon and CryptoCore. Microsoft advises reviewing dependency trees for any @mastra packages at the compromised versions, checking for easy‑day‑js in node_modules or package‑lock.json, pinning known‑good versions (mastra ≤ 1.13.0, @mastra/core ≤ 1.42.0), running npm install with --ignore‑scripts, searching for IOC files like $TMPDIR/.pkg_history or unexpected .js files, rotating exposed credentials, blocking C2 IPs 23.254.164.92 and 23.254.164.123, auditing CI/CD logs for outbound traffic, and enabling cloud‑delivered protection. Microsoft Defender XDR provides detections for the initial npm script execution (Trojan:JS/NpmStealz.Z!MTB, Trojan:JS/NpmStealz.ZA!MTB), the reflective .NET assembly injection stage (Trojan:JS/NpmSteal.DB!MTB, Trojan:PowerShell/PsExec.DE!MTB), and related suspicious Node.js process behavior.

A malicious process was injected with code that executed entirely in memory using reflective loading, a technique that leaves no files on disk. Microsoft Defender for Cloud flagged the activity as “fileless in‑memory execution” and also reported possible reconnaissance using AI tools and secret‑search queries, as well as attempts to query the cloud metadata service. The same monitoring platform later observed suspicious behavior inside a CI/CD runner, indicating post‑compromise activity after the initial supply‑chain breach.

Persistence was achieved by creating a registry Run key that launches a hidden PowerShell script at every user login; the script in turn starts protocol.cjs. Microsoft Defender for Endpoint recorded an anomaly in the ASEP registry and captured a GET request to hxxps://23.254.164.92:8000/update/49890878, where the response body was read as plain text. A command‑line process was also seen communicating with the same malicious endpoint, confirming active command‑and‑control traffic.

Microsoft Security Copilot now offers pre‑built promptbooks to automate investigation steps for this threat, including incident investigation, user analysis, threat‑actor profiling, and vulnerability impact assessment. The team also supplied KQL queries for Advanced Hunting in Defender XDR: one query isolates “node” processes that invoke setup.cjs or easy‑day‑js with the --no-warnings flag, while another flags outbound connections to the IPs 23.254.164.92 and 23.254.164.123.

The identified indicators of compromise span network, file, host, and package artifacts. Network IOCs include the primary C2 server 23.254.164.92, a secondary address 23.254.164.123, and domains teams.onweblive.org and maskasd.com used for PowerShell backdoor delivery and beaconing. File hashes link the malicious post‑install dropper setup.cjs (SHA‑256 B122A9873B…), the weaponized tarball easy‑day‑js‑1.11.22.tgz (AE70DD4F6B…), a clean bait tarball easy‑day‑js‑1.11.21.tgz (4A8860240E…), the compromised CLI package mastra‑1.13.1.tgz (B73DE25C05…), and supporting scripts such as protocol.cjs and two PowerShell stages. Host artifacts include $TMPDIR/.pkg_history (which records the install path) and $TMPDIR/.pkg_logs containing an XOR‑encoded “easy‑day‑js” string, as well as a randomly named .js file in the user’s home directory that holds the second‑stage payload. The malicious npm package easy‑day‑js is a typosquat of dayjs, published by the account sergey2016, while the compromised publisher ehindero controlled more than 140 Mastra packages. The investigation was conducted by Microsoft Defender Security Research and Threat Intelligence researchers Suriyaraj Natarajan, Sagar Patil, Rajesh Kumar Natarajan, Mahesh Mandava, and Arvind Gowda, who note that further analysis is ongoing to determine the full scope of the compromise.

Why It Matters for Trust & Control Assurance — The incident demonstrates a failure in third‑party risk oversight and software‑supply‑chain integrity, directly testing the control objective of “vendor and supply‑chain security.”

Who Is Affected — Software development teams, enterprises that rely on npm packages, and CI/CD pipeline operators across all industries.

Recommended Actions

  • Enforce signed publishing and restrict maintain‑account privileges for all npm scopes.
  • Deploy continuous monitoring of package‑registry activity and integrate supply‑chain risk alerts into CI pipelines.
  • Conduct a rapid inventory of all @mastra dependencies and replace compromised versions with clean builds.

Technical Notes – Attack vector: compromised maintainer account → typosquat easy‑day‑js → malicious post‑install hook → obfuscated dropper → TLS bypass → C2 → second‑stage Node.js implant with cross‑platform persistence. No CVE is associated; the flaw is a process‑level supply‑chain abuse. Source: Microsoft Security Blog

📰 Original Source
https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/ ↗

This LiveThreat Intelligence Brief is an independent analysis. Read the original reporting at the link above.

From the Verisq platform · Vendor Risk Hub

Point-in-time vendor reviews miss incidents like this.

Verisq AI Trust Operations replaces the annual questionnaire with continuous third-party monitoring — so vendor exposure becomes audit evidence, not a once-a-year guess.

See how Verisq AI Trust Operations works →