Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy#61530
Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy#61530BrennanConroy merged 2 commits intodotnet:mainfrom
Conversation
|
@dotnet-policy-service agree |
|
/backport to release/9.0 |
|
Started backporting to release/9.0: https://github.com/dotnet/aspnetcore/actions/runs/14605839496 |
|
/backport to release/8.0 |
|
Started backporting to release/8.0: https://github.com/dotnet/aspnetcore/actions/runs/14605854172 |
|
/backport to release/2.3 |
|
Started backporting to release/2.3: https://github.com/dotnet/aspnetcore/actions/runs/14605871270 |
|
@BrennanConroy backporting to "release/2.3" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Header Spoofing Proof for XForwardedProto, XForwardedHost and XForwardedPrefix
Using index info to reconstruct a base tree...
M src/Middleware/HttpOverrides/test/ForwardedHeadersMiddlewareTest.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Middleware/HttpOverrides/test/ForwardedHeadersMiddlewareTest.cs
CONFLICT (content): Merge conflict in src/Middleware/HttpOverrides/test/ForwardedHeadersMiddlewareTest.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Header Spoofing Proof for XForwardedProto, XForwardedHost and XForwardedPrefix
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
|
Thanks for the find and fix @yannic-hamann-abb ! |
|
This is a breaking changes!!! After upgrading from AspnetCore 8.0.15 to 8.0.17 this completly broke my authentication as the THIS SHOULD NOT BE INCLUDED IN THE MINOR RELEASE. |
Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy
Fixes a bug where, under some conditions,
XForwardedPrefix,XForwardedProtoandXForwardedHostheaders could be tampered with.Description
This PR makes sure that XForwarded-Headers are only interpreted when they come from a known proxy. As suggested by the documentation..
If the
ForwardedHeaders.XForwardedForflag inForwardedHeadersOptionsisn't set. TheForwardedHeadersMiddlewaredoesn't check if the request comes from a known proxy.This means that with the following
ForwardedHeadersOptions(or any other combination whereForwardedHeaders.XForwardedForis missing):the respective
X-Forwarded-headers will be always processed by the middleware which have some (security related?) side effects:XForwardedPrefixsetscontext.Request.PathBaseXForwardedProtosetscontext.Request.SchemeXForwardedHostsetscontext.Request.HostWith
ForwardedHeadersOptionsset toForwardedHeaders.Allno side effects would have been executed.Fixes #61449
This observation has been reported by me via the
MSRC-Portal but was classified as a product bug. The following information may be related: aspnet/Announcements#295