-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: net/http: omit contents of Authorization / Cookies header in string output #26551
Comments
I guess that would fix one problem, but there's plenty of APIs out there that require costum headers such as
isn't exactly user-friendly logging but more "debug logging". Things like Especially because I don't think that Also, if we're talking about debugging then printing everything is better than hiding information as debug logging should contain enough information for devs to see what's going on and what fields have which values to see if maybe they were set wrongly. I guess this depends on what the intended use case of |
Security critical contexts often have all sorts of other restrictions, sure. I'm talking about providing a slightly more safe default. I've seen several projects which just log whole http.Response projects. Maybe adding |
Consider the following code:
This type of code is fairly common, but can lead to exposing the
Authorization
header (orCookie
). Instead we should opt to not expose these sensitive headers by default. There's similar precedent for masking userinfo passwords from urls in #24572.We need to keep
req.Header.Get("Authorization")
unchanged as servers read the auth blob that way. Instead I propose we add:As part of the implementation we might need to specify a format for headers. Looking through various Printf encodings gives us:
%s
map[Authorization:[secret]]
%#v
Header:http.Header{"Authorization":[]string{"secret"}}
%+v
Header:map[Authorization:[secret]]
With a fixed encoding we are able to write the formatter and always mask these sensitive headers.
The text was updated successfully, but these errors were encountered: