fix: mask sensitive values in env override logging#1441
Open
mvanhorn wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When environment variables are overridden via
--env, the override is logged at info level asoverride NAME=VALUEwith the value in cleartext. For secret-bearing variables (passwords, access keys, storage credentials, encryption keys) that writes the raw secret into the log, where it can persist in log files, aggregators, or CI output. This masks the value in that log line when the variable name looks sensitive, printing[MASKED]instead, while leaving non-sensitive overrides readable.Why this matters
Issue #1429 asks for the env-override logging to stop leaking secrets. The override log is otherwise useful for debugging which variables were applied, so the fix keeps the line but redacts only the value, and only when the variable name matches a sensitive token. The token list covers the documented credential and encryption-key variables across backends (passwords, secrets, access/secret keys,
AZBLOB_ACCOUNT_KEY/ SSE keys,S3_SSE_CUSTOMER_KEY,GCS_ENCRYPTION_KEY, tokens, SAS, connection strings), so common Azure/GCS/S3 SSE configurations no longer expose credentials in logs.Changes
pkg/config/config.gogains amaskSensitiveEnvValue(name, value)helper backed by asensitiveEnvNameTokenslist and uses it only at theoverride NAME=VALUEinfo-log call site. The override behavior itself is unchanged; only the logged representation of the value changes for sensitive names.Testing
Added tests in
pkg/config/config_test.goasserting that sensitive overrides (including the Azure/GCS/SSE key variables) log[MASKED]and never leak the raw value, that a non-sensitive variable still logs its value, and that the env override is applied regardless. The log-capture test pinsLOG_LEVEL=infoso it is independent of the surrounding process's log level.go test ./pkg/configpasses (including underLOG_LEVEL=error);go vetandgofmtare clean.Closes #1429