Skip to content

fix(http): remove never-functional Authorization header capture from request logger - #4437

Open
stevenvegt wants to merge 3 commits into
masterfrom
fix/no-authorization-header-logging
Open

fix(http): remove never-functional Authorization header capture from request logger#4437
stevenvegt wants to merge 3 commits into
masterfrom
fix/no-authorization-header-logging

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

Removes the header capture (Authorization and DPoP) from the HTTP request logger middleware. The capture has never worked: no released version has ever written these headers to a log, so no operator action is required. It is removed rather than repaired because Authorization carries bearer tokens, which must not end up in logs.

Details: since its introduction in #3033 the gate read logger.Level on a *logrus.Entry, which is the per-message level that is only set on the entry copy used during an actual log call, never on the long-lived entry held by the middleware. The condition was therefore always 0 >= 5, i.e. false, and the headers field was never added to a log entry.

Rather than repairing the gate and filtering out Authorization, this removes the header capture entirely, so that a future innocent fix of the level check cannot silently start logging bearer tokens.

Testing: Test_requestLoggerMiddleware gains a pinning subtest it does not log headers, even on debug that sets Authorization and DPoP on the request, runs the middleware with the logger at debug verbosity, and asserts the resulting log entry has no headers field. It passes both before and after the removal, which is what confirms the capture never fired.

The request logger middleware listed the Authorization header in
LogHeaders, to be copied into request log entries at debug verbosity.
Bearer tokens must never reach logs, so the capture is removed
entirely instead of filtered.

The removal changes no observable behavior: the debug gate read
Entry.Level, which is only set on the entry copy used during an
actual log call, so the condition was always false and headers were
never logged by any released version. A pinning test now asserts
that no headers field is logged, even at debug verbosity.

Assisted-by: AI
@qltysh

qltysh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
http/cmd/cmd.go100.0%
Coverage rating: A Coverage rating: A
http/requestlogger.go100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

The http.log flag description stated that authorization headers are
logged at debug verbosity. The header capture is removed, and it
never fired in any released version to begin with.

Assisted-by: AI
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