[BUG] npm config list leaks credentials in proxy-related environment variables
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
Since #8828 was merged to fix #4170 (released in CLI v11.8.0), the "environment-related config" section of npm config list shows the values of the HTTP_PROXY, HTTPS_PROXY and NO_PROXY env vars. However, unlike the native proxy and https-proxy options, it doesn't obscure the credentials in the proxy URL.
Expected Behavior
Any obvious credentials in the npm config list output should be replaced by *** (or e.g. (protected), as is done with auth-related configuration like //<some-registry>:_auth).
Steps To Reproduce
Given:
# .npmrc
proxy=${HTTP_PROXY}
then you see e.g.:
$ HTTP_PROXY=http://user:pass@example.com:80 npm config list
# ... user config
; "project" config from path/to/.npmrc
proxy = "http://user:***@example.com:80"
; environment-related config
; HTTP_PROXY = "http://user:pass@example.com:80"
# ... etc.
The password in the proxy config option is correctly redacted, but the HTTP_PROXY env var is emitted as-is.
Environment
Tested on two entirely different systems, both with npm >11.8:
- npm: v12.0.1 / v11.13.0
- Node.js: v26.5.0 / v24.16.0
- OS Name: macOS Tahoe 26.5.2 / Windows 11
- System Model Name: MacBook Pro / Lenovo ThinkPad
- npm config: already given in example
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with npm config list and the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables described here. Trace the environment-related config output and compare it with the existing redaction of the native proxy and https-proxy options. Done means obvious credentials are replaced with *** or an equivalent protected marker in the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100