[Bug] config show prints secrets that are inside URLs, args, env values and headers
Description
nanocoder config show hides provider apiKey values but prints other secrets in clear text: credentials in URLs and query strings, --api-key style arguments, env values such as DATABASE_URL, and headers with non-obvious names. This can leak secrets into terminals, screenshots and CI logs.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at f92cce9c)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
-
In an empty folder create
.mcp.json:{"mcpServers":{"gh":{"command":"npx","args":["-y","some-mcp","--api-key","$MY_SECRET"],"env":{"DATABASE_URL":"postgres://u:$MY_SECRET@h/db"}},"remote":{"transport":"http","url":"https://mcp.example.com/mcp?api_key=${MY_SECRET}","headers":{"Ocp-Apim-Subscription-Key":"$MY_SECRET"}}}} -
Run
MY_SECRET=SUPERSECRET123 NANOCODER_CONFIG_DIR=<empty dir> node dist/cli.js config show mcpServers --json -
Optionally set a provider
baseUrltohttps://x.example.com/v1?key=$MY_SECRETand runconfig show providers.
Expected Behavior
No real secret value appears in the output.
Actual Behavior
SUPERSECRET123 appears in args, env, url and header values, and redacted is false for both entries.
Logs/Screenshots
"args": ["-y", "some-mcp", "--api-key", "SUPERSECRET123"]
"env": {"DATABASE_URL": "postgres://u:SUPERSECRET123@h/db"}
"url": "https://mcp.example.com/mcp?api_key=SUPERSECRET123"
"headers": {"Ocp-Apim-Subscription-Key": "SUPERSECRET123"}
"redacted": false
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/config/effective-config.ts:129(SECRET_KEY_PATTERN) and:169(redactValue): also redact the user:password part and sensitive query parameters of URLs, the value after an argument like--api-keyor--token, every env and header value written as a$VARreference, and header names containing "key", "token", "secret" or "subscription".- Check the call sites at
:676and:834, andsource/config/config-cli.ts:53(formatValue). - Add a test for each case above.
Related: #1661 (same problem in /doctor).
I will pick this up. I will extend effective-config redaction to URL credentials and sensitive query parameters, secret CLI flag values, and MCP env/header secrets, including resolved environment references. I will test both structured and rendered output using synthetic secrets.