-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conflicting XFF
and xff_trusted_cidr
documentation
#38462
Comments
I just ran the following unit tests:
Example 7 fails to pass, as it presents the wrong detected address. Also, even though it uses |
Happy to get this assigned to me once it's triaged. We could fix the documentation and make sure those examples are addressed by test cases. |
Thanks for raising this issue. |
I think that's actually working as intended, basically we have two options:
We looked at the code today with @jaellio, and when it comes to the option 2 (when we use xff extension), xff is always updated unless you explicitly tell it not to. And that behavior makes sense to me for the edge proxy use cases. The examples still seem incorrect though, particularly, as you pointed out the trusted client IP address in example 7 is wrong, both from the point of view of what is actually implemented and from the point of view of what we want the trusted client IP address to be. My understanding of the behavior we want here is that if the downstream address is trusted, then the trusted IP client should be the rightmost untrusted IP in XFF. The logic is based on the idea that trusted IP addresses represent trusted proxies that correctly update XFF. Each trusted proxy appends to XFF the downstream address it got the request from. If we got request from a trusted downstream address, then we can trust that the proxy before us appended a correct address to XFF, so the last entry in XFF is correct. If the last entry in XFF is itself a trusted IP, then we can be sure that entry it added to XFF is also correct, thus we can trust a second to last entry in XFF, and so on and so forth, until we find an entry we cannot actually trust (the entry that was added to XFF by the first trusted proxy in the chain of trust). Returning to the example 7, I think, the trusted client IP address should be |
Perhaps it would be helpful to rename |
Conflicting
XFF
andxff_trusted_cidr
documentationDescription:
The current documentation for using
xff_trusted_cidrs
for selecting the trusted original address is as follows:Based on the docs I'd expect the second to last IP address in the XFF header to be used as the original client address. The docs conflict with a later example:
Note the trusted client address is set to
192.0.2.1
. Based on the documentation I would have expected the trusted client address to be set to203.0.113.10
. I thought maybe thesecond-last
address was evaluated after appending the downstream IP address to the XFF but this also conflicts with a later example:In example 8, the trusted client address is set to 203.0.113.10 which is the expected second-last XFF IP.
Could someone clarify the expected behavior and if this behavior verified in a unit test?
The text was updated successfully, but these errors were encountered: