-
Notifications
You must be signed in to change notification settings - Fork 363
fix: allow configured HTTP proxy on private IPs in SSRF transport #2864
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
Merged
+229
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
[MEDIUM] IPv4-mapped IPv6 addresses may not match allowlist entries on dual-stack systems
When a proxy is specified as an IPv4 literal (e.g.
http://10.0.0.1:3128),proxyHostPortsstores the allowlist key as"10.0.0.1:3128"vianet.JoinHostPort(ip.String(), port).On dual-stack Linux hosts where the OS dialer uses an IPv6 socket to connect to an IPv4 endpoint, the
Controlcallback receives"[::ffff:10.0.0.1]:3128"asaddress. That string is not present in the allowlist, so the code falls through toSSRFDialControl, which rejects the private address — and the proxy dial fails.Trigger: dual-stack host + IPv4-literal proxy address. The consequence is an availability failure (all proxied requests refused), not a security bypass.
Suggested fix: normalise both sides to the IPv4 canonical form before comparison, or add both the IPv4 and IPv4-mapped IPv6 representations to the allowlist when the input is an IPv4 literal:
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.
Addressed in 8ce99b3: added a
canonicalHostPorthelper that folds IPv4-mapped IPv6 dial addresses ([::ffff:a.b.c.d]:port) back to dotted-quad form before the allowlist lookup. So an IPv4-literal proxy on a dual-stack host will now match regardless of which socket family the OS dialer picks. Covered byTestCanonicalHostPort.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.
Perfect — canonicalHostPort is exactly the right approach. Folding IPv4-mapped addresses at lookup time is cleaner than pre-populating both forms in the allowlist, and TestCanonicalHostPort nails the test coverage (including the hex-form case). Thanks for the quick fix!