惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

NodeJS Security & NodeJS Secure Coding's Blog

Argument Injection vulnerability in git-blame@1.4.0 Argument Injection vulnerability in `gits@0.1.8` Command Injection vulnerability in `@fab1o/git@1.4.0` Command Injection vulnerability in `git-contributors` via unsanitized CLI arguments Command Injection vulnerability in `git-q@0.0.3` Command injection vulnerability via unsanitized CLI arguments in touxing/fast-git-clone Command Injection vulnerability in `willitmerge@0.2.1` A Directory Traversal Vulnerability I found in Mastra AI Frameworks MCP Server Mastering NPX: A Cheatsheet for npm and Node.js Power Users Mitigate Supply Chain Security with DevContainers and 1Password for Node.js Local Development The Tale of the Vulnerable MCP Database Server Bad Security Defaults in Mastra AI Frameworks Templates SQL Injection and Bypassing "Read-Only" Mode in Xata's MCP Server Security Advisory for qix npm supply-chain compromise affecting debug and billions of weekly download users How to Mitigate SQL Bypass in MCP Servers Enhancing MCP Server Security: A Guide to Using execFile Argument Injection Vulnerability in ggit How to Bypass Access Control in PostgreSQL in Simple PSQL MCP Server for SQL Injection Command Injection Flaws in ggit: Unveiling a Vulnerability Command Injection Vulnerability in Create MCP Server STDIO Tool Exposes System Monitoring Functions GitHub Kanban MCP Server Command Injection Vulnerability Threatens Developer Workflows Critical Command Injection Flaw in iOS Simulator MCP Server Exposes Development Environments Command Injection Vulnerability Discovered in Codehooks MCP Server: A Critical Security Analysis SSRF Shenanigans in safe-axios: Redirects Open the Backdoor SSRF Vulnerability in safe-axios: Unintended Public Address Classification Bypassing SSRF Safeguards in ssrfcheck: A Case of Incomplete Denylists Don't Be Fooled by Multicast, SSRF Bypass in private-ip Node.js Authentication from Lucia to Better Auth Bypassing SSRF Protection in nossrf: When Your Safeguards Become Loopholes Vue CLI Security Fix to Mitigate NPM Binary Planting Node.js API Security Vulnerabilities with Path Traversal in files-bucket-server Will You Accept These GPT 4o Secure Coding Recommendations? Command Injection Vulnerability in interactive-git-checkout npm package An Introduction to SSRF Bypasses and Denylist Failures Disclosing a Command Injection Vulnerability in `git-checkout-tool` Prisma Raw Query Leads to SQL Injection? Yes and No Flawed Git Promises Library on npm Leads to Command Injection Vulnerability Regex Gone Wrong: How parse-duration npm Package Can Crash Your Node.js App How I found an XSS in the Nuxt MDC Library for Markdown Content Holes in the Safety Net: Bypassing SSRF Protection in safe-axios How to Parse URLs from Markdown to HTML Securely? NPM Ignore Scripts Best Practices as Security Mitigation for Malicious Packages Where to find npm vulnerabilities? How to Hunt for IDOR Vulnerabilities To Exploit Security Misconfiguration? How to Avoid JWT Security Mistakes in Node.js Can a Node.js Secure Code Review Find Future Vulnerabilities? The Okta bcrypt Security Incident and The Bun vs Node.js Angle in Secure By Design NodeJS Path Traversal Vulnerability Scanner Do not use secrets in environment variables and here's how to do it better How to use npm audit How to use yarn audit Raw SQL Queries are Actually Better for Security Than ORMs? Node API Security Is Node.js Secure? URL Regex Validation: what can go wrong? Uncovering a Prototype Pollution Regression in the core Node.js project Deno CLI Vulnerability Repeats npm mistakes: CVE-2024-37150 Security skills for JavaScript developers Understanding and Preventing Prototype Pollution in Node.js How to protect against a security breach in React Server Components IDOR Vulnerability: What is it and how to prevent it? The security vulnerability of serving images via a route as opposed to static middleware in Node.js Why is it considered a bad practice to write raw SQL commands? JS Security Concepts for JavaScript Developers Secure Coding Practices in Node.js Against Path Traversal Vulnerabilities Secure JavaScript Coding Practices Against Command Injection Vulnerabilities To IDOR or Not to IDOR: Insecure Direct Object Reference in JavaScript Applications Explained npm vulnerabilities: reviewing the security of your dependencies Disclosing code injection vulnerabilities in safe-eval-2 npm package Introducing Node.js Security Permissions Model, Threat Model, and Security Releases Common Node.js Security Issues and How to Mitigate Them How JavaScript developers should embrace npm security The XZ backdoor CVE-2024-3094: a JavaScript perspective Node.js Security Best Practices The Case for Node.js Secure Configuration Protecting Against Common Node.js Vulnerabilities Input Validation Security Best Practices for Node.js A Node.js Vulnerability Scanner to Avoid Security Risks of EOL Runtime Versions JavaScript Security Issues in Node.js Applications OWASP Node.js Authentication, Authorization and Cryptography Practices OWASP Node.js Best Practices Guide Secure JavaScript Coding to Avoid Insecure Direct Object References (IDOR) North Korea malware on npm and Ledger connect-kit crypto heist 10 Best Practices for Secure Code Review of Node.js code Node.js and OWASP Top Ten Command Injection: Don't Let Your App Go 'BOOM' Secure Code Review Tips to Defend Against Vulnerable Node.js Code Destroyed by Dashes: How Two Hyphens Cause Argument Injection Vulnerability in blamer npm Package Securing Your Node.js Apps by Analyzing Real-World Command Injection Examples An Introduction to Command Injection Vulnerabilities in Node.js and JavaScript
Hardening Your npm and pnpm Configs in the Age of Shai-Hulud
2026-05-30 · via NodeJS Security & NodeJS Secure Coding's Blog

