Skip to content

fix(recovery): mask Cookie and Proxy-Authorization in panic dumps - #4744

Open
sonnemusk wants to merge 1 commit into
gin-gonic:masterfrom
sonnemusk:fix/recovery-mask-sensitive-headers
Open

fix(recovery): mask Cookie and Proxy-Authorization in panic dumps#4744
sonnemusk wants to merge 1 commit into
gin-gonic:masterfrom
sonnemusk:fix/recovery-mask-sensitive-headers

Conversation

@sonnemusk

Copy link
Copy Markdown

Summary

secureRequestDump is used when Recovery middleware logs a panic. Previously only Authorization was redacted, so session cookies and proxy credentials could still appear in logs.

This change also masks:

  • Cookie
  • Proxy-Authorization

Header matching is done by field name (case-insensitive) so the dump stays stable across http.Header canonicalization.

Test plan

  • Extended TestSecureRequestDump for Cookie / Proxy-Authorization / multi-header cases
  • go test -count=1 -run TestSecureRequestDump .
  • go test -count=1 .

Panic recovery logs dump the request for debugging. Only Authorization
was redacted, so session cookies and proxy credentials could still leak
into logs. Mask Cookie and Proxy-Authorization the same way.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.39%. Comparing base (3dc1cd6) to head (420ba0f).
⚠️ Report is 289 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4744      +/-   ##
==========================================
- Coverage   99.21%   98.39%   -0.82%     
==========================================
  Files          42       48       +6     
  Lines        3182     3181       -1     
==========================================
- Hits         3157     3130      -27     
- Misses         17       41      +24     
- Partials        8       10       +2     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.38% <100.00%> (?)
-tags go_json 98.25% <100.00%> (?)
-tags nomsgpack 98.30% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.25 98.39% <100.00%> (?)
go-1.26 98.33% <100.00%> (?)
macos-latest 98.33% <100.00%> (-0.89%) ⬇️
ubuntu-latest 98.39% <100.00%> (-0.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant