npm Supply Chain Attacks in 2026: How to Protect Your Team
ChainDrop reached more than 400 npm packages, and in November hijacked packages ran code without any install script. Why familiar defences fall short, and which settings to turn on this week.

On 3 November 2026, attackers pushed 12 new releases across 10 npm packages they had hijacked. Some of those packages had not been updated for years. According to Sonatype, the new code did not need an install script at all: it ran as soon as an application loaded the package, read the latest transaction from an Ethereum wallet, decoded a server address from it and fetched its next stage from there.
Three months earlier, Microsoft described ChainDrop, a self-propagating worm that reached more than 400 packages across multiple unrelated publishers, including widely used ones such as keyv, flat-cache and cache-manager.
If your team builds anything in JavaScript or TypeScript, from a website to an internal tool, these attacks are aimed at your machines and your CI. This guide explains how they work, why some familiar defences no longer cover them, and which settings are worth turning on this week.
Two attacks, two techniques
ChainDrop: a worm that publishes itself
Microsoft's analysis describes a variant of the "Mini Shai-Hulud" malware family. Evidence points to stolen maintainer credentials as the first step. After that, the worm spread by itself:
A compromised release runs a loader (
setup.mjs) through an npmpreinstallhook, which starts a heavily obfuscated payload.The payload collects npm, GitHub, AWS, Kubernetes and HashiCorp Vault credentials from the machine. On developer laptops it detaches and keeps running in the background. On CI runners it stays attached.
With a stolen npm token, it downloads the latest version of every package that publisher can release, adds itself, bumps the patch version and publishes again. One stolen token turns into a malicious patch release of every package that publisher can release.
With stolen GitHub credentials it adds files to repository branches for persistence, among them
.vscode/tasks.jsonand.claude/settings.json. These are configuration files that editors and AI coding assistants read automatically.
PolinRider: no install script needed
The November campaign took a different route. Sonatype says the loader runs "when its code is loaded", so blocking install scripts does not stop it. Its server address comes from a blockchain transaction, which means the operator can move to a new server without publishing another package version. Sonatype attributes PolinRider to North Korea's state-backed Lazarus Group.
Why the usual advice is not enough
Many teams rely on three habits: a lockfile, disabling install scripts, and trusting packages that show provenance. Each still helps, but each leaves a gap.
A lockfile protects you only until someone updates it. A routine
npm update, or an automated pull request that bumps dependencies, can pull a malicious patch release into the lockfile the day it is published.Blocking install scripts stops ChainDrop's
preinstallhook. It does nothing against PolinRider, whose code runs when the package is imported.Provenance proves where and how a package was built. It does not prove the code is safe. npm's documentation says so directly: provenance "does not guarantee the package has no malicious code". Microsoft also notes that releases the worm published from a hijacked publishing workflow could carry valid provenance, because they came from a legitimate workflow identity.
In both campaigns the malicious version was the newest one. The most effective defence is therefore time: do not install a version in the first hours or days after it is published, when most hijacks are found and removed.
Five settings for teams that install packages
1. Wait before installing new versions
Microsoft's first recommendation for ChainDrop is to update the npm CLI and use min-release-age. With it, npm only installs versions that have been public for at least the number of days you set. npm also has a before setting for installing as of a fixed date.
In pnpm the setting is minimumReleaseAge, measured in minutes. Its documented default is 1440, one day, and it covers transitive dependencies too. Packages you control, or an urgent security fix, can be exempted with minimumReleaseAgeExclude.
2. Allow install scripts by name
pnpm already blocks dependency build scripts: according to its build settings, any package not listed in allowBuilds is treated as unreviewed, and with the default strictDepBuilds: true the install fails until someone approves it. npm's configuration handles project policy through an allowScripts field in package.json. Keep the list short, and add each package only after you know why it needs a script.
3. Update on purpose, install exactly
In CI, use npm ci (or pnpm install --frozen-lockfile), which installs exactly what the lockfile says. Treat dependency updates as a separate, reviewed change: read which packages moved, and look harder at any package that had been quiet for years and suddenly has a new release. That was exactly what happened in the November campaign.
4. Close the side doors
As of npm 12, the allow-git and allow-remote settings default to none, so dependencies are no longer pulled from Git repositories or arbitrary URLs unless you allow it. If you are on an older npm, set them explicitly, or upgrade.
5. Give CI less to steal
The worm was after credentials. A build job that only runs tests does not need cloud keys or a publishing token. Use read-only tokens for installs, give each job only the secrets it uses, and keep publishing in a separate job.
Goal | npm | pnpm |
|---|---|---|
Delay new versions |
|
|
Control install scripts |
|
|
Install exactly the lockfile |
|
|
Block Git and URL sources |
| — |
If you publish packages
ChainDrop's spread depended on long-lived publishing tokens. npm trusted publishing replaces those tokens with short-lived OIDC credentials issued to a specific CI workflow. It needs npm CLI 11.5.1 or later and Node 22.14.0 or later, and it works with GitHub Actions, GitLab CI/CD and CircleCI on their cloud-hosted runners (not self-hosted ones). After setting it up:
In the package settings, require two-factor authentication and disallow tokens for publishing.
Run the publishing job in a protected environment, with protected release tags, so a change to a random branch cannot publish.
Review who and what can publish each package on a regular schedule.
None of this helps if an attacker controls the workflow itself, which is why Microsoft also lists token scopes and protected environments in its recommendations.
When a compromised version got in
Both Microsoft and Sonatype give similar steps:
Search lockfiles, CI caches and container images for the affected versions, then remove them and pin a known-good version.
Clear the npm and yarn caches, so a bad tarball is not reinstalled from cache.
Check whether the code actually ran. For PolinRider, loading the package is enough. If it ran, treat the machine as compromised.
Rotate every credential the machine could reach, from a clean machine: npm, GitHub, cloud and Kubernetes keys.
Check your repositories for branches or files you did not create, especially in editor and assistant configuration folders.
A short checklist for a small team
Set a release-age delay in every project and in CI.
Keep the install-script allow list short and reviewed.
Use
npm ciin CI and review dependency updates as code.Upgrade to npm 12, or set
allow-gitandallow-remoteyourself.Move package publishing to trusted publishing and disallow tokens.
Write down an incident plan: who rotates which keys, and in what order.
None of these items is hard. The usual problem is that they belong to nobody, so they never get done. If your team plans its work in Hamroshd, put this checklist in a task database with an owner and a due date, and make the token review a recurring task. That turns "we should do this" into something that shows up on someone's board.
Sources
ChainDrop supply chain compromise: Anatomy of a self-propagating worm, Microsoft Security Blog, 4 August 2026
How a Compromised npm Package Used Ethereum to Fetch Its Next Stage (PolinRider), Sonatype
Trusted publishing for npm packages, npm Docs
Generating provenance statements, npm Docs
npm config (v12), npm Docs
Dependency resolution settings and build settings, pnpm


