axios 1.14.1 and 0.30.4 were malware: finding the plain-crypto-js install in our builds
For about three hours on 2026-03-31, the latest axios release on npm pulled in plain-crypto-js, whose install script dropped a remote access trojan. Here is how we checked lockfiles, caches and CI logs, what we rotated, and the install settings we changed so it cannot happen the same way again.
On the morning of 2026-03-31 (UTC) a teammate shared the axios issue titled "axios@1.14.1 and axios@0.30.4 are compromised" in our engineering channel. axios is in almost every Node.js service we run, usually as a direct dependency, sometimes three levels deep under an SDK. The first question was not "are we safe" but "did any machine of ours run npm install against the registry between 00:21 and 03:15 UTC, and did it resolve axios fresh instead of from a lockfile".
What the malicious release did
According to the maintainers' post-mortem, an attacker took over the lead maintainer's npm account after a targeted social engineering campaign put a remote access trojan on his computer. 2FA was enabled, but malware on the machine made it irrelevant. With the account, the attacker published two versions that never existed in the GitHub repository:
Version | Published (UTC, 2026-03-31) | Line |
|---|---|---|
| 00:21 | 1.x, tagged |
| about 01:00 | 0.x legacy |
Both added one new dependency, plain-crypto-js@4.2.1. That package had an install script that downloaded and started a cross-platform remote access trojan on macOS, Windows and Linux, then cleaned up after itself so the folder in node_modules looked harmless. npm removed the axios versions at 03:15 UTC and plain-crypto-js at 03:29 UTC. Roughly three hours of exposure, on a package with hundreds of millions of monthly downloads.
Reproducing our exposure
We could not, and should not, reproduce the payload. What we could reproduce was the resolution: which of our installs would have picked 1.14.1. That depends on the range in package.json and on whether the install respected a lockfile:
# A caret range accepts 1.14.1 as soon as it is published
npm view axios@'^1.13.0' version --json
# npm ci installs exactly what the lockfile says and never upgrades
npm ci
# npm install, npx and "latest" pulls can upgrade within the range
npm install
npx some-cli@latest
Services built with npm ci from a committed lockfile were not exposed unless the lockfile was regenerated in that window. The risky paths were:
local
npm installornpm updateon developer laptops that morning,CI jobs that ran
npm installwithout a lockfile (two internal tools still did),npxcalls that fetched a CLI with axios inside it, which leave no trace in any lockfile,Docker builds whose
RUN npm installlayer was not cached and so re-resolved.
Root cause
Not a bug in our code: a trusted package name published malicious content, and our install process allowed new versions and install scripts to run with full access to the build machine and its secrets. Two settings made it possible for us specifically: caret ranges resolved at install time in a few jobs, and npm running lifecycle scripts by default.
What is happening under the hood
When npm installs a package it runs its preinstall, install and postinstall scripts unless told otherwise. The script runs as the user doing the install, with that user's environment. On a CI runner that environment usually holds an npm token, a cloud deploy key and the source of the repository. On a laptop it holds SSH keys, browser profiles and cloud CLI credentials.
The attack did not need a vulnerability in axios. Adding a dependency is a normal change, and the dependency's install script did the work. One community analysis in the issue noted that the package swapped a clean manifest in after running, so checking node_modules/plain-crypto-js afterwards was not reliable evidence. The lockfile and network logs were.
Environment
Component | Version / value |
|---|---|
Node.js | 22 LTS and 24 LTS |
npm | 10.9 and 11.x |
CI | GitHub Actions hosted runners, self-hosted runners for two repos |
Lockfiles |
|
Affected packages |
|
Clean versions |
|
Who is affected
Anyone whose install resolved one of the two axios versions during the window, directly or through another package. If your lockfile pinned an earlier axios and you only ran npm ci, you were not affected. If you cannot tell, treat the machine as affected.
The fix
1. Search every lockfile, not just the main app. We cloned all repositories and ran one search across every lockfile format:
grep -rnE 'axios@?(1\.14\.1|0\.30\.4)|"axios": "(1\.14\.1|0\.30\.4)"|plain-crypto-js' \
--include=package-lock.json --include=npm-shrinkwrap.json \
--include=yarn.lock --include=pnpm-lock.yaml --include=bun.lock \
~/src
Also check the git history of each lockfile, because a bad version may have been committed and then replaced by a later Renovate or Dependabot run:
git log -p --since=2026-03-30 -- package-lock.json pnpm-lock.yaml yarn.lock | grep -n 'plain-crypto-js'
2. Check what actually got installed. On machines that still had node_modules:
npm ls plain-crypto-js axios --all
And the npm cache, which keeps an index of everything fetched:
grep -rl 'plain-crypto-js' "$(npm config get cache)/_cacache/index-v5" 2>/dev/null
3. Check CI logs and network logs. For CI we exported job logs from 2026-03-30 to 2026-04-01 and searched for plain-crypto-js and axios@1.14.1. The post-mortem lists a network indicator to look for in DNS and egress logs:
domain: sfrclak[.]com (port 8000)
ip: 142.11.206.73
We found one hit: an internal CLI installed with npx inside a self-hosted runner job at 01:47 UTC. Nothing in any lockfile pointed to it.
4. Treat a hit as a compromised machine. For that runner we:
took it offline and rebuilt it from the base image instead of cleaning it,
rotated every secret the job could read: the npm automation token, the cloud deploy role credentials, a container registry password and the repository deploy key,
reviewed the cloud audit logs for actions by those credentials after 01:47 UTC,
pinned axios to
1.14.0in the affected tool and regenerated its lockfile from a clean machine.
5. Make installs boring. These went into every repository:
# .npmrc
ignore-scripts=true
save-exact=true
min-release-age=3
ignore-scripts=true stops dependency lifecycle scripts. A few packages need them (native modules such as esbuild or sharp fetch binaries); we run those explicitly with npm rebuild esbuild sharp after review. min-release-age=3 (npm 11.10 and later, in days) refuses versions younger than three days, which would have skipped the three-hour window entirely. CI uses npm ci only, and we replaced bare npx tool calls with a pinned dev dependency.
Alternatives and trade-offs
pnpm or Bun. pnpm does not run dependency build scripts unless they are allowed, and both have a minimum release age setting. Switching managers is a bigger change than an
.npmrc.A private registry proxy with a quarantine delay. Strong control for larger teams, but it is another service to run and patch.
Cooldown vs urgent patches. A release age delay also delays security fixes. We exclude nothing by default and bypass it per install when a CVE fix needs to go out the same day.
How to test the fix
Add a throwaway package with a
postinstallthat writes a file, install it, and confirm the file is not created withignore-scripts=true.Run
npm install axios@latestright after a release on a test repo and confirm npm picks the previous version because ofmin-release-age.Break the lockfile on purpose in a branch and confirm
npm cifails instead of resolving.
Confirming in production
Two weeks after the incident we re-ran the lockfile search across all repositories, re-checked egress logs for the indicator, and reviewed every rotated credential for use from unknown addresses. No further hits. The rebuilt runner pool now has outbound traffic limited to the registries and cloud endpoints it needs.
Regression guard
A CI step fails the build if
.npmrclacksignore-scripts=trueor if a job callsnpm installinstead ofnpm ci.Lockfile changes from bots wait for the release age window before auto-merge.
npxwithout an explicit version is blocked by a lint rule on workflow files.
Security implications
This is a security incident first. The payload ran with the installing user's rights, so assume anything readable by that user was taken: tokens, keys, cookies, source. Rotating secrets is not optional, and cleaning a machine in place is not enough; rebuild it. For your own packages, publish from CI with npm trusted publishing (OIDC) instead of long-lived tokens on a personal machine, which is the change the axios maintainers announced afterwards.
Prevention checklist
Commit lockfiles and use
npm cieverywhere automated.Set
ignore-scripts=trueand allow scripts per package after review.Set a minimum release age for new versions.
Pin CLIs used in CI instead of calling
npx tool@latest.Restrict outbound network access from build runners.
Know which secrets each CI job can read, so rotation takes minutes, not days.
References
axios issue, compromised versions: https://github.com/axios/axios/issues/10604
axios post-mortem: https://github.com/axios/axios/issues/10636
npm docs, config (
ignore-scripts,min-release-age,before): https://docs.npmjs.com/cli/v11/using-npm/confignpm docs,
npm ci: https://docs.npmjs.com/cli/v11/commands/npm-cinpm docs, trusted publishing: https://docs.npmjs.com/trusted-publishers
Add a label
Embed this post
<iframe src="https://hibug.me/axios-1-14-1-npm-compromise-plain-crypto-js" width="700" height="420" frameborder="0" loading="lazy"></iframe>
I have spent most of my career on the side of software that pages people at night: payment integrations, web platforms with real traffic, CI/CD pipelines, Kubernetes clusters and the databases underneath them. Somewhere along the way I started keeping a notebook of every bug that cost more than an hour — the exact error, what we ruled out, the real root cause and how we proved the fix. Hibug is where those notes live. Every post follows the same path: Investigate, Explain, Fix, Verify — with the environment spelled out, the fix tested, and the security angle checked.
Comments
0No comments yet. Be the first to comment!
Sign In to post a comment.