Don't fall back to REMOTE_ADDR unless X_FORWARDED_FOR is empty#1160
Closed
KaptajnKold wants to merge 1 commit intorack:masterfrom
Closed
Don't fall back to REMOTE_ADDR unless X_FORWARDED_FOR is empty#1160KaptajnKold wants to merge 1 commit intorack:masterfrom
KaptajnKold wants to merge 1 commit intorack:masterfrom
Conversation
The previous, faulty behaviour was to remove all trusted ip addresses from X_FORWARDED_FOR and returning the last one remaining, falling back to the REMOTE_ADDR if none remain. A problem arises if all the address in X_FORWARDED_FOR are trusted. They can't all be proxies. One of them (the first one) is the ip that made the request. The correct behaviour is to return the first one, but the previous implementation would remove them all, and fall back to REMOTE_ADDR. This patch removes trusted ips only from the tail of X_FORWARDED_FOR, and returns the last address in the resulting list, ensuring that we don't fall back to REMOTE_ADDR if X_FORWARDED_FOR is non-empty.
|
Hi @KaptajnKold |
Contributor
|
Almost the same PR was also submitted by me Such a shame this is in the pipeline for so long |
Contributor
|
@KaptajnKold does #1224 resolve the issue for you too? |
Author
|
@mikegee yes, it does. |
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 previous, faulty behaviour was to remove all trusted ip addresses
from X_FORWARDED_FOR and returning the last one remaining, falling back
to the REMOTE_ADDR if none remain.
A problem arises if all the address in X_FORWARDED_FOR are trusted.
They can't all be proxies. One of them (the first one) is the ip that
made the request. The correct behaviour is to return the first one, but
the previous implementation would remove them all, and fall back to
REMOTE_ADDR.
This patch removes trusted ips only from the tail of X_FORWARDED_FOR,
and returns the last address in the resulting list, ensuring that we
don't fall back to REMOTE_ADDR if X_FORWARDED_FOR is non-empty.