feat(log): truncate access tokens in debug logs by default - #140
Open
synackd wants to merge 1 commit into
Open
Conversation
Previously, enabling debug logging exposed access tokens in full at
three points, leaking sensitive credentials into logs, terminal
scrollback, and any captured output shared for troubleshooting:
- internal/cli/cli.go: the --token flag value was logged verbatim
- internal/cli/cli.go: the token read from the cluster's
<CLUSTER>_ACCESS_TOKEN environment variable was logged verbatim
- pkg/client/client.go: the request "Authorization: Bearer <token>"
header was logged verbatim in the request-header debug loop
This change truncates any token that would appear in debug logs to its
first 6 characters followed by an ellipsis (e.g. "eyJhbG..."). The logs
still indicate that a token is present and hint at its identity, but no
longer disclose the full, usable credential. A new --show-token flag
restores the previous behavior of logging the full token for cases where
an operator explicitly needs to inspect it.
The token-hiding behavior is on by default. To see the full token in
logs, users must now pass --show-token.
Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
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.
Description
Previously, enabling debug logging exposed access tokens in full at three points, leaking sensitive credentials into logs, terminal scrollback, and any captured output shared for troubleshooting:
internal/cli/cli.go: the--tokenflag value was logged verbatiminternal/cli/cli.go: the token read from the cluster's<CLUSTER>_ACCESS_TOKENenvironment variable was logged verbatimpkg/client/client.go: the request "Authorization: Bearer " header was logged verbatim in the request-header debug loopThis change truncates any token that would appear in debug logs to its first 6 characters followed by an ellipsis (e.g. "eyJhbG..."). The logs still indicate that a token is present and hint at its identity, but no longer disclose the full, usable credential. A new
--show-tokenflag restores the previous behavior of logging the full token for cases where an operator explicitly needs to inspect it.The token-hiding behavior is on by default. To see the full token in logs, users must now pass
--show-token.Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryType of Change
For more info, see Contributing Guidelines.