-
Notifications
You must be signed in to change notification settings - Fork 4.4k
VAULT-191: Validate X-Forwarded-For IP #29774
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
Conversation
CI Results: |
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.
validation seems in line with other checks in the file
Build Results: |
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!
req := client.NewRequest("GET", "/") | ||
req.Headers = make(http.Header) | ||
req.Headers.Set("x-forwarded-for", "5.6.7.8, 4.5.6.7, 8.8.8.8") | ||
req.Headers.Set("x-forwarded-for", "10.9.8.7, 1.2.3.4, 256.1.1.1") |
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.
@miagilepner calling .Set()
will replace the contents.
https://pkg.go.dev/net/http#Header.Set
You'd want to use https://pkg.go.dev/net/http#Header.Add if the intention was to test two chains of x-fowarded-for
.
The same issue exists in the second testcase you added below.
Description
This PR validates that the client address extracted from the X-Forwarded-For header is a valid IP address
TODO only if you're a HashiCorp employee
backport/
label that matches the desired release branch. Note that in the CE repo, the latest release branch will look likebackport/x.x.x
, but older release branches will bebackport/ent/x.x.x+ent
.of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.