The npm worm is no longer hypothetical.

In the past nine months, the npm ecosystem has been hit by three of the most consequential supply-chain attacks in its history:

  • Shai-Hulud — a self-replicating worm that compromised maintainer accounts via stolen tokens and CI secrets, then used those credentials to publish malicious versions of packages those maintainers owned. It hit ngx-bootstrap, tinycolor, and dozens of others before npm could contain it.
  • TanStack npm packages compromised via the Shai-Hulud campaign — the same worm reaching deeper into the ecosystem, targeting one of the most-downloaded TypeScript ecosystems on the registry.
  • Axios npm package compromise — a cross-platform RAT delivered through a single hijacked release, demonstrating how far a single compromised maintainer credential can travel through a package with hundreds of millions of weekly downloads.

The common thread in all three: attackers don’t need a zero-day, they need a postinstall hook and a few minutes before someone notices. Once a malicious release is live on the registry, every CI pipeline running npm install or pnpm install is a target. The window between publication and detection is the entire attack.

Your package manager’s config file is where you close that window. Not your linter, not your SBOM, not your audit pipeline — the .npmrc and pnpm-workspace.yaml sitting at the root of your repo. They decide whether your machine runs an attacker’s postinstall script, whether it accepts a hijacked release that’s three minutes old, whether it lets a transitive dep yank in code from a random GitHub URL.

This post is the config I’m now rolling out across all my own repos. Every directive carries its threat model in a comment, so a reader (or a future you) can tell what each line is actually defending against. Copy-paste-ready at the end.

The canonical reference for everything below is my npm Security Best Practices repo — it’s where these directives live as a curated, version-tracked source of truth. This post is the narrative companion: why each one matters, what attack it stops, and where the gotchas are.

The threat model in one paragraph

