← Back to Blog
·Feb 26, 2026·5 min read

Supply Chain Attacks Are Coming for Your node_modules

The npm ecosystem is a security nightmare. Real stories, real vulnerabilities, and how to protect yourself from malicious packages.

securitynpmsupply-chainvulnerabilities
JV

Jose Viscasillas

February 26, 2026 · 5 min read

Supply Chain Attacks Are Coming for Your node_modules

Your node_modules folder has 1,247 packages. You've reviewed approximately zero of them.

You ran npm install. You trusted the maintainers. You trusted npm. You assumed that if a package had millions of weekly downloads, it must be safe.

That assumption is wrong.

The Attack Surface

Every dependency is a potential vulnerability. Not just the code you install today—every future update, every new maintainer, every compromised account.

The numbers are staggering:

  • Average React app: 1,000+ dependencies
  • Average npm package: 5-10 dependencies
  • Zero-day vulnerabilities in popular packages: increasing year over year

Your attack surface includes everyone who has write access to any package you depend on. Directly or transitively.

Real Attacks That Happened

event-stream (2018)

A popular package with millions of downloads. A new maintainer was added. They introduced code that stole cryptocurrency wallet keys from specific applications.

The malicious code sat undetected for months. Millions of people installed it.

ua-parser-js (2021)

A package used by... everyone. Parse user agent strings. Super common.

The maintainer's npm credentials were compromised. Attackers published versions that ran cryptominers and stole data. Anyone who ran npm update during the window got infected.

colors and faker (2022)

A maintainer, upset about not being paid for his work, deliberately corrupted his own packages. Infinite loops. Broken builds. Millions of developers affected.

This wasn't even malicious in the traditional sense. It was a protest. Your supply chain includes maintainer sentiment.

node-ipc (2022)

Protestware. The maintainer added code that, on certain IP addresses (Russian and Belarusian), would overwrite files on disk. Political protest via dependency injection.

Whether you agree with the politics or not, your dependencies can execute arbitrary code on your machine.

The Attack Vectors

Compromised maintainer accounts

Phishing, password reuse, leaked tokens. Maintainers are humans. Humans get hacked.

Malicious new maintainers

A helpful contributor offers to maintain a package. The original maintainer, burnt out, agrees. The new maintainer has different intentions.

Typosquatting

react-router vs react-ruter. One letter difference. The typo version might be malicious.

Dependency confusion

A malicious package with the same name as an internal package, published to public npm. npm install might pull the public (malicious) version instead of your private one.

Install scripts

Some packages run scripts during installation. They have full access to your machine. You wouldn't run a random shell script from the internet, but npm install does it automatically.

How to Protect Yourself

1. Audit your dependencies

bash
npm audit
npm audit fix

This catches known vulnerabilities. Not zero-days, but something.

2. Use lockfiles

Commit package-lock.json. Pin versions. Don't let npm install pull latest silently.

3. Review new dependencies

Before adding a package:

  • Check the repository. Is it maintained?
  • Check the maintainers. Do they seem legitimate?
  • Check the downloads. Suspiciously low for what it does?
  • Check the dependencies. Why does a utility function need network access?

4. Use npm provenance

npm now supports provenance—cryptographic proof of where a package was built. Prefer packages with provenance.

bash
npm audit signatures

5. Run npm in CI with frozen lockfile

bash
npm ci

Not npm install. npm ci respects the lockfile exactly. No surprises.

6. Consider a private registry

For enterprise, cache packages in a private registry. Audit what you cache. Reduce exposure to npm directly.

7. Disable install scripts

bash
npm config set ignore-scripts true

Some packages need install scripts to work. But most don't. The security tradeoff is worth considering.

8. Use tools

  • Socket.dev: Analyzes packages for suspicious behavior
  • Snyk: Vulnerability scanning
  • npm audit: Built-in, basic but useful
  • OWASP Dependency-Check: Comprehensive scanning

The Hard Truth

You can't audit 1,247 packages. You can't review every line of code in your node_modules. The ecosystem is too big, changes too fast.

But you can:

  • Reduce your dependency count
  • Prefer well-maintained, popular packages
  • Pin versions and update deliberately
  • Stay informed about security issues
  • Have a plan for when (not if) a vulnerability is found

A Personal Story

I ran npm audit on a project last month. 47 vulnerabilities. Most were "moderate" severity. I ran npm audit fix and... it broke my app.

The fix required updating React. React 18 to React 19. Which required updating the router. Which required updating the form library. Which...

I spent a day on it. A day I didn't have. The vulnerabilities still aren't fully patched.

This is the reality. Security debt compounds like technical debt. The longer you wait, the harder it is to fix.

What the Ecosystem Needs

Better tooling: Automatic detection of malicious patterns. npm's provenance is a start, but not enough.

Smaller dependency trees: Stop installing 50 packages to left-pad a string. The ecosystem needs to value minimalism.

Maintainer support: Underpaid maintainers burn out or sell out. If we depend on packages, we should fund them.

Accountability: npm needs better security practices. Two-factor authentication should be required for popular packages.

The Bottom Line

Your node_modules folder is a security blind spot. You're trusting hundreds of strangers with your production environment.

That's the tradeoff we made when we embraced the npm ecosystem. It's productive. It's also risky.

Mitigate what you can. Accept what you can't. And keep npm audit in your CI pipeline.

---

Run `npm audit` today. I'll wait.

JV

Written by Jose Viscasillas

Senior Software Engineer building video platforms at ON24. 21 years of coding experience. I write about React, TypeScript, AI, and developer tools.

Recommended Reads

📬

Subscribe to the Newsletter

New articles delivered to your inbox. No spam, unsubscribe anytime.

Join 500+ developers getting weekly insights on React, TypeScript, and building products.