Skip to content

fix(apple): redact tokens from exchange-response debug log#284

Merged
umputun merged 1 commit into
masterfrom
fix/apple-log-redact-token-response
May 8, 2026
Merged

fix(apple): redact tokens from exchange-response debug log#284
umputun merged 1 commit into
masterfrom
fix/apple-log-redact-token-response

Conversation

@paskal
Copy link
Copy Markdown
Collaborator

@paskal paskal commented May 8, 2026

Summary

The Apple handler logged the full appleVerificationResponse struct on a [DEBUG] line:

[DEBUG] response data {AccessToken:M... TokenType:bearer ExpiresIn:3600
    RefreshToken:Iw... IDToken:eyJ...}

AccessToken, RefreshToken and IDToken are bearer credentials. With DEBUG-level logging enabled (default in many staging setups) these landed in stdout, file logs, centralized logging, crash bundles, and any third-party observability stack — anywhere log access doesn't imply auth-server-process compromise.

Change

Replace the raw %+v dump with appleVerificationResponseLogSummary, which logs only the non-secret fields plus presence indicators (present|missing) for each token. Operators can still tell whether a response carried each token; the value never leaks.

[DEBUG] apple exchange response: type=bearer expires_in=3600
    access_token=present refresh_token=present id_token=present error=""

Same redaction in v1 (provider/apple.go:334) and v2 (v2/provider/apple.go:334), single PR.

Test

TestAppleVerificationResponseLogSummary asserts the helper omits the three secret values verbatim and reports presence/missing correctly. Added in both modules. Full go test -race ./... green; golangci-lint run --new-from-rev=master 0 issues.

The handler logged the full appleVerificationResponse struct on a
DEBUG line:

    [DEBUG] response data {AccessToken:M... TokenType:bearer ...
        RefreshToken:Iw... IDToken:eyJ...}

AccessToken, RefreshToken and IDToken are bearer credentials. With
DEBUG-level logging enabled (default in many staging setups) these
ended up in stdout, file logs, centralised logging, crash bundles
and third-party observability — anywhere log access doesn't imply
auth-server-process compromise.

Replace the raw %+v dump with appleVerificationResponseLogSummary,
which logs only the non-secret fields plus presence indicators
(present|missing) for each token. Operators can still tell whether
a response carried each token; the value never leaks.

Same redaction in v1 (provider/apple.go:334) and v2
(v2/provider/apple.go:334), single PR.

Tests: TestAppleVerificationResponseLogSummary asserts the helper
omits the three secret values verbatim and reports presence/missing
correctly. Added in both modules.
@paskal paskal requested a review from umputun as a code owner May 8, 2026 18:29
@coveralls
Copy link
Copy Markdown

coveralls commented May 8, 2026

Coverage Report for CI Build 25572510465

Coverage increased (+0.5%) to 84.706%

Details

  • Coverage increased (+0.5%) from the base build.
  • Patch coverage: 11 of 11 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3315
Covered Lines: 2808
Line Coverage: 84.71%
Coverage Strength: 7.76 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Member

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thx

@umputun umputun merged commit be7ba6e into master May 8, 2026
9 checks passed
@umputun umputun deleted the fix/apple-log-redact-token-response branch May 8, 2026 22:42
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.

3 participants