microcks-cli icon indicating copy to clipboard operation
microcks-cli copied to clipboard

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

Open gyanranjanpanda opened this issue 6 months ago • 1 comments

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 values → Authorization: [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.

gyanranjanpanda avatar May 28 '26 04:05 gyanranjanpanda

Could @Harsh4902 @lbroudoux review this ''

gyanranjanpanda avatar Jun 09 '26 17:06 gyanranjanpanda