-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
X-Forwarded-For #4380
X-Forwarded-For #4380
Conversation
command/server/config.go
Outdated
@@ -761,6 +761,10 @@ func parseListeners(result *Config, list *ast.ObjectList) error { | |||
"address", | |||
"cluster_address", | |||
"endpoint", | |||
"forwarded_for_authorized_addrs", | |||
"forwarded_for_hop_skips", | |||
"forwarded_for_reject_non_authorized", |
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.
Thoughts on non_authorized
vs not_authorized
? not_authorized
can go a little better with not_present
.
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 idea, changed.
helper/parseutil/parseutil.go
Outdated
for _, addr := range stringAddrs { | ||
sa, err := sockaddr.NewSockAddr(addr) | ||
if err != nil { | ||
return nil, errwrap.Wrapf("error parsing address: {{err}}", err) |
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.
Do we want to mention the problematic addr
in the error statement?
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.
Done.
http/handler.go
Outdated
if len(headers) == 1 { | ||
headers = strings.Split(headers[0], ",") | ||
} | ||
for i, v := range headers { |
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.
Is passing multiple X-Forward-For
headers that are each comma separated valid [0]? If so, this is only iterating through the first set and not parsing the values correctly.
[0]: -H 'X-Forwarded-For: 203.0.113.100, 203.0.113.101' -H 'X-Forwarded-For: 203.0.113.200, 203.0.113.201'
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.
It's not an actual standard, so...no idea? I guess I can handle that.
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.
Fixed.
Docs are still todo.
This uses the approach of "specify how many hops back we should be looking" rather than some metric like "is a public IP" in order to validate. Behavior on unauthorized address or missing header can be set to reject or allow (without actually trusting the header).