Repository navigation
Description
Motivation ("The Why")
Recent supply chain attacks have spurred many important improvements to the npm CLI, including configuration options that help prevent being the victim of one. However, the npm configuration is not always "user-controlled", which can lead to unexpected (and potentially compromising) outcomes. In particular, a user may have a secure user-level configuration (~/.npmrc) but run a command in a compromised/malicious project and end up in a bad situation. Alternatively, a user may have a secure user-level configuration but have some third-party script unexpectedly run npm install --ignore-scripts=false <malicious-package>1.
For this reason I would propose the npm CLI attempts to prevent such a security-conscious user from being the victim of a supply chain attack by alerting them when this situation arises, or at the very least leave a trace when it happens.
Example
You have a user level configuration
$ cat ~/.npmrc
ignore-scripts=true
min-release-age=7And you have just cloned an (untrusted) repository with a local configuration file
$ cat random-github-project/.npmrc
ignore-scripts=false
min-release-age=0If you install dependencies, it won't inform you about the configuration conflicts
$ npm --version
11.12.1
$ npm install # or npm clean-install
added X packages, and audited Y packages in 420ms
found Z vulnerabilitiesHow
Current Behaviour
The option value in the "closest" configuration wins and is used.
Desired Behaviour
If there is a conflict for an option between configurations (files or CLI) the npm CLI should either
- Prompt the user for confirmation that the configurations are conflicting, and which option value will be used, or
- Output a warning that there was a conflict, or
- Error and not do anything
Where an example of a configuration mismatch is if one explicitly specifies ignore-scripts=false and another one explicitly specifies ignore-scripts=true.
I would personally advocate for using (1) when a TTY is detected and falling back to (2) otherwise, e.g. in CI.
The behavior itself may be configurable, but in that case should only be respected when provided at the user level (~/.npmrc) or CLI.
In some ideal world it should not be considered a problem when, say, the project-level configuration is more strict than the user-level configuration2. However, I imagine it can be difficult and contentious to determine when a configuration is "more strict".
References
Footnotes
-
as described in https://lists.archlinux.org/archives/list/[email protected]/thread/L2JXQNYBGWOQQQXDEPEAICBHKFEFANUC/ ↩
-
For example,
ignore-scripts=falsein~/.npmrcandignore-scripts=trueinproject/.npmrc. ↩
Activity
algomaster99 commentedon Jun 16, 2026
I'm in favor of this proposal, especially prompting or throwing an error. What are the other software supply chain-relevant options that could be overridden for malicious purposes?
ericcornelissen commentedon Jun 16, 2026
Some options that come to mind:
allow-gitallow-remoteignore-scriptsmin-release-ageregistry=*:registry=Since this comment might get outdated, here are some sources that might keep an up-to-date list of supply chain security related options:
msapelov commentedon Aug 31, 2026
There's a real-world delegated-tooling example that seems directly relevant to this proposal.
I configured a release-age policy, but simply running the Pi coding agent's self-update can disable it for that invocation. Pi explicitly constructs
npm install -g --ignore-scripts --min-release-age=0 ....The user only runs
pi update, and the tool changes the package-manager security setting underneath.The relevant source is:
https://github.com/earendil-works/pi/blob/853a80d26c90a14c1886f0ebb8ffaae133ca2185/packages/coding-agent/src/config.ts#L168
This makes me wonder if, in addition to warning about configuration conflicts, there should be an opt-in concept of protected user settings.
For example, conceptually, a user could have
min-release-age=7and markmin-release-ageas protected.Then a delegated invocation attempting
npm install --min-release-age=0 ...could fail (or ignore the override with a warning) rather than silently bypassing the configured policy.I think the distinction is useful because CLI overrides are perfectly reasonable when the user intentionally supplies them. The problematic case is when another tool invokes npm on the user's behalf and the user does not realize that the tool is also changing their security policy.