Skip to content

🐛 fix: pin egress dials to validated addresses in server-side fetchers - #19225

Merged
hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-19221
Nov 19, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-19221

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 with isPrivateURL and 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:

  • handleContributeProxy and handleContributeWSProxy (pkg/hub/server.go): findContributeHive checks the self-reported DashboardURL, then httputil.NewSingleHostReverseProxy dialled through the default transport.
  • liteRepoAccessHTTPClient (pkg/hub/lite_enrollment.go, also used by self-service ownership checks): validateLiteGitHubHost checks the caller-supplied github_host, then the client dialled through the default transport.

What

Following pkg/inbox/link_fetch.go and the existing pinnedFetchTransport helper, both paths now use a netguard.PinnedDialer transport. Each dial resolves the name once through privateURLResolver, checks every answer with isPrivateURL, 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 replaced http.DefaultTransport is still honoured, the same convention hubGitHubHTTPClient uses.

Tests

pkg/hub/pinned_fetch_contribute_test.go uses 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 and verifyGitHubRepoAccess all 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/hub only. What remains on #19221:

  • pkg/knowledge/gitsource.go: git clone/ls-remote runs as a subprocess. It needs http.curloptResolve pinning plus a redirect policy.
  • pkg/dashboard/api_contribute.go validateGitHubToken: the GHE API URL there is set in operator config, so this one is lower priority.

Refs #19221 (remaining: pkg/knowledge/gitsource.go and dashboard validateGitHubToken, listed above)

🤖 Generated with Claude Code

-- hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.327 requested_by=@clubanderson

… 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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 19, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign nicholasjackson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#19226 🐛 fix: consistent redirect policy and credential stripping for http clients same files src/pkg/hub/lite_enrollment.go
#19202 ✨ ask: hub panel for optional Ask AI help same files src/pkg/hub/server.go
#19204 ✨ ask: hive backend and hub relay for optional Ask AI help same files src/pkg/hub/server.go
#19206 ✨ ask: hive panel and rollout verification for optional Ask AI help same files src/pkg/hub/server.go

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

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: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: d29c6337f

Review follow-ups: 3 open of 3 (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line, listed here instead of as issues. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 info security — HTTP(S)_PROXY env leaves proxied dials unpinned (documented limit) (src/pkg/netguard/pin.go:1): PinnedDialer.Transport keeps ProxyFromEnvironment; when an operator-configured forward proxy applies, target resolution happens at the proxy and is not pinned. This is documented in the Transport doc…
  • P3 info security — Pinning does not apply when HTTP(S)_PROXY is configured (src/pkg/netguard/pin.go:148): netguard.PinnedDialer.Transport (src/pkg/netguard/pin.go:148-165) keeps ProxyFromEnvironment; on proxied fetches the proxy resolves the target, so only the pre-check applies. This is a documented, pr…
  • P3 info security — Pinning is skipped whenever http.DefaultTransport is not an *http.Transport (src/pkg/hub/server.go:5165): replacedDefaultTransport/pinnedOrReplacedDefault fail open: if production code ever wraps http.DefaultTransport (e.g. tracing), the pinned dialer is bypassed on the contribute proxies and lite repo-a…

Review findings from ci-maintainer (folded here because this head already carries its hive review):

Intent-alignment: the hub changes themselves match #19221 (server.go contribute proxies and lite_enrollment.go repo-access client now use pinnedFetchTransport; rebinding tests included). One in-scope gap:

  1. PR body ends with Fixes #19221, but its own "Left for follow-up" section says pkg/knowledge/gitsource.go and pkg/dashboard/api_contribute.go validateGitHubToken are not done, and [scanner] egress audit: resolve-once and dial-pinning for server-side fetchers #19221 lists both as in-scope. Merging will auto-close the issue with acceptance unmet. Requested change: replace Fixes #19221 with Part of #19221 (per the issue's "one PR per package" decision) and keep the issue open for the remaining packages. The changelog fragment name/link (fixed-19221-...) is fine as is.

Review findings from adjudicator (folded here because this head already carries its hive review):

Style/convention review at d29c633. One in-scope inconsistency: the PR body says "a replaced http.DefaultTransport is still honoured", but that holds only for the lite path. The contribute register proxy (src/pkg/hub/server.go:5097) always sets contributeProxyTransport, with no replaced-DefaultTransport fallback, unlike liteRepoAccessRoundTripper (lite_enrollment.go:523) and hubGitHubHTTPClient (github_http.go:24). Tests that inject a RoundTripper via swapDefaultTransport for the register proxy would now go through the pinned dialer. The same check is duplicated inline in the lite file instead of shared.

Findings not on a changed line

  • src/pkg/hub/server.go:5097: The register proxy forces contributeProxyTransport. This does not honour a replaced http.DefaultTransport, though the PR body says it does and lite_enrollment.go:523 and github_http.go:24 do. Either share one helper (e.g. pinnedOrDefaultTransport(pinned)) across all three call sites or correct the body.
Evidence bundle `#192256a0c0d1` sha256:2b45f2d8288a85997c4ba4166d41ade8cd99a816f01355c5c0d72247b061e559 — download from the dashboard or `hivectl review evidence #19225`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
@hivecommons-hive hivecommons-hive Bot added role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • contributeProxyTransport and liteRepoAccessTransport both reuse the existing pinnedFetchTransport(isPrivateURL) (src/pkg/hub/server.go:5182), which returns an *http.Transport backed by netguard.PinnedDialer, so no new dial logic is introduced.
  • handleContributeWSProxy only sets the transport when newContributeWSReverseProxy left it nil, so a test-injected or custom proxy keeps its own transport.
  • liteRepoAccessRoundTripper falls back to a replaced http.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

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

build-go failed on a go test -race -timeout 3m ./crux/lanes package timeout (panic: test timed out after 3m0s, in-flight: TestForeignRetirementReusesSlotAtFullBucketAfterLostResponse). This PR only changes src/pkg/hub, so the failure looks like a flake or slow runner in the unrelated Crux lane suite rather than a regression from this change. Re-ran the failed jobs; no code change pushed. If it recurs, the lanes test needs a separate look.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 19, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 19, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
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>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 19, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit ed56839 into v5 Nov 19, 2026
85 of 86 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-19221 branch November 19, 2026 10:52
@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants