admin: Redact sensitive request headers in API logs#7578
Open
steadytao wants to merge 1 commit intocaddyserver:masterfrom
Open
admin: Redact sensitive request headers in API logs#7578steadytao wants to merge 1 commit intocaddyserver:masterfrom
steadytao wants to merge 1 commit intocaddyserver:masterfrom
Conversation
Member
|
We could possibly move But I'm okay with this too. |
da6fd61 to
0aff561
Compare
Contributor
Author
@francislavoie Much better. Much appreciated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the admin API request logging path so sensitive request headers are redacted instead of being logged verbatim.
Before this change,
adminHandler.ServeHTTPlogged headers withzap.Reflect("headers", r.Header), which bypassed the normal header redaction behavior used elsewhere in the codebase. This could expose values from headers such asAuthorization,Proxy-Authorization,Cookie, andSet-Cookiein admin API logs.This change replaces that raw header logging with a structured marshaler that redacts those sensitive headers while leaving ordinary headers visible.
Why
adminLoggableHTTPHeaderinstead of reusingloggableHTTPHeader?modules/caddyhttp, butadmin.gois in the rootcaddypackage. Importingmodules/caddyhttpfromadmin.gocreates an import cycle (caddy -> modules/caddyhttp -> caddy) so the admin handler cannot directly reuse that type. For this fix, the smallest clean option is to keep an admin-specific private marshaler inadmin.gowith the same redaction behavior.This change:
Authorization,Proxy-Authorization,Cookie, andSet-Cookiein admin API request logsShould fix #7566.
Assistance Disclosure
No AI was used.