Leaked Env in Logs
process.env.* leaked inside console.log() calls
warningSecurity
leaked-env-in-logsWhy this matters
Logging env vars sends secrets to your log aggregator, CI output, and browser console. Anyone with log access sees your API keys and database URLs.
Example
lib/config.tsconsole.log("Config:", {
dbUrl: process.env.DATABASE_URL,
apiKey: process.env.STRIPE_SECRET_KEY,
});lib/config.tsconst hasDbUrl = Boolean(process.env.DATABASE_URL);
const hasStripeKey = Boolean(process.env.STRIPE_SECRET_KEY);
console.log("Config:", { hasDbUrl, hasStripeKey });How to fix
Keep process.env out of console calls altogether. Work out what you need to know first (is it set?), then log that.
Reference
- In the output
- Findings carry
"ruleId": "leaked-env-in-logs"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line leaked-env-in-logs- Silence a whole file
// prodlint-disable leaked-env-in-logsat the top of the file- How it works
- Reads the syntax tree, with a text fallback for files that don't parse. Source on GitHub