3-minute product tour Urgent incident email
Security blog

Installation risks highlighted by npm supply chain incidents

The public Nx and Shai-Hulud incidents illustrate what to review during package installation.
The article explains install script policies, dependency review, and testing in isolation.

Installation risks highlighted by npm supply chain incidents

Nx, August 26, 2025

An injection issue in a GitHub Actions workflow exposed an Nx npm publishing token, and malicious releases were available for several hours. Versions nx 20.9.0 through 20.12.0, 21.5.0 through 21.8.0, and several @nx/* packages were affected. The malicious releases contained postinstallthat runs through telemetry.jscontained malicious code.

Post-incident analysis says the install script attempted to bypass approval checks in Claude Code, Gemini CLI, and Amazon Q CLI when these tools were present. Investigate unusual access to wallet files, SSH keys, and .env files and other sensitive data in the development environment. Look for newly created public repositories with names beginning with s1ngularity-repository. Analyses differ on whether the AI tools acted on the request. Nx identified the lack of npm provenance in the malicious releases as a warning sign.

Shai-Hulud, September 2025

The Shai-Hulud worm was discovered the following month. CISA reported in its September 23 alert that more than 500 npm packages were affected. Compromised install scripts targeted secrets in development environments, and exposure of publishing credentials could put more packages at risk. Review installation history, package publishing records, and unusual activity in developer and CI accounts together.

In both cases, developers ran their usual npm install. An application code review alone cannot cover this installation step.

Disable install scripts by default

The most effective control is to disable dependency install scripts by default. Starting with 10.0, pnpm skips dependency lifecycle scripts by default, and onlyBuiltDependenciescontrols which packages can run scripts. npm also lets you disable them through configuration.

npm config set ignore-scripts true
npm ci --ignore-scripts

onlyBuiltDependencies:
  - esbuild
  - sharp

Disabling scripts can break packages that need to build at install time, such as native modules. Expect to spend the first few days creating an allowlist for legitimate packages that fail. Malicious code in the library itself can stay inactive during installation and run requirewhen first used.

Test newly introduced versions in an isolated environment first

Test new packages, and packages whose maintainers have changed, in an environment without secrets. A container without host mounts is a simple starting point.

docker run --rm node:22 \
  sh -c "mkdir /tmp/t && cd /tmp/t && npm init -y >/dev/null && \
         npm install example-package@1.2.3 --foreground-scripts 2>&1" | tee install.log

This can reveal which commands an install script runs and where it tries to connect. Code that depends on particular CI environment variables or starts after a certain date may stay dormant in an empty container.

When the Genox Vulnerability Scanner finds warning signs such as a maintainer change or obfuscation, the Behavioral Analyzer runs the installation in a sandbox to monitor environment-variable access and outbound connections. Use this check alongside install script restrictions because sandbox testing has the same limitations described above.

If you already installed an affected version

If you installed an affected release, isolate the workstation or CI runner and preserve logs and change records. Revoke or rotate any potentially exposed npm, GitHub, and cloud credentials. Check your GitHub organization for newly created s1ngularity-repository or Shai-Hulud repositories, or the .github/workflows/shai-hulud-workflow.yml file. In Nx environments, review ~/.bashrcand ~/.zshrcfor changes. If you find unauthorized configuration changes, preserve the evidence before restoring a verified configuration.

References

Talk to Genox
about scope and timing.

Talk to us