Documentation for ForwardLimit says: "Set to null to disable the limit, but this should only be done if KnownProxies or KnownNetworks are configured." Could you, please, add some comments to the documentation what the consequences of ignoring the recommendation are? I guess this can compromise security, but how exactly?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello @voroninp ...
The remark comes from the API comment at ...
From the following remarks on a related issues, it's a simple precaution for both misconfigured proxies and security of the proxy chain ...
proxy is misconfigured ... or the request is coming from a potentially malicious side-channel
From: https://github.com/aspnet/AspNetCore/issues/10302
There's no way we can actually figure out your proxy setup, and an attacker can, of course, add their own X-Forwarded-For header, with misconfigured proxies not stripping it at all. Thus, if you know you have chained proxies then you need to tell the middleware about them. Set the ForwardLimit on the ForwardedHeaderOptions.
From: https://github.com/aspnet/AspNetCore/issues/8471#issuecomment-472421839
There are a few things here to address ...
How the ForwardLimit affects _which address will be taken as the client IP_ is buried. That content should also appear in the ForwardLimit option description.
The default
ForwardLimitis 1 (one), so only the rightmost value from the headers is processed unless the value ofForwardLimitis increased.
I'll get a PR in within a couple of weeks to address these problems. Thanks for opening this issue.
Most helpful comment
Hello @voroninp ...
The remark comes from the API comment at ...
https://github.com/aspnet/AspNetCore/blob/master/src/Middleware/HttpOverrides/src/ForwardedHeadersOptions.cs#L55-L56
From the following remarks on a related issues, it's a simple precaution for both misconfigured proxies and security of the proxy chain ...
From: https://github.com/aspnet/AspNetCore/issues/10302
From: https://github.com/aspnet/AspNetCore/issues/8471#issuecomment-472421839
There are a few things here to address ...
How the
ForwardLimitaffects _which address will be taken as the client IP_ is buried. That content should also appear in theForwardLimitoption description.From: Troubleshoot section of the topic
I'll get a PR in within a couple of weeks to address these problems. Thanks for opening this issue.