Repository navigation
Conversation
The left-most X-Forwarded-For entry is written by the client, so a client behind a trusted proxy could choose the address used for aws:SourceIp. Walk the entries from the right, skip the trusted proxies, and use the first untrusted one.
Cover a single entry, several trusted proxies, empty entries, a repeated header, an IPv6 client and an IPv4-mapped trusted proxy.
Contributor
Hello fredmnl,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Contributor
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development/8.4 #2763 +/- ##
===================================================
+ Coverage 74.72% 74.75% +0.02%
===================================================
Files 229 229
Lines 18583 18595 +12
Branches 3822 3824 +2
===================================================
+ Hits 13886 13900 +14
+ Misses 4692 4690 -2
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The X-Forwarded-For header is a list of IPs where each proxy will append their client to the right of the list thereby constructing a chain of IP. The rightmost entries are written by the trusted proxies where as leftmost entries can be legit or forged by the client. Currently, arsenal uses the leftmost entry and is susceptible to being fooled by a bad actor forging that one IP address. Instead, we choose to walk right-to-left by successively removing all IPs that belong to trusted proxies that are known to be in the chain and belong to us. We use
trustedProxyCIDRsfor this.Edge cases: if every entry is trusted, we keep the leftmost one; if an entry is not a valid IP we keep the last trusted hop to its right (the direct peer if none).
Examples
The client is 1.2.3.4, the attacker connects from 1.2.3.4 and poses as 9.9.9.9, the LB is 10.0.0.1 and the s3-frontend is 127.0.0.1, so cloudserver's peer is always 127.0.0.1.
trustedProxyCIDRscontains 127.0.0.1 and, except in case 5, 10.0.0.1.1.2.3.41.2.3.4, 10.0.0.19.9.9.9, 1.2.3.49.9.9.9, 1.2.3.4, 10.0.0.1trustedProxyCIDRs→ s3-frontend1.2.3.4, 10.0.0.1Behaviour change
Assuming every proxy in front of cloudserver and Vault appends to
X-Forwarded-For, each of them must now be listed intrustedProxyCIDRs. An unlisted proxy is taken for the client: every request it forwards gets the proxy's address. Before, the left-most entry gave the right address for an honest client but could be forged; now it can't be forged, but we need to know every proxy. How we document and roll this out is for product to decide.Open for discussion
ip:port. An entry with a port is not a valid IP, so a trusted proxy writingip:portmakes us fall back to that proxy's address (often the local frontend,127.0.0.1) for every request. We could strip ports in Arsenal; left out for now to keep the change simple.real_ip_header X-Forwarded-For,real_ip_recursive on) does the same walk and acceptsip:port. The frontend already uses realip for its PROXY protocol listeners, and only onereal_ip_headerapplies per server block, so this would mean splitting the server block in two and makes the nginx configuration convoluted.