# s1ngularity Nx npm supply chain abusing AI CLIs

- ID: s1ngularity-nx-ai-cli-2025-08
- Reported: 2025-08-27
- Researcher: Wiz; Nx; Snyk; JFrog
- Organization: Wiz / Nx
- AI role: attacker_uses_ai_as_operator (AI as operator)
- Confidence in AI involvement: not assessed
- Research / borderline: false
- Last reviewed: 2026-10-20
- Entry page: https://openattacks.ai/attacks/s1ngularity-nx-ai-cli-2025-08/
- Entry JSON: https://openattacks.ai/api/attacks/s1ngularity-nx-ai-cli-2025-08.json
- Browse title: s1ngularity Nx npm supply-chain attack abusing AI CLIs
- Editorial summary: Malicious Nx packages stole developer secrets, using local Claude, Gemini and Amazon Q CLIs to find files. Stolen tokens later made 5,500+ private repos public.
- Evidence class (catalog annotation): Reported campaign
- Source-stated target environments: Developer workflows
- Stage hunts and conditional defenses: https://openattacks.ai/api/defenses/s1ngularity-nx-ai-cli-2025-08.json

## Technique
Attackers stole an Nx npm publish token via GitHub Actions injection and published malicious Nx packages. Postinstall harvested environment, GitHub, npm, SSH, and wallet data and invoked local Claude, Gemini, and Amazon Q CLIs with dangerous flags to inventory sensitive files, then pushed loot to public GitHub repos named s1ngularity-repository\*. Phase 2 used stolen tokens to make 5,500+ private repos public. Later Mandiant reporting described a hijacked coding-assistant session spreading Shai-Hulud through malicious package recommendations.

## Stack relevance (editorial)
Assessment: mapped. Editorial applicability reviewed against the catalog source account; not a scan or independent incident verification.
First action: Review dependency and postinstall history, audit local CLI permissions and rotate credentials exposed by affected packages.
- Relationship: workflow; tools: claude-code, gemini, npm-pypi; OS scope: not OS-specific / not stated; requires existing MCP connections: false.
  Relevance: Compromised Nx packages invoke installed AI CLIs to search for secrets.
  Condition to check: Confirm installation of an affected Nx package and execution of its malicious postinstall.
  Condition to check: Local Claude / Gemini / Amazon Q CLI use is a step after package compromise, not evidence of a flaw in those AI services.
  Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/
A product mention alone is not a victim-side applicability mapping. Selection does not verify affected versions, permissions or compromise.

## Initial access
Malicious npm postinstall on nx/@nx packages (versions around 20.9–21.8)

