Skip to content

fix: remove OAuth token logging and redact sensitive data from CLI output#450

Open
gyanranjanpanda wants to merge 2 commits into
microcks:masterfrom
gyanranjanpanda:fix/redact-oauth-tokens-from-logs
Open

fix: remove OAuth token logging and redact sensitive data from CLI output#450
gyanranjanpanda wants to merge 2 commits into
microcks:masterfrom
gyanranjanpanda:fix/redact-oauth-tokens-from-logs

Conversation

@gyanranjanpanda
Copy link
Copy Markdown
Contributor

Summary

Fixes #449 — SSO login leaks OAuth access and refresh tokens to CLI logs.

Changes

cmd/login.go

Before After Why
log.Printf("Token: %s\n", tokenString) Removed Unconditionally leaked the full JWT access token to stderr
log.Printf("Refresh Token: %s\n", refreshToken) Removed Unconditionally leaked the long-lived refresh token to stderr
log.Printf("Callback: %s\n", r.URL) log.Printf("Callback received on: %s\n", r.URL.Path) Stripped query parameters containing the OAuth authorization code
fmt.Printf("Performing ... login: %s\n", url) Prints only the base URL (before ?) Stripped state nonce, code_challenge, and other sensitive params

pkg/config/config.go

Added redactSensitiveContent() helper that masks:

  • Authorization header valuesAuthorization: [REDACTED]
  • OAuth parameters (access_token, refresh_token, id_token, code) → param=[REDACTED]

Applied to both DumpRequestIfRequired() and DumpResponseIfRequired() so that --verbose HTTP dumps no longer leak bearer tokens.

Verification

  • go build ./...
  • go vet ./... ✅ (pre-existing warning in pkg/watcher/executor.go unrelated to this change)
  • grep confirms zero remaining token log statements in cmd/

Risk Assessment

Low risk — Only removes debug log statements and adds output redaction. No behavioral changes to authentication flow, token storage, or API calls.

Signed-off-by: gyanranjanpanda <sanupanda141@gmail.com>
…tput

Remove unconditional log.Printf calls that leaked access tokens and
refresh tokens to stderr after SSO login. Redact the callback URL
(which contained the OAuth authorization code) and the authorization
URL (which contained state nonce and code challenge).

Additionally, add redaction of Authorization headers and OAuth token
parameters in verbose HTTP dump output to prevent credential exposure
when --verbose flag is used.

Closes microcks#449

Signed-off-by: gyanranjanpanda <sanupanda141@gmail.com>
@gyanranjanpanda gyanranjanpanda force-pushed the fix/redact-oauth-tokens-from-logs branch from 8a2761a to 7645976 Compare May 28, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: SSO login leaks OAuth access and refresh tokens to CLI logs

1 participant