fix(security): fingerprint Basic-Auth principal in request log (CodeQL go/clear-text-logging)#473
Merged
Merged
Conversation
Contributor
PR Quality ReportCompared against base branch Coverage and tests
Compatibility
Performance smokeLower CPU cost (
State
|
szibis
force-pushed
the
fix/redact-auth-principal-log
branch
from
July 22, 2026 08:23
3db61a9 to
db74d4f
Compare
The auth.principal field in the structured request log emitted the Basic-Auth username verbatim — credential material read from the Authorization header, flagged by CodeQL go/clear-text-logging in internal/proxy/query_translation.go. Route it through the existing redactQuery fingerprint (sha256:<8hex> len=<n>) by default; emit raw only under -debug-log-raw-queries, mirroring how raw queries are handled. Trusted-proxy enduser.* audit identity fields are unchanged. Adds a regression test asserting the username is fingerprinted by default, verbatim under the debug flag, and the password never appears.
szibis
force-pushed
the
fix/redact-auth-principal-log
branch
from
July 22, 2026 13:19
db74d4f to
d0802f6
Compare
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.
What
Routes the Basic-Auth username (
auth.principalin the structured request log) through the existingredactQueryfingerprint (sha256:<8hex> len=<n>) instead of logging it verbatim. Verbatim output remains available under-debug-log-raw-queries=true.Why
CodeQL HIGH
go/clear-text-loggingatinternal/proxy/query_translation.go:231: the Basic-Auth username — credential material read from theAuthorizationheader viar.BasicAuth()— flowed verbatim into the audit log. The password was never logged.The fix mirrors the repo's established redaction idiom (
redactQuery, gated by-debug-log-raw-queries). Trusted-proxyenduser.*audit-identity fields (fromX-Grafana-Useretc.) are intentionally unchanged — those are already-authenticated identities used for audit, not credential material.Verification
TestRequestLogger_RedactsBasicAuthPrincipal: asserts the username is fingerprinted by default, emitted verbatim under the debug flag, and the password never appears in the log. ✅internal/proxypackage: 2323 passed ✅Part of a stacked series addressing the failing Security workflow and open code-scanning/Dependabot alerts.