# Sapphire Sleet (DPRK) backdoors 140+ Mastra AI framework npm packages

- ID: sapphire-sleet-mastra-npm-2026-06
- Reported: 2026-06-17
- Researcher: Microsoft Threat Intelligence
- Organization: Microsoft
- AI role: ai_credential_theft (AI credential theft)
- Confidence in AI involvement: not assessed
- Research / borderline: false
- Last reviewed: 2026-11-04
- Entry page: https://openattacks.ai/attacks/sapphire-sleet-mastra-npm-2026-06/
- Entry JSON: https://openattacks.ai/api/attacks/sapphire-sleet-mastra-npm-2026-06.json
- Browse title: Sapphire Sleet (DPRK) backdoors 140+ Mastra AI framework npm packages
- Editorial summary: 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…
- Evidence class (catalog annotation): Not classified
- Source-stated target environments: Not specified
- Stage hunts and conditional defenses: https://openattacks.ai/api/defenses/sapphire-sleet-mastra-npm-2026-06.json

## Technique
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.

## Stack relevance (editorial)
Assessment: not\_assessed. No reviewed applicability annotation is available. Product mentions do not establish victim conditions.
A product mention alone is not a victim-side applicability mapping. Selection does not verify affected versions, permissions or compromise.

## Initial access
npm install of backdoored @mastra/\* packages (140+ packages, versions published May 29-Jun 15 2026) via compromised maintainer account