## AI tooling and models
- [claude CLI](https://github.com/anthropics/claude-code)
- [gemini CLI](https://github.com/google-gemini/gemini-cli)
- [Amazon Q CLI](https://github.com/aws/amazon-q-developer-cli)
- --dangerously-skip-permissions style flags

## Other tooling
- [GitHub CLI](https://github.com/cli/cli)
- npm postinstall
- [GitHub Actions](https://github.com/features/actions) webhook token theft

## Victims and sectors
Nx ecosystem developers (~4M weekly downloads cited); 400+ users/orgs in phase 2

## Target geography
- unknown

## Attribution
s1ngularity / UNC6426 (industry)

## Scale and metrics
Malicious packages live ~4–5 hours; phase 2 \>5500 private repos exposed; Wiz: AI path succeeded in \<25% of cases; \<100 unique valid secrets across 20k files

## Attack flow
Catalog reconstruction of the supplied source account. Unknowns and research caveats are preserved.
### step-1: Publish token is stolen [access]
GitHub Actions injection enables malicious Nx package releases.
Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/

### step-2: Package postinstall harvests secrets [execution]
Installation starts environment, developer-token and file collection.
Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/

### step-3: Local AI CLIs inventory sensitive files [ai]
Claude, Gemini and Amazon Q are invoked with permissive flags.
Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/

### step-4: Loot and private repositories become public [impact]
Collected data is pushed to public repositories; later token abuse exposes additional private repositories.
Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/

Connections:
- step-1 -> step-2
- step-2 -> step-3
- step-3 -> step-4

## 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.
### step-1: 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.

### step-2: Sensitive store access → credential use
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/credentials.sigma.yml
- KQL query download: /api/detections/credentials.kql
- SPL query download: /api/detections/credentials.spl
- Hunt hypothesis: An unexpected process or tool accesses credential stores and is followed by token use or outbound transfer inconsistent with the owner.
- Required telemetry: File-read / API access telemetry for relevant secret stores; Process identity and command lines; Identity, token and outbound-network audit logs
- Investigate: Identify the actor, process and exact store touched, then pivot to token use from new devices or infrastructure.
- Investigate: Correlate reads with egress and rotate affected credentials after confirming exposure.
- Limitation: Defender DeviceFileEvents is not a general file-read audit trail. Collect suitable object-access, EDR or application logs; legitimate developer tools also read secrets.
- No direct MagicSword prevention claim is recorded for this stage.

### step-3: Unexpected agent tool use
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-tools.sigma.yml
- KQL query download: /api/detections/agent-tools.kql
- SPL query download: /api/detections/agent-tools.spl
- Hunt hypothesis: Untrusted content or a changed tool definition precedes a file read, command, or remote call outside the user's intended task.
- Required telemetry: Agent tool-call audit records with session / tool / destination; Tool-definition and approval changes; Endpoint process, file-access and network evidence where available
- Investigate: Join input provenance, tool descriptions and calls by session ID and compare the action to the approved task.
- Investigate: Inspect child processes and destinations; record whether execution was in-process, local, or through a remote SaaS connector.
- Limitation: Process logs cannot recover model intent. Remote connectors and in-process interpreters may produce no local child process. Prompt content alone is not a reliable signature.
- No direct MagicSword prevention claim is recorded for this stage.

### step-4: Private access → public repository artifact
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/repository.sigma.yml
- KQL query download: /api/detections/repository.kql
- SPL query download: /api/detections/repository.spl
- Hunt hypothesis: A token or agent reads private material and creates a public issue, repository, commit or visibility change inconsistent with the approved task.
- Required telemetry: Git-provider organization / enterprise audit; Repository and token permission inventory; Agent tool and secret-scanning / DLP records
- Investigate: Join access and public-write actions by actor / token and time; inspect visibility changes and newly created repositories.
- Investigate: Verify whether the artifact contains sensitive data using approved scanning, retaining original source qualifications.
- Limitation: Git-provider audit completeness depends on product and plan. Not every file read or issue body is present in organization audit logs.
- 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.T0055: Unsecured Credentials — Postinstall malware harvests tokens and uses AI CLIs to locate sensitive files.
  Technique: https://atlas.mitre.org/techniques/AML.T0055
  Evidence: https://www.wiz.io/blog/s1ngularity-supply-chain-attack ; https://www.wiz.io/blog/s1ngularitys-aftermath ; https://nx.dev/blog/s1ngularity-postmortem ; https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/

## Defensive notes
Pin npm provenance; gate AI CLIs; app control on unexpected gh/cli from node postinstall; rotate tokens

## Sources
- https://www.wiz.io/blog/s1ngularity-supply-chain-attack — Wiz: s1ngularity Supply Chain Attack
- https://www.wiz.io/blog/s1ngularitys-aftermath — Wiz: s1ngularity's Aftermath
- https://nx.dev/blog/s1ngularity-postmortem — Nx: s1ngularity Postmortem
- https://snyk.io/blog/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package/ — Snyk: Weaponizing AI Coding Agents for Malware in Nx
- https://www.mandiant.com/resources/blog/hijacked-coding-assistant-shai-hulud — Mandiant: Hijacked Coding-Assistant Session Spreads Shai-Hulud
