Skip to content

feat: block unreviewed install scripts by default (v12) - #9424

Merged
owlstronaut merged 1 commit into
npm:latestfrom
JamieMagee:jamiemagee/install-scripts-phase-2
Jun 3, 2026
Merged

feat: block unreviewed install scripts by default (v12)#9424
owlstronaut merged 1 commit into
npm:latestfrom
JamieMagee:jamiemagee/install-scripts-phase-2

Conversation

@JamieMagee

@JamieMageeJamieMagee commented May 28, 2026

Copy link
Copy Markdown
Contributor

Flips the default so lifecycle scripts from packages not covered by allowScripts are blocked instead of run. The shared helpers and inBundle fixes this depends on are split into #9480, so this PR is now just the default change and the wording, docs, and snapshot updates that come with it. Targets latestonly since it needs a major.

Comment threadworkspaces/arborist/lib/arborist/rebuild.js
Comment threadlib/commands/rebuild.js Outdated
Comment threadworkspaces/libnpmexec/lib/index.js Outdated
Comment threadlib/utils/reify-output.js Outdated
Comment threadlib/commands/rebuild.js Outdated
@naugtur

Copy link
Copy Markdown

It'd be great to address this: #9450 before/in the next major.

with the allowlist feature, ignore-scripts=true is the necessary fallback for older npm versions.

@JamieMagee
JamieMageeforce-pushed the jamiemagee/install-scripts-phase-2 branch 4 times, most recently from 02a58af to bb916b2CompareJune 2, 2026 23:48
@JamieMagee
JamieMagee marked this pull request as ready for review June 2, 2026 23:52
@JamieMagee
JamieMagee requested review from a team as code ownersJune 2, 2026 23:52
Comment threadlib/utils/allow-scripts-cmd.js
@JamieMageeJamieMagee changed the title feat: Phase 2 of allowScripts opt-in install-script policyfeat: block unreviewed install scripts by default (v12)Jun 3, 2026
@JamieMagee
JamieMageeforce-pushed the jamiemagee/install-scripts-phase-2 branch from bb916b2 to 379b44aCompareJune 3, 2026 19:54
JamieMagee added a commit to JamieMagee/cli-1 that referenced this pull request Jun 3, 2026
Behavior-neutral additive tooling split out of npm#9424 so it can land on
v11 without the v12 default-deny flip:
- arborist: add collectUnreviewedScripts() + strictAllowScriptsError
(ESTRICTALLOWSCRIPTS) helpers in unreviewed-scripts.js
- arborist: isScriptAllowed() returns null for bundled deps; propagate
inBundle through isolated reifier / isolated-classes
- libnpmexec: opt-in strict-allow-scripts preflight (only under
--strict-allow-scripts); no default behavior change
- cli: rewrite check-allow-scripts as a wrapper over
collectUnreviewedScripts; exclude bundled deps from rebuild/runAll
- tests for all of the above
No default install-script behavior changes; the default-deny gate stays
in npm#9424 for v12.
owlstronaut pushed a commit that referenced this pull request Jun 3, 2026
Pulls the non-behavioral pieces out of #9424 so they can land on v11:
the `collectUnreviewedScripts`/`strictAllowScriptsError` helpers, the
`inBundle` fixes, and an opt-in libnpmexec preflight. Nothing changes by
default here, install scripts still run. The default-deny flip stays in
#9424 for v12.
## References
#9424
Phase 2 of the RFC npm#868 install-script policy: flip the default so
unreviewed lifecycle scripts are blocked unless covered by allowScripts.
Stacked on the behavior-neutral tooling PR; this commit carries ONLY the
v12-only default flip:
- arborist: gate preinstall/install/postinstall/prepare in rebuild on
the allowScripts policy (default-deny)
- user-facing "blocked because not covered by allowScripts" wording in
rebuild/reify-output/allow-scripts-cmd
- config definition docs + approve/deny command docs + snapshots
- flip tests
@JamieMagee
JamieMageeforce-pushed the jamiemagee/install-scripts-phase-2 branch from 379b44a to 7124edaCompareJune 3, 2026 21:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@JamieMagee@naugtur@owlstronaut@bakkot@manzoorwanijk