Repository navigation
🐛 fix: pin egress dials to validated addresses in server-side fetchers - #19225
Conversation
… addresses Refs #19221 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: merged v5 into the branch (it was 2 commits behind). The build-go failure was a 180s timeout in crux/lanes (NATS), a package this PR does not touch. CI pending, sweep will merge when green. 🐝 Hive Agent: Review follow-ups: 3 open of 3 (below
|
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether this change to the hub's SSRF guard (DNS-pinned transport on the contribute proxies and lite repo-access check) may land, since it sits on a security-sensitive trust boundary.
I read the change against the tree and found no defect, but I do not approve changes to the hub's SSRF guard, so this is routed to a person.
What I verified:
contributeProxyTransportandliteRepoAccessTransportboth reuse the existingpinnedFetchTransport(isPrivateURL)(src/pkg/hub/server.go:5182), which returns an*http.Transportbacked bynetguard.PinnedDialer, so no new dial logic is introduced.handleContributeWSProxyonly sets the transport whennewContributeWSReverseProxyleft it nil, so a test-injected or custom proxy keeps its own transport.liteRepoAccessRoundTripperfalls back to a replacedhttp.DefaultTransport, which matches the test convention named in the comment; production keeps the pinned one.
The new tests cover the rebinding case for all three call sites.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
|
build-go failed on a 🐝 Hive Agent: |
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the transport seam (pkg/hub/server.go:5182, pinnedFetchTransport), both call sites (server.go:5097, server.go:5135) and liteRepoAccessHTTPClient (lite_enrollment.go). The pinning is correct as far as I can tell: findContributeHive admits on isPrivateURL (server.go:4874), and the new transport re-resolves once per dial, re-checks each answer, and connects only to a checked address. The proxy.Transport == nil guard keeps a seam-supplied transport, and the http.DefaultTransport replacement check matches the hubGitHubHTTPClient convention. The three tests drive a public-then-loopback resolver, so they fail without the change.
One finding, on issue linkage: the body says Fixes #19221, but its own "Left for follow-up" section lists pkg/knowledge/gitsource.go and pkg/dashboard/api_contribute.go as still open on #19221. Merging as written closes the issue with that work undone. Suggest Refs #19221 (remaining: gitsource.go curl-resolve pinning and dashboard validateGitHubToken).
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
The contribute register/WS proxies now honour a replaced http.DefaultTransport the same way liteRepoAccessRoundTripper and hubGitHubHTTPClient do, via one shared helper. Hive-Fix-Attempt: 2/6 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Why
Part of #18986 (egress audit, section 2). #19030 already pinned the dashboard SSRF transport (
ssrf_guard.go), the knowledge document fetcher (docsource.go), and the hub hive-config proxy and webhook relay. Two hub fetchers still checked a remote-chosen host withisPrivateURLand then let the HTTP client resolve the name a second time, so a name that rebinds between the two lookups was checked as public and dialled as private:handleContributeProxyandhandleContributeWSProxy(pkg/hub/server.go):findContributeHivechecks the self-reportedDashboardURL, thenhttputil.NewSingleHostReverseProxydialled through the default transport.liteRepoAccessHTTPClient(pkg/hub/lite_enrollment.go, also used by self-service ownership checks):validateLiteGitHubHostchecks the caller-suppliedgithub_host, then the client dialled through the default transport.What
Following
pkg/inbox/link_fetch.goand the existingpinnedFetchTransporthelper, both paths now use anetguard.PinnedDialertransport. Each dial resolves the name once throughprivateURLResolver, checks every answer withisPrivateURL, fails closed if the lookup errors or comes back empty, and connects only to an address it checked. This covers every redirect hop. The change is additive: a WS proxy seam that sets its own Transport keeps it, and a replacedhttp.DefaultTransportis still honoured, the same conventionhubGitHubHTTPClientuses.Tests
pkg/hub/pinned_fetch_contribute_test.gouses a resolver that answers with a public address on the first lookup and loopback on later ones. It checks that the register proxy, the WS proxy andverifyGitHubRepoAccessall refuse the rebound address (502 /netguard.ErrRefused) and never reach the loopback upstream. It also checks which transport the client picks.Left for follow-up
Following the hive decision of one PR per package, this PR covers
pkg/hubonly. What remains on #19221:pkg/knowledge/gitsource.go: git clone/ls-remote runs as a subprocess. It needshttp.curloptResolvepinning plus a redirect policy.pkg/dashboard/api_contribute.govalidateGitHubToken: the GHE API URL there is set in operator config, so this one is lower priority.Refs #19221 (remaining:
pkg/knowledge/gitsource.goand dashboardvalidateGitHubToken, listed above)🤖 Generated with Claude Code
-- hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.327 requested_by=@clubanderson