{
  "attack_id": "sapphire-sleet-mastra-npm-2026-06",
  "status": "catalog_recommendations_not_validated_coverage",
  "stages": [
    {
      "node_id": "compromise-maintainer",
      "profile": "identity",
      "title": "Credential / session use outside baseline",
      "hypothesis": "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",
      "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.",
        "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.",
      "queries": {
        "sigma": "title: Hunt - Credential / session use outside baseline\nid: 7d73d919-e785-4d40-ab0b-f12949adfaf5\nstatus: experimental\ndescription: Repeated credential attempts or a stolen session are followed by a\n  successful login or resource access inconsistent with the owner.\nauthor: MagicSword OpenAttacks catalog\ndate: 2026-10-23\nfalsepositives:\n  - Authorized activity matching this broad hunt; baseline and investigate\n    before alerting.\nlevel: low\nlogsource:\n  category: application\n  product: openattacks_audit\n  definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,\n    Target and CorrelationId from the required source logs first.\ndetection:\n  selection:\n    EventType:\n      - identity.login\n      - identity.token.use\n  condition: selection\n",
        "kql": "// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.\n// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).\n// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.\nOpenAttacksAudit_CL\n| where TimeGenerated > ago(7d)\n| where EventType in (\"identity.login\", \"identity.token.use\")\n| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId\n| order by TimeGenerated desc",
        "spl": "sourcetype=\"openattacks:audit\"\nEventType IN (\"identity.login\", \"identity.token.use\")\n| table _time EventType Actor Asset Action Target CorrelationId\n| sort - _time"
      },
      "query_scope": "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.",
      "query_kind": "custom_schema",
      "origin": "catalog_authored",
      "definition_url": "https://github.com/magicsword-io/openattacks/blob/main/detections/identity.yaml",
      "query_downloads": {
        "sigma": "/api/detections/identity.sigma.yml",
        "kql": "/api/detections/identity.kql",
        "spl": "/api/detections/identity.spl"
      },
      "validation": "draft",
      "evidence": [
        "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
      ],
      "reviewed": "2026-10-23",
      "upstream_matches": []
    },
    {
      "node_id": "publish-backdoored",
      "profile": "package",
      "title": "Dependency / CI trust boundary",
      "hypothesis": "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",
      "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.",
        "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.",
      "queries": {
        "sigma": "title: Hunt - Dependency / CI trust boundary\nid: 5fa9c45a-ac1c-4666-a598-e80626320997\nstatus: experimental\ndescription: A package or workflow change introduces a lifecycle hook, remote\n  dependency or new command that accesses secrets or external services.\nauthor: MagicSword OpenAttacks catalog\ndate: 2026-10-23\nfalsepositives:\n  - Authorized activity matching this broad hunt; baseline and investigate\n    before alerting.\nlevel: low\nlogsource:\n  category: application\n  product: openattacks_audit\n  definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,\n    Target and CorrelationId from the required source logs first.\ndetection:\n  selection:\n    EventType:\n      - package.install\n      - ci.workflow.change\n      - package.lifecycle.exec\n  condition: selection\n",
        "kql": "// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.\n// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).\n// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.\nOpenAttacksAudit_CL\n| where TimeGenerated > ago(7d)\n| where EventType in (\"package.install\", \"ci.workflow.change\", \"package.lifecycle.exec\")\n| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId\n| order by TimeGenerated desc",
        "spl": "sourcetype=\"openattacks:audit\"\nEventType IN (\"package.install\", \"ci.workflow.change\", \"package.lifecycle.exec\")\n| table _time EventType Actor Asset Action Target CorrelationId\n| sort - _time"
      },
      "query_scope": "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.",
      "query_kind": "custom_schema",
      "origin": "catalog_authored",
      "definition_url": "https://github.com/magicsword-io/openattacks/blob/main/detections/package.yaml",
      "query_downloads": {
        "sigma": "/api/detections/package.sigma.yml",
        "kql": "/api/detections/package.kql",
        "spl": "/api/detections/package.spl"
      },
      "validation": "draft",
      "evidence": [
        "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
      ],
      "reviewed": "2026-10-23",
      "upstream_matches": []
    },
    {
      "node_id": "harvest-credentials",
      "profile": "package-install-execution",
      "title": "Package installation spawns a shell or downloader",
      "hypothesis": "A package-manager install or lifecycle script launches a shell, downloader, or script interpreter that retrieves or executes an unexpected second stage.",
      "visibility": "Endpoint process telemetry where collected",
      "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.",
        "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.",
      "note": "Use package-manager ancestry to identify the postinstall execution, then pivot to the credential-store hunt for confirmed reads.",
      "queries": {
        "sigma": "title: Hunt - Shell or Downloader Spawned by Package Installation\nid: c83f22aa-d07c-4f3c-a67f-6d5512818133\nstatus: experimental\ndescription: Detects package-manager processes spawning common shells, interpreters, or downloaders.\nauthor: MagicSword OpenAttacks catalog\ndate: 2026-11-06\nreferences:\n  - https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/command_and_control_curl_download_from_npm_install.toml\nfalsepositives:\n  - Legitimate package build and installation scripts\nlevel: medium\nlogsource:\n  category: process_creation\ndetection:\n  selection_parent:\n    ParentCommandLine|contains:\n      - npm-cli.js\n      - npx-cli.js\n      - yarn\n      - pnpm\n      - pip install\n      - python -m pip\n      - gem install\n  selection_child:\n    Image|endswith:\n      - \\powershell.exe\n      - \\pwsh.exe\n      - /sh\n      - /bash\n      - /zsh\n      - /curl\n      - /wget\n      - /python\n      - /node\n  condition: all of selection_*\n",
        "kql": "DeviceProcessEvents\n| where Timestamp > ago(7d)\n| where InitiatingProcessCommandLine has_any (\"npm-cli.js\", \"npx-cli.js\", \"yarn\", \"pnpm\",\n    \"pip install\", \"python -m pip\", \"gem install\")\n| where FileName in~ (\"powershell.exe\", \"pwsh.exe\", \"sh\", \"bash\", \"zsh\", \"curl\", \"wget\", \"python\", \"node\")\n| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,\n    InitiatingProcessFileName, InitiatingProcessCommandLine, SHA1\n| order by Timestamp desc",
        "spl": "| tstats count min(_time) as firstTime max(_time) as lastTime\n  from datamodel=Endpoint.Processes\n  where Processes.parent_process IN (\"*npm-cli.js*\", \"*npx-cli.js*\", \"*yarn*\", \"*pnpm*\",\n    \"*pip install*\", \"*python -m pip*\", \"*gem install*\")\n  Processes.process_name IN (\"powershell.exe\", \"pwsh.exe\", \"sh\", \"bash\", \"zsh\", \"curl\", \"wget\", \"python\", \"node\")\n  by Processes.dest Processes.user Processes.process_name Processes.process\n     Processes.parent_process_name Processes.parent_process\n| `drop_dm_object_name(Processes)`\n| sort - lastTime"
      },
      "query_scope": "Process candidates with package-manager ancestry that launch shells or downloaders. Tune known build tooling and correlate with network/file telemetry.",
      "query_kind": "native",
      "origin": "catalog_authored",
      "definition_url": "https://github.com/magicsword-io/openattacks/blob/main/detections/package-install-execution.yaml",
      "query_downloads": {
        "sigma": "/api/detections/package-install-execution.sigma.yml",
        "kql": "/api/detections/package-install-execution.kql",
        "spl": "/api/detections/package-install-execution.spl"
      },
      "validation": "draft",
      "evidence": [
        "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
      ],
      "reviewed": "2026-11-06",
      "upstream_matches": [
        {
          "name": "Curl Download Activity from npm Package Install",
          "id": "7a3c9e21-5d84-4b16-9f02-1e8c6a4d0b73",
          "source": "Elastic detection-rules",
          "url": "https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/command_and_control_curl_download_from_npm_install.toml"
        },
        {
          "name": "Suspicious PowerShell from npm Package Install",
          "id": "c4e8a1d7-2b6f-4e93-8a15-7d0c3f9b6e42",
          "source": "Elastic detection-rules",
          "url": "https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_suspicious_powershell_from_npm_install.toml"
        }
      ]
    },
    {
      "node_id": "exfiltrate-dprk",
      "profile": "exfil",
      "title": "Sensitive data → unusual destination",
      "hypothesis": "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",
      "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.",
        "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.",
      "queries": {
        "sigma": "title: Hunt - Sensitive data → unusual destination\nid: 04b60968-3179-4b1f-ae13-6f57c2446077\nstatus: experimental\ndescription: Sensitive reads are followed by outbound transfer, a public\n  artifact, or a tool call to a destination outside the approved workflow.\nauthor: MagicSword OpenAttacks catalog\ndate: 2026-10-23\nfalsepositives:\n  - Authorized activity matching this broad hunt; baseline and investigate\n    before alerting.\nlevel: low\nlogsource:\n  category: application\n  product: openattacks_audit\n  definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,\n    Target and CorrelationId from the required source logs first.\ndetection:\n  selection:\n    EventType:\n      - data.export\n      - agent.external.send\n  condition: selection\n",
        "kql": "// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.\n// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).\n// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.\nOpenAttacksAudit_CL\n| where TimeGenerated > ago(7d)\n| where EventType in (\"data.export\", \"agent.external.send\")\n| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId\n| order by TimeGenerated desc",
        "spl": "sourcetype=\"openattacks:audit\"\nEventType IN (\"data.export\", \"agent.external.send\")\n| table _time EventType Actor Asset Action Target CorrelationId\n| sort - _time"
      },
      "query_scope": "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.",
      "query_kind": "custom_schema",
      "origin": "catalog_authored",
      "definition_url": "https://github.com/magicsword-io/openattacks/blob/main/detections/exfil.yaml",
      "query_downloads": {
        "sigma": "/api/detections/exfil.sigma.yml",
        "kql": "/api/detections/exfil.kql",
        "spl": "/api/detections/exfil.spl"
      },
      "validation": "draft",
      "evidence": [
        "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
      ],
      "reviewed": "2026-10-23",
      "upstream_matches": []
    }
  ],
  "attack_flow": {
    "nodes": [
      {
        "id": "compromise-maintainer",
        "title": "Compromise Mastra maintainer",
        "description": "Sapphire Sleet (DPRK) compromised Mastra maintainer's npm account via targeted phishing or credential theft; gained publish access to @mastra scope",
        "kind": "access",
        "source_urls": [
          "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
        ]
      },
      {
        "id": "publish-backdoored",
        "title": "Publish 140+ backdoored packages",
        "description": "Published 140+ malicious @mastra packages between May 29-Jun 15 with obfuscated postinstall scripts; maintained functional AI framework features to avoid immediate detection",
        "kind": "ai",
        "source_urls": [
          "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
        ]
      },
      {
        "id": "harvest-credentials",
        "title": "Harvest AI and cloud credentials",
        "description": "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",
        "kind": "execution",
        "source_urls": [
          "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
        ]
      },
      {
        "id": "exfiltrate-dprk",
        "title": "Exfiltrate to DPRK C2",
        "description": "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",
        "kind": "impact",
        "source_urls": [
          "https://www.microsoft.com/en-us/security/blog/2026/06/17/postinstall-payload-inside-mastra-npm-supply-chain-compromise/"
        ]
      }
    ],
    "edges": [
      {
        "source": "compromise-maintainer",
        "target": "publish-backdoored"
      },
      {
        "source": "publish-backdoored",
        "target": "harvest-credentials"
      },
      {
        "source": "harvest-credentials",
        "target": "exfiltrate-dprk"
      }
    ]
  }
}