Nx (s1ngularity): a PR title injection stole an npm token and weaponized local AI CLIs
On August 26, 2025, attackers chained three GitHub Actions settings inside the Nx monorepo project (pull_request_target, legacy read/write token defaults, and workflow_dispatch on publish.yml) to steal Nx’s npm publishing token. For four hours, tampered releases across eight nx versions and seven companion packages ran a postinstall script that invoked local AI CLI tools (Claude, Gemini, Amazon Q) to scan developer disks and upload secrets to public s1ngularity-repository repos. Nx Cloud was unaffected.
How they got in
Nx's September 5, 2025 postmortem is a textbook illustration of how three individually mundane GitHub settings turn into full registry compromise.
First, a PR-title validation workflow ran on pull_request_target (which executes with target-branch permissions and secrets) and echoed the untrusted PR title directly into a shell command. Second, because the repository pre-dated February 2023, it still carried GitHub's old default setting of "Read and write permissions" for Actions tokens. Third, publish.yml had workflow_dispatch enabled so maintainers could trigger manual runs.
Chaining those three together took minutes. The attacker opened a PR with shell commands in its title, used the read/write GITHUB_TOKEN to push a temporary branch swapping a CI script, triggered publish.yml against that branch through the GitHub API to steal NPM_TOKEN, and deleted the branch and workflow run to clean up.
A malicious PR title triggers command injection in Nx’s PR-title validation job, exposing a legacy read/write GITHUB_TOKEN.
Malicious PR titleRead/write GITHUB_TOKENUsing workflow_dispatch on publish.yml, the attacker steals NPM_TOKEN, wipes the branch and workflow run, and publishes tampered nx and @nx/* packages lacking provenance.
Read/write GITHUB_TOKENTampered nx on npmInfected developer machines run telemetry.js, abuse local AI CLIs to inventory sensitive files, publish base64 dumps to public GitHub repos, and sabotage shell startup files until npm pulls all bad versions four hours later.
Tampered nx on npmPostinstall & AI CLIs
Figure 1. How the attack unfolded, and what stayed isolated. Select any step or box for details.
What they took
With NPM_TOKEN in hand, the attacker bypassed Nx's CI completely and pushed tampered releases directly to npm across nx (20.9.0–20.12.0, 21.5.0–21.8.0), @nx/devkit, @nx/js, @nx/workspace, @nx/node (20.9.0, 21.5.0), @nx/eslint (21.5.0), and @nx/key and @nx/enterprise-cloud (3.2.0).
The postinstall payload (telemetry.js) introduced a twist security teams had never seen at scale: it hunted for local AI coding CLIs (Claude Code, Gemini CLI, Amazon Q) and invoked them with permission-bypassing flags to recursively locate credentials, keys, and tokens across the filesystem. Harvested secrets were encoded into results.b64 and uploaded using the developer's own GitHub CLI to newly created public repositories named s1ngularity-repository*, while some variants appended sudo shutdown -h 0 to ~/.bashrc and ~/.zshrc.
What stayed safe
Because the rogue packages lacked npm provenance signing, Nx immediately knew its official CI release pipeline had not built them. Within four hours, npm pulled every tampered package and revoked all Nx tokens, while GitHub took down leaked repositories. Nx Cloud was architecturally isolated from open-source npm publishing and stayed completely untouched.
How to defend against this
Default read-only token
Set repository Actions workflow permissions to read-only by default, avoid pull_request_target on untrusted PR metadata, and pass titles through env vars instead of inline shell interpolation.
OIDC Trusted Publisher
Delete static NPM_TOKEN secrets, enable npm Trusted Publishers with OIDC, and require manual environment approval with 2FA before any release publishes.
Block install scripts
Disable npm lifecycle scripts by default (ignore-scripts=true) and alert on unexpected public GitHub repo creations or shell profile edits (sudo shutdown -h 0).
check-s1ngularity-iocs.shInspect a developer workstation for s1ngularity shell sabotage and temporary inventory files.
#!/usr/bin/env bashset -euo pipefailgrep -n "sudo shutdown -h 0" ~/.bashrc ~/.zshrc 2>/dev/null || echo "Shell profiles clean"ls -la /tmp/inventory.txt /tmp/inventory.txt.bak 2>/dev/null || echo "No /tmp/inventory.txt artifact"gh repo list --limit 100 --json name --jq '.[].name | select(startswith("s1ngularity-repository"))' 2>/dev/null || trueAppendix
Evidence log: what’s confirmed and what’s withheld
| Claim | Status | Source |
|---|---|---|
| Three conditions aligned: pull_request_target with unsanitized PR title echoing, legacy read/write Actions default permissions, and workflow_dispatch enabled on publish.yml | Confirmed | Nx Official Postmortem, Sep 5, 2025 |
| Tampered versions included nx 20.9.0–20.12.0 and 21.5.0–21.8.0, @nx/devkit, @nx/js, @nx/workspace, @nx/node (20.9.0, 21.5.0), @nx/eslint (21.5.0), and @nx/key and @nx/enterprise-cloud (3.2.0) | Confirmed | Nx Official Postmortem and GHSA-cxm3-wv7p-598c |
| Postinstall payloads abused local AI CLI tools (such as Claude and Gemini), pushed secrets as results.b64 into public s1ngularity-repository GitHub repos, and appended sudo shutdown -h 0 to ~/.bashrc and ~/.zshrc | Confirmed | Nx Official Postmortem and GHSA-cxm3-wv7p-598c |
| Nx Cloud was never affected and remained fully operational and isolated from OSS npm releases | Confirmed | Nx Official Postmortem, Sep 5, 2025 |
Indicators of compromise
s1ngularity-repository* (results.b64)/tmp/inventory.txtsudo shutdown -h 0 in ~/.bashrc or ~/.zshrc
Reproduction lab
Check GitHub repository default Actions permissions (read-only vs. legacy read/write) and scan developer machines for s1ngularity artifacts.
bash check-s1ngularity-iocs.sh