-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[release/9.0] Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy #61622
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
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
This seems like a significant behavior change, especially for a patch release, and I was very surprised to see that this was not at least called out in the 9.0.6 release notes. We had to revert an upgrade from 9.0.5 today after this broke a production environment which has Kestrel fronted by AWS ALB. |
This also impacted my production environment! In my case its an Azure WebApp, using EasyAuth, hosting a custom image. I use the Short of going back to 9.0.5, what changes do I need to make to restore previous functionality? |
What are your setups? This should only affect you if you didn't use |
There's loopback set as default for /// <summary>
/// Addresses of known proxies to accept forwarded headers from.
/// </summary>
public IList<IPAddress> KnownProxies { get; } = new List<IPAddress>() { IPAddress.IPv6Loopback };
/// <summary>
/// Address ranges of known proxies to accept forwarded headers from.
/// </summary>
public IList<IPNetwork> KnownNetworks { get; } = new List<IPNetwork>() { new IPNetwork(IPAddress.Loopback, 8) }; So this unfortunately is a breaking change for us, as we do not use app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedProto
}); |
@doeringp in your setup, what is the actual IP of the proxy forwarding the request? |
@yannic-hamann-abb I'm not sure yet, but I know it's not localhost since the application is running in Kubernetes behind an Nginx Ingress Controller. |
In your setup you have to explicitly add the proxy IP or proxy network to the var options = new ForwardedHeadersOptions { ForwardedHeaders.XForwardedProto };
options.KnownNetworks.Add(...); |
For us it was enough to override the defaults of app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedProto,
KnownNetworks = {},
KnownProxies = {},
}); With this Still a breaking change. Thankfully we discovered it in a testing environment. |
@mayerraphael with that config you are bypassing the known proxy checks entirely. |
@yannic-hamann-abb I agree that this change makes sense from a security standpoint. However, it's also a breaking change in behavior that could impact customers like us who haven't used the X-Forwarded-For header and haven't configured |
I have an OData API that uses server paging and a SPA client which depends upon the I saw this change and assumed the nightly build of the container, which uses v9 of the SDK, had used v9.0.301 and that had changed the response. (I hadn’t changed the versions of the packages consumed by my API - all I checked my configuration and I already was using I use EasyAuth and though maybe it was that proxy that was affecting the response, so I turned that off (in a test environment) and that still didn’t fix it. I think there is still another proxy in front of my Azure Web App and its that which has a dependency upon this library, because with...
It still doesn’t work. But if I add |
@BrennanConroy Our setup is |
If you had set the option in 9.0.5 to This change ensures consistent handling of forwarded headers how it is described in the docs. |
Yes @yannic-hamann-abb, I don't think anyone is arguing that your original PR was a bad idea - what's unfortunate is that this backport PR was a breaking change made in a patch release with no warnings in the release notes. |
Apologies everyone for the unannounced breaking change. Thank you everyone for figuring out the issue and providing updates that people can apply to fix the problem. As noted above, this change was made to improve the security stance of the We've updated the release notes with this now: dotnet/core#9930 |
@BrennanConroy do you have a contact in Azure that can explain what broke? Because I am not using any Microsoft.* 9.0.6 libraries, I have removed I can only assume that they rolled back this change or changed configuration in their reverse proxy. |
Shouldn't the default for known networks contain private subnets on top of loopback, i.e.:
The current default is very strict and basically means that if you don't override it it the middleware wont do anything. |
Why is this 9.0.6 issue occurring only in Production on AWS Fargate, but not in my Test or Development environments? |
Does your Test and Development enviroment use the same kind of HTTP proxy configuration as your Production environment? |
Backport of #61530 to release/9.0
/cc @BrennanConroy @yannic-hamann-abb
Forwarded Headers Middleware: Ignore XForwardedHeaders from Unknown Proxy
Description
If the
ForwardedHeadersMiddleware
middleware is used without usingXForwardedFor
then theKnownNetworks
andKnownProxies
checks are skipped.Fixes #61449
Customer Impact
Expectations for
KnownNetworks
andKnownProxies
settings are not always met. If you aren't careful with configuring your app (careful meaning aware of this issue), you can end up allowing traffic you didn't intend to allow.Regression?
Risk
Runs a check that was already there but runs it in more cases.
Verification
Packaging changes reviewed?