Skip to content

fix(auth): redact sensitive auth logging#293

Merged
umputun merged 4 commits into
masterfrom
fix/auth-sensitive-logging
May 25, 2026
Merged

fix(auth): redact sensitive auth logging#293
umputun merged 4 commits into
masterfrom
fix/auth-sensitive-logging

Conversation

@umputun

@umputun umputun commented May 25, 2026

Copy link
Copy Markdown
Member

Title: fix(auth): redact sensitive auth logging

Fixes two auth logging leaks found during security review.

Changes

  • redact passwd from direct-login request URLs before rest.SendErrorJSON logs them, while keeping GET compatibility
  • remove raw OAuth/Apple profile and mapped user debug logs from v1 and v2 providers
  • add regression tests for v1/v2 direct login, OAuth1, and OAuth2 logging
  • add project AGENTS.md guidance for CI lint reproduction and v1/v2 workflow

Verification

  • go test -p 1 ./...
  • cd v2 && go test -p 1 ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2 run --max-issues-per-linter=0 --max-same-issues=0
  • cd v2 && go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2 run --config ../.golangci.yml --max-issues-per-linter=0 --max-same-issues=0

Copilot AI review requested due to automatic review settings May 25, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses sensitive-data leakage risks in auth-related logging by removing profile debug logs from OAuth/Apple flows and redacting direct-login passwords from request URLs passed into rest.SendErrorJSON (while preserving GET compatibility). It also adds regression tests for both the v1 (root) and v2 modules and documents CI/dev workflows in a new AGENTS.md.

Changes:

  • Redact passwd in direct-login request URLs used for error logging (v1 and v2).
  • Remove debug logs that print raw OAuth/Apple user profile data (v1 and v2).
  • Add regression tests ensuring user profiles and passwords are not logged; add AGENTS.md contributor guidance.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
provider/direct.go Uses a scrubbed request copy for rest.SendErrorJSON to avoid logging passwd from query strings.
v2/provider/direct.go Same redaction behavior as v1 for the v2 module.
provider/direct_test.go Adds a regression test verifying query password redaction and no mutation of the original request.
v2/provider/direct_test.go Same regression coverage for v2.
provider/oauth1.go Removes debug logging of raw/mapped user info to prevent sensitive profile leakage.
v2/provider/oauth1.go Same logging removal for v2.
provider/oauth2.go Removes debug logging of raw/mapped user info to prevent sensitive profile leakage.
v2/provider/oauth2.go Same logging removal for v2.
provider/apple.go Removes user-info debug log and redacts parse error log to avoid logging user contents.
v2/provider/apple.go Same logging adjustment for v2.
provider/oauth1_test.go Adds regression test to ensure OAuth1 login doesn’t log sensitive profile fields.
v2/provider/oauth1_test.go Same regression coverage for v2.
provider/oauth2_test.go Adds regression test to ensure OAuth2 login doesn’t log sensitive profile fields.
v2/provider/oauth2_test.go Same regression coverage for v2.
AGENTS.md Adds project guidance for running v1/v2 tests and lint consistent with CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread provider/oauth2_test.go Outdated
Comment on lines +322 to +340
logBuf := strings.Builder{}
captureLog := func(p *Params) {
p.L = logger.Func(func(format string, args ...any) {
fmt.Fprintf(&logBuf, format, args...)
})
}
teardown := prepOauth2Test(t, 8991, 8992, nil, captureLog)
defer teardown()

jar, err := cookiejar.New(nil)
require.NoError(t, err)
client := &http.Client{Jar: jar, Timeout: 5 * time.Second}

resp, err := client.Get("http://localhost:8991/login?site=remark")
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)

logged := logBuf.String()
Comment thread v2/provider/oauth2_test.go Outdated
Comment on lines +331 to +349
logBuf := strings.Builder{}
captureLog := func(p *Params) {
p.L = logger.Func(func(format string, args ...any) {
fmt.Fprintf(&logBuf, format, args...)
})
}
teardown := prepOauth2Test(t, 8991, 8992, nil, captureLog)
defer teardown()

jar, err := cookiejar.New(nil)
require.NoError(t, err)
client := &http.Client{Jar: jar, Timeout: 5 * time.Second}

resp, err := client.Get("http://localhost:8991/login?site=remark")
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)

logged := logBuf.String()
Comment thread provider/oauth1_test.go Outdated
Comment on lines +221 to +239
logBuf := strings.Builder{}
captureLog := func(p *Params) {
p.L = logger.Func(func(format string, args ...any) {
fmt.Fprintf(&logBuf, format, args...)
})
}
teardown := prepOauth1Test(t, 8993, 8994, captureLog)
defer teardown()

jar, err := cookiejar.New(nil)
require.NoError(t, err)
client := &http.Client{Jar: jar, Timeout: timeout * time.Second}

resp, err := client.Get("http://localhost:8993/login?site=remark")
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)

logged := logBuf.String()
Comment thread v2/provider/oauth1_test.go Outdated
Comment on lines +217 to +235
logBuf := strings.Builder{}
captureLog := func(p *Params) {
p.L = logger.Func(func(format string, args ...any) {
fmt.Fprintf(&logBuf, format, args...)
})
}
teardown := prepOauth1Test(t, 8993, 8994, captureLog)
defer teardown()

jar, err := cookiejar.New(nil)
require.NoError(t, err)
client := &http.Client{Jar: jar, Timeout: timeout * time.Second}

resp, err := client.Get("http://localhost:8993/login?site=remark")
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)

logged := logBuf.String()
@coveralls

coveralls commented May 25, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 26410456224

Coverage increased (+0.05%) to 85.475%

Details

  • Coverage increased (+0.05%) from the base build.
  • Patch coverage: 5 uncovered changes across 1 file (36 of 41 lines covered, 87.8%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
v2/provider/direct.go 20 15 75.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3587
Covered Lines: 3066
Line Coverage: 85.48%
Coverage Strength: 8.49 hits per line

💛 - Coveralls

@umputun umputun merged commit 54502ee into master May 25, 2026
9 checks passed
@umputun umputun deleted the fix/auth-sensitive-logging branch May 25, 2026 16:43
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