Forwarded Headers Middleware: X-Forwarded-Prefix Applied when it comes from an Unknown Proxy #61449
Closed
1 task done
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Milestone
Is there an existing issue for this?
Describe the bug
I am not understanding the security concerns why X-Forwarded-Fields should be only allowed for known proxies - but that is what the documentation implies.
The current implementation of
ForwardedHeadersMiddleware
only breaks and logsUnknown proxy: {RemoteIpAndPort}
when the flagForwardedHeaders.XForwardedFor
is set.Documentation says:
With other words you can end up with a configuration like:
which modifies your
request.PathBase
even though it comes from an unknown proxy. Is this a bug or by design? If by design maybe documentation could be improved.XForwardedProto
andXForwardedHost
are potentially bypassed in the same way.Expected Behavior
Unknown due to my limited security understanding. Maybe
HttpContext.Request.PathBase
should be left untouched by the middleware when header comes from an unknown proxy.Steps To Reproduce
Exceptions (if any)
No response
.NET Version
9.0.104
Anything else?
I would like to contribute to fix this issue. I am planning to write some tests tomorrow for this and suggest a PR with some more detailed description of the issue.
The text was updated successfully, but these errors were encountered: