HeadlinesBriefing favicon HeadlinesBriefing.com

npm v12 security defaults tighten script and Git handling

Hacker News •
×

The npm team previewed breaking changes slated for npm v12, targeting script execution and remote source handling. Starting with npm 11.16.0, warnings surface for each upcoming default shift, letting maintainers test before the July 2026 release. Core changes flip automatic behaviors into opt‑in actions, tightening supply‑chain security across the JavaScript ecosystem. By disabling implicit node‑gyp rebuilds, the default shields projects from silent native code injection.

Two flags drive the new model. allow-scripts now defaults to off, so npm install skips preinstall, install and postinstall scripts unless a project explicitly approves them via npm approve‑scripts and records the allowlist in package.json. Likewise, allow-git defaults to none, blocking Git dependencies unless the flag is set, closing a vector where a malicious .npmrc could hijack the Git binary.

Developers can preview the impact by upgrading to npm 11.16.0+, running a normal install, and reviewing the generated warnings. Packages flagged for scripts are either approved with npm approve‑scripts or denied with npm deny‑scripts, and the resulting configuration persists across the v12 upgrade. The changes also leave --allow‑remote, --allow‑file and --allow‑directory defaults untouched. Teams should commit the allowlist to version control to ensure reproducible builds across CI pipelines.