-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Trimming whitespace in XFF for IP whitelisting #3971
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👏
7f813c6
to
c5f42cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
d9b0ef6
to
80735c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
80735c6
to
0cb46a3
Compare
What does this PR do?
Trims whitespace from
X-Forwarded-For
header values.Motivation
In case there are multiple comma-separated values for the XFF header, there might be trailing whitespace after the comma e.g.
If that's the case, then
net.parseIP
will returnnil
and the whitelist check will fail.This situation was not caught by the test since the fixture:
listed the matching IP as the first value in the comma separated value, hence not testing the second value (
10.2.3.1
) which contains the whitespace.More
Additional Notes