-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy #61530
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
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 128 Please backport manually! |
Thanks for the find and fix @yannic-hamann-abb ! |
Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy
Fixes a bug where, under some conditions,
XForwardedPrefix
,XForwardedProto
andXForwardedHost
headers 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.XForwardedFor
flag inForwardedHeadersOptions
isn't set. TheForwardedHeadersMiddleware
doesn't check if the request comes from a known proxy.This means that with the following
ForwardedHeadersOptions
(or any other combination whereForwardedHeaders.XForwardedFor
is missing):the respective
X-Forwarded
-headers will be always processed by the middleware which have some (security related?) side effects:XForwardedPrefix
setscontext.Request.PathBase
XForwardedProto
setscontext.Request.Scheme
XForwardedHost
setscontext.Request.Host
With
ForwardedHeadersOptions
set toForwardedHeaders.All
no 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