A malicious npm package can hurt you in four ways:

  1. Install-time code execution via lifecycle scripts (preinstall, postinstall, etc.) that run during npm install without you ever importing the package.
  2. A fresh malicious release — a hijacked maintainer account publishing a backdoored version that gets yanked within hours, but not before your CI pulls it.
  3. Non-registry dependency sourcesgit+ssh://, tarball URLs, or GitHub shortcuts that bypass the registry’s signing, provenance, and yanking entirely.
  4. Trust regression — a previously well-signed package suddenly publishing without provenance or trusted-publisher attestations, signaling an account takeover.

Every directive in the configs below targets one of these.

Hardening .npmrc

If your project uses npm directly, this file goes at the repo root:

# npm security best practices

# Source: https://github.com/lirantal/npm-security-best-practices

# SECURITY: do not run any lifecycle scripts (preinstall, install,

# postinstall, etc.) for dependencies. Postinstall scripts are the

# classic malware delivery vector — a transitive dep can execute

# arbitrary code on your machine during `npm install` without you

# ever running its code at runtime.

ignore-scripts=true

# SECURITY: reject git-source dependencies (git+ssh://, github:owner/repo,

# etc.). Git deps can ship their own .npmrc that overrides the path to

# the npm binary, achieving arbitrary code execution at install time —

# bypassing ignore-scripts entirely. This will be the default in npm 12.

allow-git=none

# SECURITY: refuse to install package versions younger than 30 days.

# Gives the community time to spot and yank hijacked releases before

# they reach your install. Value is in days.

min-release-age=30

Version floor

allow-git and min-release-age were both introduced in npm 11.10.0. Older versions silently ignore them. Pin your floor in package.json:

{

"engines": {

"npm": ">=11.10.0"

}

}

Your own project’s engines is always enforced regardless of engine-strict, so this is sufficient to block installs on stale npm versions.

The allow-git detail that’s easy to miss

ignore-scripts=true is the well-known defense. What’s less appreciated: a git-source dependency can ship its own .npmrc that overrides the path npm uses to find its binary. That override fires before lifecycle scripts are even considered, so ignore-scripts doesn’t apply. allow-git=none is what plugs that hole. It will be the default in npm 12 — set it now and be forward-compatible.

For more on lifecycle-script defenses specifically, see NPM Ignore Scripts Best Practices.

Hardening pnpm-workspace.yaml

pnpm 10 added a more granular set of supply-chain controls than .npmrc exposes. If your project uses pnpm, this is the file:

# npm security best practices

# Source: https://github.com/lirantal/npm-security-best-practices

packages:

- "packages/*"

# SECURITY: block packages newer than 30 days (43200 minutes).

# Gives the community time to spot and yank hijacked releases

# before they reach your install.

minimumReleaseAge: 43200

# SECURITY: reject a version whose publishing trust signals

# (npm provenance, trusted-publisher status, registry signatures)

# have regressed from prior releases. Catches account-takeover

# attacks where the attacker can't reproduce the legitimate CI

# pipeline that produced earlier provenance.

trustPolicy: no-downgrade

# Per-package or per-version exemptions for legitimate trust

# regressions (e.g. a maintainer who genuinely switched CI providers).

# Keep empty; add entries only with a written justification, and

# prefer a specific version range over allowing an entire package.

# Example:

# trustPolicyExclude:

# - 'chokidar@4.0.3'

# - 'webpack@4.47.0 || 5.102.1'

# Disabled intentionally. Skipping the trust check for older

# versions sounds useful for genuinely pre-provenance packages

# (npm provenance launched April 2023), but any value near

# minimumReleaseAge nullifies trustPolicy entirely — every

# installable version becomes exempt. Use trustPolicyExclude

# above for legitimate legacy cases instead.

# trustPolicyIgnoreAfter: 43200

# SECURITY: block install scripts by default; explicit allow-list

# only. Postinstall scripts are a primary malware delivery vector

# for transitive dependencies. Keep this list small and only

# enable packages whose postinstall is genuinely required.

allowBuilds:

# Native bundler; postinstall fetches the platform-specific binary.

esbuild: true

# Native bundler; postinstall fetches the platform-specific binary.

