[13.x] Fix TrustProxies at:* when multiple proxies are used#60726
Open
mattford wants to merge 1 commit into
Open
[13.x] Fix TrustProxies at:* when multiple proxies are used#60726mattford wants to merge 1 commit into
mattford wants to merge 1 commit into
Conversation
Update TrustProxies to add all intermediate IP addresses to trusted list
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
bert-w
reviewed
Jul 10, 2026
Comment on lines
+123
to
+127
| $trustedIps = collect($this->gatherProxyIpAddresses($request)) | ||
| ->concat([$request->server->get('REMOTE_ADDR')]) | ||
| ->unique() | ||
| ->values() | ||
| ->all(); |
Contributor
There was a problem hiding this comment.
This does not seem efficient at all, especially considering this is a middleware.
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.
Update TrustProxies to add all intermediate IP addresses to trusted list
Currently, only the remote address is trusted when using TrustProxies:*. If there are multiple proxies this results in the most recent proxy being treated as the original client IP.
There are tests for this however they were incorrect, treating the last IP in the X-Forwarded-For or Forwarded header list as the original, however it should be the first one (https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For)
Symfony doesn't support wildcards in trusted proxies so to get around this, this patch gathers all IP addresses in the forwarded for or forwarded header + the remote address, and adds them all to the trusted list
Resolves #60725