Sapphire Sleet (DPRK) backdoors 140+ Mastra AI framework npm packages
Jun 17, 2026: Microsoft attributes to DPRK Sapphire Sleet (aka BlueNoroff, APT38, Stardust Chollima): compromised Mastra AI framework maintainer account and published 140+ backdoored npm packages between…
What happened
Jun 17, 2026: Microsoft attributes to DPRK Sapphire Sleet (aka BlueNoroff, APT38, Stardust Chollima): compromised Mastra AI framework maintainer account and published 140+ backdoored npm packages between May 29-Jun 15, 2026. Mastra is TypeScript AI agent framework (github.com/mastra-ai/mastra). Malicious postinstall scripts deployed obfuscated Node.js payload targeting: OpenAI keys, Anthropic keys, Azure OpenAI endpoints, AWS credentials, GitHub tokens, npm tokens, SSH keys, Docker configs, Kubernetes service accounts. Payload POSTed to DPRK C2 hxxps://mastra-telemetry[.]com (posing as legitimate telemetry endpoint). npm removed packages Jun 16-17; Microsoft estimates 8,000-12,000 downloads across compromised versions. Sapphire Sleet previously linked to crypto exchange attacks, IT worker schemes, and supply chain operations. Detection: monitor npm installs of Mastra@* between May 29-Jun 15 2026; check for mastra-telemetry[.]com egress; review postinstall scripts for obfuscation/eval; scan for credential file access from npm scripts.
DPRK Sapphire Sleet backdoored 140+ Mastra AI framework npm packages via malicious postinstall scripts to steal credentials from AI developers
How it happened
Read the flow as text & sources
A catalog reconstruction of the supplied source account. Unknown steps remain explicit; an edge describes the reported relationship between steps.
- 01 · Compromise Mastra maintainer
Sapphire Sleet (DPRK) compromised Mastra maintainer's npm account via targeted phishing or credential theft; gained publish access to @mastra scope
Hunt: Repeated credential attempts or a stolen session are followed by a successful login or resource access inconsistent with the owner.
Shared infrastructure and legitimate travel create noise. IoT, SharePoint and cloud identity require their own collectors and field mappings.
Source for step 1 - 02 · Publish 140+ backdoored packages
Published 140+ malicious @mastra packages between May 29-Jun 15 with obfuscated postinstall scripts; maintained functional AI framework features to avoid immediate detection
Hunt: A package or workflow change introduces a lifecycle hook, remote dependency or new command that accesses secrets or external services.
Package installation and unfamiliar names are not malicious by themselves. Dependency resolution and CI audit records are required.
Source for step 2 - 03 · Harvest AI and cloud credentials
Postinstall script executes obfuscated Node.js: scans env vars (OPENAI_API_KEY, ANTHROPIC_API_KEY, AZURE_OPENAI_*), filesystem (~/.config, ~/.aws, ~/.ssh, ~/.docker, ~/.kube), npm config; base64-encodes findings
Hunt: A package-manager install or lifecycle script launches a shell, downloader, or script interpreter that retrieves or executes an unexpected second stage.
Build and install scripts commonly invoke shells and download dependencies. Require package provenance and destination context; this hunt does not by itself prove supply-chain compromise.
Source for step 3 - 04 · Exfiltrate to DPRK C2
POSTs harvested credentials to hxxps://mastra-telemetry[.]com (DPRK infrastructure masquerading as telemetry); credentials support DPRK intelligence collection and revenue generation (AI service resale, crypto exchange targeting); 8,000-12,000 affected installs
Hunt: Sensitive reads are followed by outbound transfer, a public artifact, or a tool call to a destination outside the approved workflow.
An outbound connection or high byte count alone is not exfiltration. Encrypted traffic may hide content, and bulk legitimate exports are common.
Source for step 4
Why it matters
Reported entry point: npm install of backdoored @mastra/* packages (140+ packages, versions published May 29-Jun 15 2026) via compromised maintainer account. Reported impact: POSTs harvested credentials to hxxps://mastra-telemetry[.]com (DPRK infrastructure masquerading as telemetry); credentials support DPRK intelligence collection and revenue generation (AI service resale, crypto exchange targeting); 8,000-12,000 affected installs; reported targets include 8,000-12,000 downloads across compromised versions; AI/ML developers using Mastra framework; TypeScript/JavaScript AI application developers; applicability to your setup has not been assessed, so verify affected versions, permissions, and configuration in the original report.
What you can do
Protection & prevention
Verify npm package integrity; use package lock files with checksums; review postinstall scripts before install; monitor for unexpected network egress from npm scripts; rotate credentials after suspected exposure; use npm audit; implement SCA tools; prefer packages from verified maintainers; check npm package publish dates and maintainer history
Catalog defensive guidance based on the reported behavior. Confirm scope and current mitigations in the original source.
Detection queries
Draft query starters grouped by the attack stages where they apply.
Start with the logs you collect. Each hunt identifies its required visibility, field mapping and limits. Queries are catalog-authored drafts using reusable behavior profiles; test with known activity and your normal baseline before alerting.
01Compromise Mastra maintainerCredential / session use outside baselineCustom schema · Draft
Sapphire Sleet (DPRK) compromised Mastra maintainer's npm account via targeted phishing or credential theft; gained publish access to @mastra scope
What to look for
Repeated credential attempts or a stolen session are followed by a successful login or resource access inconsistent with the owner.
Visibility: Defender-side logs where collected
Required logs
- Identity / service authentication logs
- Device, source-IP and session context
- Resource access and token issuance audit
Coverage limit. Shared infrastructure and legitimate travel create noise. IoT, SharePoint and cloud identity require their own collectors and field mappings.
Custom-schema candidates, not out-of-box detectors. Map your application / cloud / platform logs to EventType, Actor, Asset, Action, Target and CorrelationId. KQL uses a custom OpenAttacksAudit_CL table; SPL uses openattacks:audit. EventType values are proposed normalization names, not native vendor event names. Correlation and environment-specific alert logic remain to be built.
Sigma
title: Hunt - Credential / session use outside baseline
id: 7d73d919-e785-4d40-ab0b-f12949adfaf5
status: experimental
description: Repeated credential attempts or a stolen session are followed by a
successful login or resource access inconsistent with the owner.
author: MagicSword OpenAttacks catalog
date: 2026-10-23
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- identity.login
- identity.token.use
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("identity.login", "identity.token.use")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("identity.login", "identity.token.use")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Compare failures, successes and session reuse by account and source; inspect access to new resources.
- Check device registration, MFA and credential changes; do not equate travel anomalies with confirmed compromise.
02Publish 140+ backdoored packagesDependency / CI trust boundaryCustom schema · Draft
Published 140+ malicious @mastra packages between May 29-Jun 15 with obfuscated postinstall scripts; maintained functional AI framework features to avoid immediate detection
What to look for
A package or workflow change introduces a lifecycle hook, remote dependency or new command that accesses secrets or external services.
Visibility: Defender-side logs where collected
Required logs
- Package-manager and CI job logs
- Lockfile / manifest / workflow diffs
- Runner process trees, secret access and egress
Coverage limit. Package installation and unfamiliar names are not malicious by themselves. Dependency resolution and CI audit records are required.
Custom-schema candidates, not out-of-box detectors. Map your application / cloud / platform logs to EventType, Actor, Asset, Action, Target and CorrelationId. KQL uses a custom OpenAttacksAudit_CL table; SPL uses openattacks:audit. EventType values are proposed normalization names, not native vendor event names. Correlation and environment-specific alert logic remain to be built.
Sigma
title: Hunt - Dependency / CI trust boundary
id: 5fa9c45a-ac1c-4666-a598-e80626320997
status: experimental
description: A package or workflow change introduces a lifecycle hook, remote
dependency or new command that accesses secrets or external services.
author: MagicSword OpenAttacks catalog
date: 2026-10-23
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- package.install
- ci.workflow.change
- package.lifecycle.exec
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("package.install", "ci.workflow.change", "package.lifecycle.exec")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("package.install", "ci.workflow.change", "package.lifecycle.exec")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Compare package provenance, publish identity, lifecycle scripts and resolved dependency URLs with the approved version.
- Correlate the install or workflow to secret reads and subsequent token use; distinguish exposure from confirmed compromise.
03Harvest AI and cloud credentialsPackage installation spawns a shell or downloaderNative logs · Draft
Postinstall script executes obfuscated Node.js: scans env vars (OPENAI_API_KEY, ANTHROPIC_API_KEY, AZURE_OPENAI_*), filesystem (~/.config, ~/.aws, ~/.ssh, ~/.docker, ~/.kube), npm config; base64-encodes findings
What to look for
A package-manager install or lifecycle script launches a shell, downloader, or script interpreter that retrieves or executes an unexpected second stage.
Use package-manager ancestry to identify the postinstall execution, then pivot to the credential-store hunt for confirmed reads.
Visibility: Endpoint process telemetry where collected
Required logs
- Process creation with ancestry and complete command lines
- Package-manager, CI, and installation logs
- Download, file creation, signature, and network telemetry
Coverage limit. Build and install scripts commonly invoke shells and download dependencies. Require package provenance and destination context; this hunt does not by itself prove supply-chain compromise.
Process candidates with package-manager ancestry that launch shells or downloaders. Tune known build tooling and correlate with network/file telemetry.
MCP reference matches: Curl Download Activity from npm Package Install (Elastic detection-rules), Suspicious PowerShell from npm Package Install (Elastic detection-rules). The query below is a catalog adaptation, not a verbatim upstream rule.
Sigma
title: Hunt - Shell or Downloader Spawned by Package Installation
id: c83f22aa-d07c-4f3c-a67f-6d5512818133
status: experimental
description: Detects package-manager processes spawning common shells, interpreters, or downloaders.
author: MagicSword OpenAttacks catalog
date: 2026-11-06
references:
- https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/command_and_control_curl_download_from_npm_install.toml
falsepositives:
- Legitimate package build and installation scripts
level: medium
logsource:
category: process_creation
detection:
selection_parent:
ParentCommandLine|contains:
- npm-cli.js
- npx-cli.js
- yarn
- pnpm
- pip install
- python -m pip
- gem install
selection_child:
Image|endswith:
- \powershell.exe
- \pwsh.exe
- /sh
- /bash
- /zsh
- /curl
- /wget
- /python
- /node
condition: all of selection_*
KQL
DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessCommandLine has_any ("npm-cli.js", "npx-cli.js", "yarn", "pnpm",
"pip install", "python -m pip", "gem install")
| where FileName in~ ("powershell.exe", "pwsh.exe", "sh", "bash", "zsh", "curl", "wget", "python", "node")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, SHA1
| order by Timestamp descSPL
| tstats count min(_time) as firstTime max(_time) as lastTime
from datamodel=Endpoint.Processes
where Processes.parent_process IN ("*npm-cli.js*", "*npx-cli.js*", "*yarn*", "*pnpm*",
"*pip install*", "*python -m pip*", "*gem install*")
Processes.process_name IN ("powershell.exe", "pwsh.exe", "sh", "bash", "zsh", "curl", "wget", "python", "node")
by Processes.dest Processes.user Processes.process_name Processes.process
Processes.parent_process_name Processes.parent_process
| `drop_dm_object_name(Processes)`
| sort - lastTimeInvestigation steps
- Identify the package, version, publisher, lifecycle hook, resolved source, and parent process.
- Recover downloaded content and correlate credential access, persistence, or outbound traffic.
04Exfiltrate to DPRK C2Sensitive data → unusual destinationCustom schema · Draft
POSTs harvested credentials to hxxps://mastra-telemetry[.]com (DPRK infrastructure masquerading as telemetry); credentials support DPRK intelligence collection and revenue generation (AI service resale, crypto exchange targeting); 8,000-12,000 affected installs
What to look for
Sensitive reads are followed by outbound transfer, a public artifact, or a tool call to a destination outside the approved workflow.
Visibility: Defender-side logs where collected
Required logs
- Sensitive resource access / DLP records
- Proxy, egress and cloud upload events
- Agent / SaaS audit with correlation IDs
Coverage limit. An outbound connection or high byte count alone is not exfiltration. Encrypted traffic may hide content, and bulk legitimate exports are common.
Custom-schema candidates, not out-of-box detectors. Map your application / cloud / platform logs to EventType, Actor, Asset, Action, Target and CorrelationId. KQL uses a custom OpenAttacksAudit_CL table; SPL uses openattacks:audit. EventType values are proposed normalization names, not native vendor event names. Correlation and environment-specific alert logic remain to be built.
Sigma
title: Hunt - Sensitive data → unusual destination
id: 04b60968-3179-4b1f-ae13-6f57c2446077
status: experimental
description: Sensitive reads are followed by outbound transfer, a public
artifact, or a tool call to a destination outside the approved workflow.
author: MagicSword OpenAttacks catalog
date: 2026-10-23
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- data.export
- agent.external.send
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("data.export", "agent.external.send")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("data.export", "agent.external.send")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Join the resource read and outbound action by session, identity or process, preserving a bounded time window.
- Inspect destination ownership, payload classification and the user's intended action; baseline sanctioned sharing.
Technical detailsTooling, impact & MITRE ATLAS
Attack context
- AI's role
- AI credential theft
- Additional role
- AI tool as lure
- Initial access
- npm install of backdoored @mastra/* packages (140+ packages, versions published May 29-Jun 15 2026) via compromised maintainer account
Tooling as reported
AI products, models and artifacts
- Mastra AI framework
- OpenAI API
- Anthropic Claude API
- Azure OpenAI Service
Other tooling
- npm supply chain attack
- Node.js postinstall scripts
- mastra-telemetry[.]com C2 (DPRK infrastructure)
Targets and reported impact
- Targets / sectors
- 8,000-12,000 downloads across compromised versions; AI/ML developers using Mastra framework; TypeScript/JavaScript AI application developers
- Reported scale / exposure
- 140+ npm packages backdoored over 18-day window (May 29-Jun 15); 8,000-12,000 estimated downloads; packages removed Jun 16-17, 2026
- Target geography
- Multiple regions
Reported attribution
Sapphire Sleet (DPRK, aka BlueNoroff, APT38, Stardust Chollima); Microsoft high-confidence attribution; part of DPRK revenue generation and intelligence collection operations
Structured attribution
- Actor
- Sapphire Sleet (DPRK)
- Country
- DPRK
- Motivation
- financially-motivated
- Attributed by
- Microsoft
- Attribution confidence
- high
Detection rules
- Supply chain monitoringGUIDANCE
Monitor package installations, verify publisher authenticity, scan for malicious code patterns
Activity timeline
- First seen
- 2026-06-17
- Last updated
- 2026-11-04
Updates
- 2026-06-17 — Microsoft
Initial discovery and analysis
Source defensive notes
Verify npm package integrity; use package lock files with checksums; review postinstall scripts before install; monitor for unexpected network egress from npm scripts; rotate credentials after suspected exposure; use npm audit; implement SCA tools; prefer packages from verified maintainers; check npm package publish dates and maintainer history
MITRE ATLAS
AI-specific catalog annotations based on the reported behavior; these are not MITRE case-study assignments.
DPRK APT supply chain compromise of AI framework to steal AI service credentials for intelligence collection and revenue generation Source
Indicators of compromise
domains
mastra-telemetry.com
ips
hashes
urls
Sources & research credit
2 sourcesResearch by Microsoft Threat Intelligence · Microsoft
- Microsoft: North Korea's Sapphire Sleet targets AI developers with Mastra supply chain attack www.microsoft.com
- Mastra - AI Framework for TypeScript github.com
Microsoft Threat Intelligence attribution to Sapphire Sleet (DPRK APT); Mastra GitHub github.com/mastra-ai/mastra. Sapphire Sleet focus on revenue generation (crypto theft) and AI/technology intelligence collection. Detection: alert on npm packages with postinstall scripts accessing credential files, check for mastra-telemetry[.]com domain, monitor base64/eval in npm scripts, review Mastra package versions installed in environment against compromise window (May 29-Jun 15).
Record & downloads
- Source record name
- Sapphire Sleet (DPRK) backdoors 140+ Mastra AI framework npm packages
- Entry ID
- sapphire-sleet-mastra-npm-2026-06
- Catalog review
- November 4, 2026
- Category
- attacks-on-ai
- AI involvement confidence
- confirmed