NodeGoat icon indicating copy to clipboard operation
NodeGoat copied to clipboard

fix(security): redact secrets from config startup log (CWE-532)

Open aayushbaluni opened this issue 7 months ago • 0 comments

Summary

config/config.js logs the full configuration object to stdout on every startup, exposing cookieSecret, cryptoKey, and the MongoDB connection URI (which may contain credentials) to anyone with access to application logs.

This is CWE-532 (Insertion of Sensitive Information into Log File).

Root Cause

Lines 12-13 of config/config.js unconditionally call console.log(util.inspect(config)), dumping the entire config including secrets.

Fix

  • Gate config logging behind NODE_ENV === 'development' AND DEBUG_CONFIG environment variable
  • When logging is enabled, redact cookieSecret, cryptoKey, and credentials in the db connection string

Fixes #390

Made with Cursor

aayushbaluni avatar Apr 15 '26 10:04 aayushbaluni