fix: allow configured HTTP proxy on private IPs in SSRF transport#2864
Merged
Conversation
melmennaoui
previously approved these changes
May 21, 2026
c2e6547 to
8ce99b3
Compare
rumpl
approved these changes
May 21, 2026
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.
Inside the docker-agent sandbox, all egress traffic must route through a network-policy proxy on a private IP (e.g.
http://172.17.0.0:3128). Thepkg/httpclient.NewSSRFSafeTransportfunction installs a dial-time SSRF check that rejects every non-public address. When the HTTP client follows theHTTP_PROXYenvironment variable, it dials the proxy itself first—and our check saw the private IP proxy address, rejected it, and every outbound request failed. This broke the aqua-registry HTTP fetch that auto-installsgopls, so the binary never landed on PATH and the MCP toolset couldn't start.NewSSRFSafeTransportnow snapshotsHTTP_PROXY,HTTPS_PROXY, andALL_PROXY(and lowercase variants) at construction time, parses each proxy spec into one or morehost:portentries, and bypasses the SSRF dial control for dials whose post-resolution address matches. The underlyingSSRFDialControlfunction is unchanged, so DNS-rebinding defenses continue to apply to every other dial. Allowlisting an operator-configured proxy doesn't widen the SSRF threat model: refusing to dial it provides zero protection (the proxy itself enforces destination policy), and breaking every request inside the sandbox is not acceptable.Three new tests pin the behavior:
TestProxyHostPortscovers URL/bare-host parsing and default port assignment forhttp,https, andsocks5schemes;TestNewSSRFSafeTransport_AllowsConfiguredProxyis the regression test verifying private-IP proxies bypass SSRF rejection;TestNewSSRFSafeTransport_AllowlistFrozenAtConstructiondocuments that the allowlist is captured at construction time (which is correct since proxy env vars are set at process start).