Skip to content
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

LoggingScopeHttpMessageHandler should not log unredacted Uri #74339

Closed
evgenyfedorov2 opened this issue Aug 22, 2022 · 5 comments
Closed

LoggingScopeHttpMessageHandler should not log unredacted Uri #74339

evgenyfedorov2 opened this issue Aug 22, 2022 · 5 comments

Comments

@evgenyfedorov2
Copy link

evgenyfedorov2 commented Aug 22, 2022

Description

LoggingScopeHttpMessageHandler logs HttpMethod and Uri here. While HttpMethod is safe to log, Uri is not, it often contains sensitive information which is a huge risk.

Reproduction Steps

Use HttpClient to send a request:

using var httpRequestMessage = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new("http://localhost/images/12345"),
};
_ = await _httpClient.SendAsync(httpRequestMessage, cancellationToken).ConfigureAwait(false);

Expected behavior

Either of those:

  • An option to redact the URI which is enabled by default, so that by default the output would be:
HttpMethod:POST
Uri:http://localhost/images/<this was redacted>
{OriginalFormat}:HTTP {HttpMethod} {Uri} 
  • Remove Uri from logging

Actual behavior

ILogger's scope contains this:

HttpMethod:POST
Uri:http://localhost/images/12345
{OriginalFormat}:HTTP {HttpMethod} {Uri} 

where 12345 is my privacy information

Regression?

No response

Known Workarounds

The only way is services.RemoveAll<IHttpMessageHandlerBuilderFilter>(); which is harsh. I need logging, but don't want to be exposed to a risk of leaking sensitive information

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 22, 2022
@ghost
Copy link

ghost commented Aug 22, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

LoggingScopeHttpMessageHandler logs HttpMethod and Uri here. While HttpMethod is safe to log, Uri is not, it often contains sensitive information which is a huge risk.

Reproduction Steps

Use HttpClient to Send a request:

using var httpRequestMessage = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new("http://localhost/images/12345"),
};
_ = await _httpClient.SendAsync(httpRequestMessage, cancellationToken).ConfigureAwait(false);

Expected behavior

Either of those:

  • An option to redact the URI which is enabled by default
HttpMethod:POST
Uri:http://localhost/images/<this was redacted>
{OriginalFormat}:HTTP {HttpMethod} {Uri} 
  • Remove Uri from logging

Actual behavior

ILogger's scope contains this:

HttpMethod:POST
Uri:http://localhost/images/12345
{OriginalFormat}:HTTP {HttpMethod} {Uri} 

where 12345 is my privacy information

Regression?

No response

Known Workarounds

The only way is services.RemoveAll<IHttpMessageHandlerBuilderFilter>(); which is harsh. I need logging, but don't want to be exposed to a risk of leaking sensitive information

Configuration

No response

Other information

No response

Author: evgenyfedorov2
Assignees: -
Labels:

area-System.Net.Http, untriaged

Milestone: -

@CarnaViire
Copy link
Member

Thank you @evgenyfedorov2
This is a dupe of #68675, so I'm going to close this one.
Please upvote #68675 if you need this feature, it would help us prioritize. Thanks!

@CarnaViire
Copy link
Member

Duplicate of #68675

@CarnaViire CarnaViire marked this as a duplicate of #68675 Aug 22, 2022
@CarnaViire CarnaViire closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 22, 2022
@xakep139
Copy link
Contributor

Hey @CarnaViire, isn't #68675 only about query parameters?

@CarnaViire
Copy link
Member

@xakep139 oh right, thanks for pointing that out. But let's gather all additional requirements in one place.

@karelz karelz added this to the 8.0.0 milestone Aug 23, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants