Repository navigation
Description
Summary
Hive has a good outbound guard on one path and a different, weaker one on several others. The agent egress proxy refuses non-globally-routable destinations at dial time on the resolved address (src/crux/proxy/plain_forward_guard.go), which is the right shape: the address that was checked is the address that is connected to. Several other outbound paths were hardened one finding at a time (#3054, #3266, #3289, #3759, #11248) and each grew its own check. Nothing has audited the whole set against one fail-closed standard, so the paths disagree about what "private" means, about whether the validated address is the one that is dialled, and about what happens when the check itself cannot run.
This issue is an audit plus the tests that pin the result. It is not a request to rewrite the proxy. Reading the v5 tree at fd84863 already shows concrete candidates (below); the audit confirms or refutes each with a failing test before any fix is proposed.
Where it applies
Agent and sandbox egress (the proxy, src/crux/proxy/):
plain_forward_guard.go: dial-timeControlhook,guardedMarkDialer,plainForwardDenyReasonAddr. Used by the plain-HTTP forward and the uninspected tunnels.upstream_chain.go:dialUpstreamRawwhen an upstream proxy is configured. The upstream proxy resolves the name, so the guard can only classify a literal IP here.upstream_chain.godialUpstreamTLS,github_proxy_copilot.go,sandbox_read_relay.go: the TLS legs for inspected hosts use the unguardedmarkDialer.github_proxy_connect.goforwardPlainDirect: forwards the agent's request after deleting onlyProxy-AuthorizationandProxy-Connection.github_proxy_mitm.goproxyHTTPHost:http.ReadRequestthen relay to a fixed upstream connection.inference_route.go(inferenceHTTPClient, model discovery clients),entitlement.go,reference_repos.go:http.Clientvalues with the default redirect policy.sandbox_read_relay.go: the Job read relay and its opaque tunnel.
Server-side fetchers that act on URLs a user or a remote party influences:
src/pkg/dashboard/api_contribute.goisPrivateURL,src/pkg/dashboard/ssrf_guard.gonoRedirectToPrivate.src/pkg/hub/server.go(a second copy ofisPrivateURLand its resolver seam).src/pkg/knowledge/docsource.go,src/pkg/knowledge/gitsource.go(resolve then check).src/pkg/inbox/link_fetch.goLinkFetcher.dial(resolves once, refuses if any answer is blocked, dials the checked address). This is the reference behaviour the others should match.
What we need
Run these checks against the code, record the result for each in the audit comment (pass, fail with a failing test, or accepted risk with the reason), and add the tests. Fail-closed means: when a check cannot be evaluated, the request is refused.
1. Address classification (one definition).
- The string-prefix blocklist in
isPrivateURL(127.,10.,172.16.to172.31.,192.168.,169.254.,[::1],[::ffff:,0.0.0.0) is applied to resolved addresses as text. Check whether it misses: CGNAT100.64.0.0/10, IPv6 unique-localfc00::/7, IPv6 link-localfe80::/10, bare::1(the resolver returns it without brackets), IPv4-mapped IPv6 in non-bracket form, NAT64 and 6to4 embeddings of private IPv4, multicast. - Check IP literal spellings that a resolver or client may accept: decimal (
2130706433), octal (0177.0.0.1), hex (0x7f.1), short forms (127.1), trailing dot, uppercase, a userinfo section placed before an internal IP host, and bracketed IPv6 with a zone. - Decide on one shared classifier (the netip-based one in
plain_forward_guard.gois the model) and list every site that should call it.
2. Resolve once and pin.
- For each server-side fetcher above, confirm whether the connection is made to the address that was validated, or whether the name is resolved a second time by the HTTP client after the check (a rebinding window).
link_fetch.gopins; the dashboard, hub and knowledge fetchers resolve withLookupHostand then lethttp.Clientdial the name. - Confirm the dial-time hook is used for every redirect hop, not only the first request.
- Confirm happy-eyeballs and multi-answer behaviour: every answer is checked, not only the first.
3. Redirects.
- Proxy-side
http.Clientvalues (inferenceHTTPClient, model discovery, entitlement probe, reference repos) use the default policy: up to ten hops, credentials kept on same-host hops. Confirm a cross-host or private-target redirect from a configured gateway endpoint cannot carry the gateway key or reach a private address. State whether these paths are in scope for the guard (the endpoints are operator-configured, so this may be an accepted risk; record it). - Confirm
forwardPlainDirectnever follows a redirect on the agent's behalf (it usesRoundTrip) and that aLocationto a private address is only returned to the agent, not fetched. - Confirm the maximum hop count and credential stripping on every
CheckRedirectinsrc/pkgare the same (ssrfMaxRedirects,stripAuthOnCrossHostRedirect).
3b. Chained and inspected legs.
- With an upstream proxy configured,
dialUpstreamRawonly classifies literal IPs. Decide what the control is for a hostname there (a documented limit, a pre-resolution by Hive, or refusing the combination without an explicit opt-in) and test it. - The inspected-host TLS legs (
api.github.com, the registered GitHub Enterprise hosts, Linear, Copilot hosts) dial without the guard. Confirm the dial target can only come from the allowlist, and test what happens when a registered host resolves to a private address (it may be legitimate for an enterprise host; the answer should be explicit config, not an accident).
4. Request smuggling and header hygiene.
- Table-test both relays (
forwardPlainDirect,proxyHTTPHost, and the read relayintercept) with:Content-LengthplusTransfer-Encoding: chunked, duplicate and conflictingContent-Length, obsolete line folding,Transfer-Encoding: xchunked, whitespace before the colon, bare LF, oversized headers, absolute-form request lines whose host differs from theHostheader, and aHostheader that differs from the CONNECT target of an inspected tunnel. - Confirm hop-by-hop headers named in
Connectionare removed in both directions, and thatProxy-Authorization,X-Forwarded-*and any internalX-Hive-*header an agent supplies are stripped before forwarding.forwardPlainDirectdeletes only two headers today. - Confirm the policy decision is made on the same parse of the request that is forwarded (no second parse that could disagree with the first).
- Confirm path normalisation: rules in
rules.gomatch a path string; test dot-segments, double slashes, percent-encoded slashes and case against each deny rule.
5. Errors must deny.
- Enumerate every branch in the proxy decision path that can fail: body read errors, body over the scan limit, JSON or GraphQL parse failures, regex or rule-table lookup misses, canary or classifier callbacks unavailable, resolver failure, identity lookup failure (
/proc/net/tcpread), policy callbacks that are nil. For each, record whether the outcome is deny or allow and the test that proves it. Several branches already deny (enforceLinear,inspectCanaryEgress,WriteSurfaceGraphQLRefusal); the audit is to prove the rest, and to write down the ones that intentionally do not (for example the advisory-mode fallback for an unidentified caller). - Confirm the unset or zero-value configuration of each guard is the protected one (the
allowPrivateForwardzero value is guarded; check the others). - Add a fault-injection table test: a policy callback that returns an error, panics, or blocks past its deadline must produce a deny, not a forward.
Acceptance criteria
- An audit comment on this issue lists every check above with a result and a code reference.
- Each failing check has a regression test in the same PR as its fix (or an issue filed with a failing test).
- One shared address classifier is used by the proxy and the server-side fetchers, with table tests covering the classes in item 1.
- Every server-side fetcher connects to the validated address, with a test using a resolver that answers differently on the second lookup.
- A smuggling and header table test exists for each relay and passes.
- A fault-injection test shows every proxy policy seam fails closed.
-
src/docs/security-model.mdsection 5 andsrc/docs/security-threat-model.mdstate the result, including accepted risks.
Open questions
- Should the dial-time guard also cover the inspected TLS legs, with an explicit allow for enterprise hosts on private addresses?
- Is the operator-configured gateway endpoint inside the SSRF threat model, or trusted by definition?
- Is the unidentified-caller advisory fallback acceptable as a documented fail-open, or should it deny on write paths?
- Single PR per finding, or one hardening PR per package?
Effort: medium. The audit is a day or two of reading and tests; fixes are small per finding.
Activity
clubanderson commentedon Nov 18, 2026
Claimed by the maintainer: a dispatched agent is working this, one PR to follow. Please do not open a parallel PR.
hivecommons-hive commentedon Nov 18, 2026
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.
PR #19225 covers this issue: #19225
The PR body says this is partial/non-closing work (
Refs/Part ofor leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.🔒 fix: one shared address classifier for server-side URL fetch guards (…
🐛 fix: fail-closed fault injection for proxy policy seams (#19227)
fix(proxy): strip hop-by-hop and agent forwarding headers (#19264)