nanocoder
nanocoder copied to clipboard
[Bug] redactSecrets does not mask common credential shapes (Bearer tokens, URL passwords, npm, Hugging Face, AWS, Azure, Twilio, SendGrid)
Description
redactSecrets is the safety net for text the CI investigator and PR reviewer post publicly. It only knows a short list of token shapes, so many common credentials pass through unchanged, including a plain Authorization: Bearer ... header. Environment variables are only masked when their name contains TOKEN, KEY, SECRET or PASSWORD, so DB_PASS is missed.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at eb7dee57)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Call
redactSecrets(text, {})(empty env) with each text below. - Check whether the secret part is still in the result.
Expected Behavior
Every secret below is replaced with [REDACTED].
Actual Behavior
All ten pass through unchanged.
Logs/Screenshots
Authorization: Bearer abcdef0123456789abcdef0123456789
token npm_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8
token hf_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
DATABASE_URL=postgres://admin:[email protected]:5432/app
git clone https://deploy:[email protected]/org/repo.git
key SK0123456789abcdef0123456789abcdef
SG.abcdefghijklmnopqrstuv.abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG
env DB_PASS=hunter2hunter2, then the text "connecting with hunter2hunter2"
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/verify/redact-secrets.ts:14(SECRET_PATTERNS): add patterns forBearer <token>,npm_,hf_, AWS secret access keys afteraws_secret_access_key, AzureAccountKey=, TwilioSK+ 32 hex, SendGridSG.x.y, and the password part ofscheme://user:password@host.source/verify/redact-secrets.ts:37(SECRET_ENV_NAME): also matchPASS,PWD,CREDENTIAL,AUTHin env names.- Add one test per shape above.
Related: PR #2074, PR #1906 (earlier additions to the same list).