aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

W3C cookies only logged when other "RequestHeader" fields are logged.

Open MarkPflug opened this issue 3 years ago • 7 comments

https://github.com/dotnet/aspnetcore/blob/bc9255b509c4b51d9bbbea7b15ddafe482784699/src/Middleware/HttpLogging/src/W3CLoggingMiddleware.cs#L179

I noticed this issue when looking at the W3C logging middleware, that the Cookie field is logged inside of a conditional block that checks for the presence of "RequestHeaders" flags, which doesn't include the cookie flag. This means that cookie values can't be logged without also logging other request headers. Either the cookie field should be moved out of this block, or the RequestHeaders flags should include the Cookie flag.

MarkPflug avatar Nov 21 '22 19:11 MarkPflug

Cookie was intentionally excluded from RequestHeaders due to its sensitive nature. Moving it out of that if block would be the correct fix.

Tratcher avatar Nov 22 '22 00:11 Tratcher

Are you interested in submitting a PR for this?

Tratcher avatar Nov 22 '22 00:11 Tratcher

Cookie was intentionally excluded from RequestHeaders due to its sensitive nature

Makes sense. ~~Just submitted #45224 with the fix.~~

I'll submit a PR, I guess doing this entire in github web UI was a bad idea.

MarkPflug avatar Nov 22 '22 00:11 MarkPflug

Nevermind. I guess I can't figure this out. I pulled the repo locally, but can't figure out how to build anything. dotnet build is complaining that I don't have .NET SDK 8.0-alpha and I don't know where/how to get it. I tried opening the csproj in VS and it... doesn't open, and presents to no error message.

MarkPflug avatar Nov 22 '22 01:11 MarkPflug

https://github.com/dotnet/aspnetcore/blob/main/docs/BuildFromSource.md

BrennanConroy avatar Nov 22 '22 01:11 BrennanConroy

TLDR; Run restore.cmd from the root, go to the project you want to builds folder and run startvs.cmd.

BrennanConroy avatar Nov 22 '22 01:11 BrennanConroy

I must be doing something wrong. I've tried following those instructions, but I'm getting a wall of MSBuild errors about missing imported projects: Microsoft.Cpp.Defaults.props? I probably don't have a prereq installed. I honestly don't have the patience to try to figure it out right now. I fixed the original failing PR as #45226, seems to be building properly now.

MarkPflug avatar Nov 22 '22 03:11 MarkPflug