CCyberwiki

Responding to a malicious package installation

Installing a malicious package version is enough to run it. In the npm malware campaigns of 2025, the hostile code ran as part of the installation, so it started during npm install with the rights of the user or the CI job that ran the command.1 The advisory for the malicious ua-parser-js versions of October 2021 treats a computer which installed or ran the package as "fully compromised", and every secret and key stored on it is to be replaced from a different computer.2

Scope of the compromise

In the Nx compromise of August 2025, the install script searched the disk for wallets, keystores, .env files and SSH keys, read the GitHub CLI token and the contents of .npmrc, and added a shutdown command to the shell start files .bashrc and .zshrc.34 Deleting the package leaves such changes in place, and removal gives no guarantee that all the malicious software is gone.2

Stolen tokens keep working after the package is deleted from the registry. Attackers hold back some of the tokens they collect and can start a new campaign with them "weeks or months" later.1

A package can arrive without anyone typing its name: through transitive dependencies, AI agents, editors or editor extensions. The Nx team's own VS Code extension, Nx Console 18.6.30 to 18.65.1, installed the latest nx to read its version number, so opening the editor while the bad version was tagged as latest ran the malware.4

Confirm the installation

The advisory names the package and the affected versions. npm ls prints every installed copy of a package, including copies nested under other dependencies:

npm ls nx

Two more places can hold the bad version: the lockfiles package-lock.json and yarn.lock, which record nested dependencies, and cached copies in artifact repositories and dependency tools.5 The bad nx versions were on the registry from 18:32 to 22:44 EDT on 26 August 2025, so an install in that window is the event to look for.4

Some advisories name traces on disk. For Nx, a file at /tmp/inventory.txt listed the files the malware had read, and its presence meant the machine was affected.4

Replace the credentials

Replacement is done from a computer that never installed the package, because the affected one may still run attacker code.2 What the code could read decides what goes on the list, and after the npm worm the advice was to rotate all developer credentials at once.5

Table 1. Credentials to replace after an install of the malicious Nx versions
CredentialWhere the malware read itReplacement
npm tokens.npmrcOn npmjs.com: profile picture, Access Tokens, then the × button or Delete Selected Tokens. On the command line: npm token list, then npm token delete with the token ID. Revocation can take up to an hour.6
GitHub CLI tokengh auth tokenRevoke the authorization of the app the GitHub CLI signs in with. The next gh command signs in again and receives a new token.4
Other tokensEnvironment variablesReplace each token at its service. The Nx maintainers also advised changing the GitHub password and the passwords of other services.4
SSH keysKey files on diskGenerate a new key pair and revoke the old one.3
Cloud and API keys.env files and environment variablesAt each provider; see Responding to a leaked API key.
Cryptocurrency walletsWallet filesMove the funds to a new wallet. A wallet cannot be rotated.3

When the install ran in a CI job, the secrets passed to that job belong on the list. The Nx malware ran in GitHub Actions as well as on developer machines, and the second Shai-Hulud wave changed its behaviour when it detected a CI environment.31

Remove the package and its traces

Upgrade or remove the package so the lockfile no longer names the bad version, then clear the package caches so that a later install cannot reuse the copy on disk. The Nx advisory gives these commands:4

npm uninstall nx && npm install nx@latest
npm cache clean --force
yarn cache clean --all
pnpm store prune --force
# then delete ~/.npm/_npx (macOS, Linux)
# or %LocalAppData%/npm-cache/_npx (Windows)

An organization that mirrors npm through an internal registry, such as JFrog Artifactory or Sonatype Nexus, deletes the versions there as well. On each affected machine, open .bashrc and .zshrc and delete lines the owner did not write.4 In CI, npm ci rebuilds node_modules from the corrected lockfile: it deletes the existing folder first and stops with an error when the lockfile and package.json disagree.7

Find out how the credentials were used

On GitHub, the account's security log holds the actions of the last 90 days. It is under Settings, in the Archives section, Security log, and can be searched by event name and exported as JSON or CSV.8 The repo.create event records each new repository; the Nx malware published its haul as a repository named s1ngularity-repository, and the maintainers pointed users to the search action:repo.create.4

Remove GitHub Apps and OAuth applications that are not needed, and audit repository webhooks and secrets.5 Authorized apps are listed under Settings, Applications, Authorized GitHub Apps, each with a Revoke button.9 For cloud and API keys, the provider's usage records show what a key did; the steps are in Responding to a leaked API key.

Notable incidents

Nx "s1ngularity" (2025)

On 26 August 2025, in a supply chain compromise, an attacker published malicious versions of the Nx build system and several of its plugins with an npm token stolen through an injection flaw in the project's GitHub Actions workflow.4 The install script prompted AI command-line tools, among them Claude, Gemini and Q, with flags such as --dangerously-skip-permissions to search the file system, then uploaded the results, base64-encoded, to public repositories it created in each victim's GitHub account. GitHub disabled those repositories after about eight hours. Wiz counted over a thousand valid GitHub tokens and dozens of valid cloud credentials and npm tokens in them, and treated the data as public, since base64 decodes without a key. In a second phase, the leaked tokens were used to make over 5,500 private repositories of more than 400 users and organizations public.3

Prompt for a coding agent

This prompt has an AI coding agent find the bad version and list the credentials to replace, without running any install.

A malicious version of the package [NAME], versions [VERSIONS], was published to npm. Do not run npm install, npm ci or any package script. Search package-lock.json, yarn.lock and pnpm-lock.yaml in this project, including nested dependencies, for those versions and report each match with its path in the dependency tree. Then list the names, never the values, of every environment variable, .env entry, CI secret and config key this project uses for API keys, tokens and passwords, with the service each one belongs to, so they can be replaced.

In SecFlash

SecFlash reports a dependency version published as malware as SF-SEC-713 on the Security page, and a package the app uses that was published to attack its installers as SF-THR-201 on the Threats page.

See also

References

  1. a b c Ficorilli, Madison (23 December 2025). "Strengthening supply chain security: Preparing for the next malware campaign". The GitHub Blog.
  2. a b c GitHub (22 October 2021). "GHSA-pjwm-rvh2-c87w" (ua-parser-js). GitHub Advisory Database.
  3. a b c d e Wiz Threat Research (updated 29 August 2025). "s1ngularity: supply chain attack leaks secrets on GitHub" (title shortened). Wiz Blog.
  4. a b c d e f g h i j Nx maintainers (27 August 2025). "Malicious versions of Nx and some supporting plugins were published", GHSA-cxm3-wv7p-598c. GitHub security advisory, nrwl/nx.
  5. a b c CISA (23 September 2025). Alert on the widespread supply chain compromise in npm (Shai-Hulud). Cybersecurity and Infrastructure Security Agency.
  6. back "Revoking access tokens". npm Docs. GitHub.
  7. back "npm-ci". npm Docs, CLI v11. GitHub.
  8. back "Reviewing your security log". GitHub Docs.
  9. back "Reviewing and revoking authorization of GitHub Apps". GitHub Docs.