fix: redact Authorization header in debug request dump#947
Open
aviadshiber wants to merge 1 commit intoankitpokhrel:mainfrom
Open
fix: redact Authorization header in debug request dump#947aviadshiber wants to merge 1 commit intoankitpokhrel:mainfrom
aviadshiber wants to merge 1 commit intoankitpokhrel:mainfrom
Conversation
f690fd7 to
3179156
Compare
When --debug mode is enabled, httputil.DumpRequest outputs the full HTTP request including the Authorization header, which contains the API token (Bearer) or base64-encoded credentials (Basic auth). This could lead to credential exposure in CI/CD logs, shared terminal sessions, or bug reports. Clone the request headers before dumping, redact sensitive header values in the clone, then restore the original headers. This ensures the debug output never contains credentials while leaving the actual request object untouched for callers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3179156 to
957c36a
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.
Summary
--debugmode is enabled,httputil.DumpRequestoutputs the full HTTP request including theAuthorizationheader containing Bearer tokens or base64-encoded Basic auth credentialsAuthorizationheader value before dumping (preserving only the scheme likeBearerorBasic), then restores the original header so the request is not modified for callersSecurity Impact
Vulnerability: Credential exposure via debug output
Severity: Medium
Affected code:
pkg/jira/client.go—dump()functionBefore this fix, enabling
--debugwould print:After this fix:
Test plan
TestDumpRedactsAuthorizationHeader— verifies Bearer token is redacted and original header is restoredTestDumpRedactsBasicAuthHeader— verifies Basic auth credentials are redacted and original header is restoredgo test ./pkg/jira/...)🤖 Generated with Kapsis