Closed as not planned
Description
Motivation ("The Why")
Today, the ecosystem has been incorrectly trained to believe that --ignore-scripts
ensures no "scripts" are executed & the nuance of the various situations where that is true has historically been hard to document & educate (ex. bug bounty submissions based on the GitHub program/scope encompassing "Arbitrary script execution upon package install with the --ignore-scripts flag"
https://bounty.github.com/targets/npm-cli.html). For v10 (ref. npm/statusboard#487 / npm/cli#6641), I'm recommending the team makes all commands respect this flag properly (no matter how silly the situation).
How
Current Behaviour
npm
makes nuanced decisions about which scripts to run even when--ignore-scripts
is defined (ex. git deps runprepare
,prepack
,npm test
will runscripts.test
etc.)
Desired Behaviour
- running
install
,publish
,pack
& more will ignore all defined scripts when--ignore-scripts
is set (ex. git repos would no longer be treated uniquely duringinstall
&prepare
/prepack
etc. wouldn't be executed) - running
npm test --ignore-scripts
ornpm run foo --ignore-scripts
executes nothing (seems weird, but the result would be consistent)
References
- [BUG] NPM allows insecure code execution by configuration file cli#4101
- [BUG] --ignore-scripts is ignored, npm install runs build. cli#4202
- https://www.nerdycode.com/prevent-npm-executing-scripts-security/
- https://community.sonarsource.com/t/omitting-ignore-scripts-can-lead-to-execution-of-shell-scripts/90183
- https://medium.com/cider-sec/npm-might-be-executing-malicious-code-in-your-ci-without-your-knowledge-e5e45bab2fed
- https://stackoverflow.com/questions/59471962/how-does-npm-behave-differently-with-ignore-scripts-set-to-true
Bikeshedding
- you may want to look at grouping scripts & providing net-new flags to provide nuanced behavior some have asked for (ex.
--ignore-pre-scripts
/--ignore-post-scripts
/--ignore-lifecycle-scripts
or something similar) but--ignore-scripts
should be the most broad in its enforcement & is the most requested
Metadata
Metadata
Assignees
Labels
No labels