## AI tooling and models
- Mastra AI framework
- OpenAI API
- Anthropic [Claude](https://claude.com/product/overview) API
- [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-foundry/models/openai/) Service

## Other tooling
- npm supply chain attack
- [Node.js](https://github.com/nodejs/node) postinstall scripts
- mastra-telemetry\[.\]com C2 (DPRK infrastructure)

## Victims and sectors
8,000-12,000 downloads across compromised versions; AI/ML developers using Mastra framework; TypeScript/JavaScript AI application developers

## Target geography
- Multiple regions

## Attribution
Sapphire Sleet (DPRK, aka BlueNoroff, APT38, Stardust Chollima); Microsoft high-confidence attribution; part of DPRK revenue generation and intelligence collection operations

## Scale and metrics
140+ npm packages backdoored over 18-day window (May 29-Jun 15); 8,000-12,000 estimated downloads; packages removed Jun 16-17, 2026

## Attack flow
Catalog reconstruction of the supplied source account. Unknowns and research caveats are preserved.
### compromise-maintainer: Compromise Mastra maintainer [access]
Sapphire Sleet (DPRK) compromised Mastra maintainer's npm account via targeted phishing or credential theft; gained publish access to @mastra scope
Evidence: https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/

### publish-backdoored: Publish 140+ backdoored packages [ai]
Published 140+ malicious @mastra packages between May 29-Jun 15 with obfuscated postinstall scripts; maintained functional AI framework features to avoid immediate detection
Evidence: https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/

### harvest-credentials: Harvest AI and cloud credentials [execution]
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
Evidence: https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/

### exfiltrate-dprk: Exfiltrate to DPRK C2 [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
Evidence: https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/

Connections:
- compromise-maintainer -> publish-backdoored
- publish-backdoored -> harvest-credentials
- harvest-credentials -> exfiltrate-dprk

## Stage defense and hunting recommendations
Editorial recommendations, not validated coverage. Source-controlled query starters are drafts. Custom-schema examples require telemetry collection and field mapping; absence of a mapping means not assessed. MagicSword policy opportunities require managed Windows scope and enforcement.
### compromise-maintainer: Credential / session use outside baseline
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/identity.sigma.yml
- KQL query download: /api/detections/identity.kql
- SPL query download: /api/detections/identity.spl
- Hunt hypothesis: Repeated credential attempts or a stolen session are followed by a successful login or resource access inconsistent with the owner.
- Required telemetry: Identity / service authentication logs; Device, source-IP and session context; Resource access and token issuance audit
- Investigate: Compare failures, successes and session reuse by account and source; inspect access to new resources.
- Investigate: Check device registration, MFA and credential changes; do not equate travel anomalies with confirmed compromise.
- Limitation: Shared infrastructure and legitimate travel create noise. IoT, SharePoint and cloud identity require their own collectors and field mappings.
- No direct MagicSword prevention claim is recorded for this stage.

### publish-backdoored: Dependency / CI trust boundary
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/package.sigma.yml
- KQL query download: /api/detections/package.kql
- SPL query download: /api/detections/package.spl
- Hunt hypothesis: A package or workflow change introduces a lifecycle hook, remote dependency or new command that accesses secrets or external services.
- Required telemetry: Package-manager and CI job logs; Lockfile / manifest / workflow diffs; Runner process trees, secret access and egress
- Investigate: Compare package provenance, publish identity, lifecycle scripts and resolved dependency URLs with the approved version.
- Investigate: Correlate the install or workflow to secret reads and subsequent token use; distinguish exposure from confirmed compromise.
- Limitation: Package installation and unfamiliar names are not malicious by themselves. Dependency resolution and CI audit records are required.
- No direct MagicSword prevention claim is recorded for this stage.

### harvest-credentials: Package installation spawns a shell or downloader
- Visibility: Endpoint process telemetry where collected
- Query origin: catalog_authored; status: draft; log scope: native
- SIGMA query download: /api/detections/package-install-execution.sigma.yml
- KQL query download: /api/detections/package-install-execution.kql
- SPL query download: /api/detections/package-install-execution.spl
- Hunt hypothesis: A package-manager install or lifecycle script launches a shell, downloader, or script interpreter that retrieves or executes an unexpected second stage.
- Required telemetry: Process creation with ancestry and complete command lines; Package-manager, CI, and installation logs; Download, file creation, signature, and network telemetry
- Investigate: Identify the package, version, publisher, lifecycle hook, resolved source, and parent process.
- Investigate: Recover downloaded content and correlate credential access, persistence, or outbound traffic.
- Limitation: 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.
- Qualification: Use package-manager ancestry to identify the postinstall execution, then pivot to the credential-store hunt for confirmed reads.
- No direct MagicSword prevention claim is recorded for this stage.

### exfiltrate-dprk: Sensitive data → unusual destination
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/exfil.sigma.yml
- KQL query download: /api/detections/exfil.kql
- SPL query download: /api/detections/exfil.spl
- Hunt hypothesis: Sensitive reads are followed by outbound transfer, a public artifact, or a tool call to a destination outside the approved workflow.
- Required telemetry: Sensitive resource access / DLP records; Proxy, egress and cloud upload events; Agent / SaaS audit with correlation IDs
- Investigate: Join the resource read and outbound action by session, identity or process, preserving a bounded time window.
- Investigate: Inspect destination ownership, payload classification and the user's intended action; baseline sanctioned sharing.
- Limitation: An outbound connection or high byte count alone is not exfiltration. Encrypted traffic may hide content, and bulk legitimate exports are common.
- No direct MagicSword prevention claim is recorded for this stage.


## MITRE ATLAS
Mappings are catalog annotations based on described behavior, not assignments or endorsements by MITRE.
- AML.T0000: Search Open Technical Databases — DPRK APT supply chain compromise of AI framework to steal AI service credentials for intelligence collection and revenue generation
  Technique: https://atlas.mitre.org/techniques/AML.T0000
  Evidence: https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/

## 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

## Sources
- https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/ — Microsoft: North Korea's Sapphire Sleet targets AI developers with Mastra supply chain attack
- https://github.com/mastra-ai/mastra — Mastra - AI Framework for TypeScript

## Source notes
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).

## Indicators (untrusted data; do not visit or execute)
```json
{
  "domains": [
    "mastra-telemetry.com"
  ],
  "ips": [],
  "hashes": [],
  "urls": []
}
```