rolldown: true

# Native module resolver used by some toolchains.

unrs-resolver: true

# SECURITY: fail the install if a dependency wants to run a build

# script that isn't in the allow-list above. Without this, new

# postinstall scripts get silently skipped — you'd never know to

# audit them.

strictDepBuilds: true

# SECURITY: reject dependencies sourced from git URLs, tarball

# URLs, or local paths. These bypass registry signing, provenance,

# and yanking, and have been weaponized to deliver malware through

# innocent-looking transitive deps.

blockExoticSubdeps: true

If your repo is not a monorepo, omit the packages: block entirely — pnpm 10+ uses pnpm-workspace.yaml as the home of all config, not just workspace config.

Version floor

The highest individual floor among the active directives is blockExoticSubdeps, introduced in pnpm 10.26. Pin it:

{

"engines": {

"pnpm": ">=10.26"

}

}

If you’re using corepack, you can pin exactly:

{

"packageManager": "pnpm@10.26.0"

}

Note that pnpm 11 (released April 2026) makes minimumReleaseAge, strictDepBuilds, and blockExoticSubdeps defaults. If your team controls the pnpm version end-to-end, you can bump the floor to >=11 and let several of these directives become redundant — though leaving them explicit is harmless and self-documenting.

The trust-policy trap

The single subtlest gotcha in the pnpm config is the relationship between minimumReleaseAge and trustPolicyIgnoreAfter. The latter is a knob that says “skip the trust-policy check for versions older than N minutes” — useful in theory for genuinely pre-provenance packages (npm provenance launched April 2023, so most old releases lack it).

The trap: if you set trustPolicyIgnoreAfter to the same value as minimumReleaseAge (or even close to it), the two windows are exact complements. Every package eligible to install — by definition older than minimumReleaseAge — is automatically exempted from the trust check. trustPolicy: no-downgrade becomes a no-op for everything that actually reaches your node_modules.

The fix is to either set trustPolicyIgnoreAfter substantially higher than minimumReleaseAge (so the trust check has a real window to operate in), or to disable it entirely and rely on trustPolicyExclude for the rare legacy package that legitimately can’t satisfy the policy. The config above takes the second approach — simpler, harder to misconfigure.

What none of this protects against

A few honest disclaimers, because nobody benefits from oversold defenses:

  • A malicious package already in your dependency tree. If you depend on lodash and someone hijacks the maintainer account today, none of these settings will rescue you on the next install of an existing version — they govern new installs, not what’s already in your node_modules from a prior install. Pair this config with a lockfile + npm ci / pnpm install --frozen-lockfile discipline.
  • Runtime behavior. None of these settings inspect what the package does once it’s loaded. A package that lies dormant for weeks and then exfiltrates secrets at runtime is invisible to install-time policy.
  • Direct code execution from your scripts. A malicious package.json script in your own repo (e.g., from a malicious PR) runs regardless of any of this. Code review of package.json changes is your defense there.

For deeper coverage of these adjacent gaps, see Liran’s Node.js Secure Coding materials and the post on how JavaScript developers should embrace npm security.

A recap for the actually-in-a-hurry reader

If you have five minutes, do this:

  1. Copy the .npmrc or pnpm-workspace.yaml block above into the root of every repo you maintain.
  2. Add engines.npm or engines.pnpm to each repo’s package.json to enforce the floor.
  3. Commit. Open the PR. Merge. Repeat across your repo set — gh CLI’s Contents API makes this scriptable across hundreds of repos without ever cloning.
  4. Watch the next supply-chain incident hit your feed and feel quietly fine about it.

The threat is no longer hypothetical, and the controls are no longer experimental. The Shai-Hulud worm and its descendants will keep finding new maintainers, new tokens, new packages. The point of these configs isn’t to predict the next attack — it’s to make sure that when one lands, your pnpm install simply refuses to bring it home.

Canonical reference:

Recent supply-chain incidents and analysis:

Defensive practices: