npm malware wave of 2026: why AI-built sites are at risk, and how to protect yours
Updated · by the Bologu team
2026 has been the worst year on record for npm, the JavaScript package registry. Attackers steal the accounts of people who maintain popular packages, then publish new versions with malware inside. Anyone who installs or builds a project during that window pulls the malware in without noticing. AI-built sites are especially exposed: AI installs packages often and rarely pins versions.
What happened
- April: Unit 42 tracked two waves calling themselves “Shai-Hulud: The Third Coming” and “Mini Shai-Hulud”, successors to the Shai-Hulud worm that spread through npm in late 2025.
- June–July: at least 32 packages under
@redhat-cloud-serviceswere hit, and AsyncAPI’s release pipeline was breached to publish trojanized versions. - August (ChainDrop): Microsoft reported more than 400 compromised packages, including
keyv,flat-cacheandcache-manager, which many projects pull in without their owners ever installing them directly. - November 3: Sonatype found 12 malicious releases across 10 hijacked packages that fetch their next stage through a blockchain. Some had not been updated in years.
What the malware does
From Microsoft’s analysis of ChainDrop, the main pattern is:
- Runs at install time: a
preinstallscript runs before installation finishes, before any tests or scanners get a chance. - Harvests secrets:
.envfiles, environment variables, GitHub, npm and AWS tokens, SSH keys and GitHub Actions secrets, then sends them out. - Spreads itself: with an npm token it publishes infected versions of every package that token’s owner maintains.
- Hides in AI tools: with stolen GitHub access it adds files to a repo’s
.claudeand.vscodefolders, so opening the project in Claude or VS Code can start the malware again.
Why AI-built sites are more at risk
- AI runs
npm installconstantly, and many agents install packages without asking. - AI-written
package.jsonfiles often use^,*orlatest, so yesterday’s release is accepted automatically. - Many projects have no lockfile, or build with
npm install, which can pick up versions newer than the ones you tested. - The machine you code on often holds real production keys in
.env.
How to protect your project
- Commit a lockfile and build with a lockfile-only install:
npm ci,pnpm install --frozen-lockfileoryarn install --immutableinstead ofnpm install. - Don’t take brand-new releases: Microsoft recommends npm CLI v12 with the
min-release-agesetting, so new versions wait a few days before they can be installed. Malicious versions are usually pulled within hours or days. - Stop using
*andlatestinpackage.json. - Keep production keys off the machine you code on. Use separate test keys, and give GitHub and npm tokens only the access they need.
- Review files in
.claude/,.vscode/and.github/workflows/whenever a commit appears that you didn’t make.
If you installed an infected version
- Treat every machine and CI runner that installed it as compromised, and rotate every key, token and password from a different, clean machine.
- Clear the npm, yarn and pnpm caches on developer machines and in CI.
- Reinstall from a lockfile that points to safe versions, then rebuild and redeploy everything.
- If you maintain packages yourself, check their publish history for versions you didn’t release.
A prompt for your AI
Harden this project against compromised npm packages:
1. Make sure a lockfile (package-lock.json / pnpm-lock.yaml / yarn.lock) is committed.
2. Change every install in CI, Dockerfile and deploy settings to a lockfile-only install
(npm ci, pnpm install --frozen-lockfile, yarn install --immutable).
3. Replace "*", "latest" and wide ranges in package.json with the versions now in the lockfile.
4. List every dependency that runs an install script (preinstall/install/postinstall)
and tell me which ones really need it.
5. Check .claude/, .vscode/ and .github/workflows/ for files or changes I did not make.
Do not upgrade any package in this change.Let Bologu check for you
The GitHub code check warns when there is no lockfile, when the build uses npm install instead of npm ci, when versions are * or latest, and when packages don’t exist or are barely used. It also compares your locked versions with the OSV.dev vulnerability database.
Sources
Read next
- Next.js ships security patches almost monthly: which version you need now (Nov 2026)
- Lessons from Moltbook: a fully AI-built site that let anyone read and edit its database
- Security checklist before launching an AI-built website
- What is Supabase RLS, and how to check your customers' data isn't exposed
- API key leaked in your website: how to check, and what to do right away
