Repository navigation
π fix(crux/proxy): apply destination policy to uninspected tunnels - #16785
Conversation
The plain-HTTP forward path refuses non-routable destinations at dial time, but a CONNECT to a host the proxy neither inspects nor intercepts, and the transparent-TLS passthrough for such a host, still dialled whatever host:port the client named from the proxy's own uid. Route both through the same guarded dialer so the policy has one definition and one override. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether refusing CONNECT and transparent-TLS tunnels to RFC 1918/CGNAT/link-local destinations by default (opt-out via HIVE_PROXY_ALLOW_PRIVATE_FORWARD=true) is acceptable for existing deployments whose agents reach private HTTPS services through the forced-egress redirect.
The code is correct and does what it says; I'm routing it because it changes the proxy's default destination policy, which is a trust surface (src/crux/proxy/** is CODEOWNERS-scoped), and because two operator docs now understate what the override covers.
Verified in the tree (not just the diff):
guardedMarkDialer(plain_forward_guard.go:146-157) is the same Control-hook check the plain path used inline;newPlainForwardTransportnow reuses it, so behaviour there is unchanged.tunnelDirectis reached only for hosts that are neither inspected nor MITM'd (github_proxy_connect.go:490-491), anddialTunnelUpstreamlikewise (:166-169); the GitHub/Linear/Copilot intercept paths dial elsewhere and are not affected.refuseTunnelmirrorsrefusePlainForward's loopback-vs-estate split;countViolationandidentifyAgentFromConnexist and have no side effects beyond the lookup.- The forced-egress rule is
-A HIVE_PROXY -p tcp --dport 443 -j REDIRECTwith no destination exemption (src/deploy/entrypoint.sh:2279), so after this lands an agent's HTTPS connection to any in-cluster or private-LAN service on :443 is refused with a violation count unless the operator sets the override. That is the stated intent (metadata endpoint, kube API, internal registries), but it is a default-behaviour change shipped under a π title, and agents'NO_PROXYonly covers loopback plus the OMP broker host (src/crux/agent/manager_env.go:30-41). Someone who owns deployments should confirm no fleet relies on agents reaching private HTTPS endpoints (self-hosted inference over TLS, GHE on a private IP that is not MITM'd).
Docs out of date with this change (should fix before merge):
src/docs/env-vars.md:221β still saysHIVE_PROXY_ALLOW_PRIVATE_FORWARD"lifts the plain-HTTP forward destination guard" and "a non-CONNECT request β¦ is dialled only whenβ¦"; it now also governs CONNECT and transparent tunnels.src/docs/security-model.md:208β same scoping ("only where a private-network plain-HTTPβ¦").
The new tests (tunnel_destination_guard_test.go) exercise 403 + violation count, loopback-not-a-violation, and the override, and the four existing loopback-tunnel tests opt in explicitly β that reads right to me.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @a41f37e, 68/68 checks green, DCO yes, soak 2m0s of 10m0s. What to do: approve this head ( How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to Updated 2026-11-06 19:51 UTC. |
|
Quality test-review @46cc511 β the new tests are good (and the PR body's "fails without the change" claim checks out for
var denied *plainForwardDenied
if errors.As(err, &denied) && denied.reason != plainForwardReasonLoopback {
p.logger.Warn(...)
p.countViolation(agentName)
}
Suggested addition (same shape as func TestHandleTransparentTLSRefusalCountsEstateNotLoopback(t *testing.T) {
for _, tc := range []struct {
sni string
want int
}{{"10.255.255.1", 1}, {"127.0.0.1", 0}} {
p := newTestProxy()
clientHello := buildClientHello(tc.sni)
clientConn, proxyConn := net.Pipe()
done := make(chan struct{})
go func() {
defer close(done)
p.handleTransparentTLS(proxyConn, clientHello[:1])
_ = proxyConn.Close()
}()
_, _ = clientConn.Write(clientHello[1:])
<-done
_ = clientConn.Close()
p.mu.Lock()
got := p.violations[""]
p.mu.Unlock()
if got != tc.want {
t.Errorf("SNI %s: violations = %d, want %d", tc.sni, got, tc.want)
}
}
}Not blocking β the decision question above is the gate β but worth folding in before merge so the arm is pinned. (Note: wait on π Hive Agent: β hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
β¦back handleTransparentTLS counts a refused estate-bound SNI against the caller and skips the counter for loopback; no test reached that arm, so dropping either the reason check or the countViolation call kept the suite green. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Folded in @a41f37e: π Hive Agent: β hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the forced-egress (transparent-TLS) leg may refuse RFC 1918/CGNAT :443 destinations by default β after this PR an agent's TLS connection to any in-cluster service on :443 is dropped and counted as a violation, with no NO_PROXY escape and only the global HIVE_PROXY_ALLOW_PRIVATE_FORWARD override.
Code looks correct to me; routing for a policy decision on the transparent-TLS leg.
Read plain_forward_guard.go, github_proxy_connect.go and github_proxy.go:94-115 at a41f37e.
What I verified:
guardedMarkDialer(plain_forward_guard.go:146-156) is a faithful extraction of the inline Control hook previously innewPlainForwardTransport;markDialeralways setsControl, so themark(...)chain is never nil.tunnelDialer(plain_forward_guard.go:164-169) keys offallowPrivateForward, whichnewGitHubProxyWithCAalready snapshots from the env β the override really is a single knob for all three legs.tunnelDirect(github_proxy_connect.go:614-620) andhandleTransparentTLS(:169-178) both unwrap*plainForwardDeniedwitherrors.As, so a guard refusal does not fall into the generic 502 branch. The new test exercises the CONNECT path only; the transparent leg is covered indirectly viadialTunnelUpstream.
The question for a maintainer (not a defect): the CONNECT leg is low-risk β an agent that needs a private host can set NO_PROXY. The transparent leg is different: src/deploy/entrypoint.sh:2279 REDIRECTs all non-proxy-uid :443 into the proxy regardless of destination, so after this PR any agent TLS connection to an in-cluster :443 service (Kubernetes API, internal registry, another spoke) is silently closed and counted as a violation. There is no per-destination escape; the only override is the global env var, which also lifts the plain-HTTP guard. Refusing "the Kubernetes API, other spokes, internal registries" is the stated intent of the guard (plain_forward_guard.go:34-35), so this may be exactly what you want β but it is a behaviour change on the forced-egress path that no agent can opt out of, and it should be a deliberate choice.
Docs not updated (low): src/docs/env-vars.md:221 still says the var "Lifts the plain-HTTP forward destination guard", and src/docs/security-model.md:200-210 describes the guard as plain-forward-only. Both now undersell what the override covers.
β hive: agent=reviewer model=claude-fable-5.1
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Code looks correct to me; routing for a policy sign-off because it changes proxy egress rules for all deployments. What I verified in the tree at
The one thing I can't settle from the code is whether any supported deployment relies on agents reaching private HTTPS endpoints through the forced redirect (an internal registry or in-cluster API an agent tool legitimately calls). The plain-HTTP guard already made this call for |
clubanderson
left a comment
There was a problem hiding this comment.
Owner decision (@clubanderson): Yes β agent-uid HTTPS (transparent :443 redirect), raw CONNECT and plain-HTTP to loopback / link-local / RFC 1918 / CGNAT / multicast destinations are refused by default on every spoke, and HIVE_PROXY_ALLOW_PRIVATE_FORWARD=true is the only lift. No supported deployment is meant to have agents reach the kube API, in-cluster registries or the metadata service through the proxy; where a private endpoint is legitimately needed we route around the proxy per host (the OMP_AUTH_BROKER_URL β NO_PROXY precedent in #15649/#15807), not by waving the tunnel through.
Rationale: fail closed at the proxy boundary β the MITM proxy exists to enforce what agents cannot bypass, and a tunnel it cannot inspect must not be the one leg without a destination policy. Same posture as #16977 and the plain-forward guard (#14082); this closes the two remaining legs with the same classifier, the same override and the same loopback-vs-estate split.
Verified locally on a41f37e (src/, go test -count=1 -coverprofile ./crux/proxy/, plus -race on the tunnel tests):
- Refusal:
TestTunnelDirectRefusesNonRoutableDestination(169.254.169.254 / 10.x / 100.64.x β 403 naming the env var, violation counted),TestDialTunnelUpstreamRefusesNonRoutableSNI,TestHandleTransparentTLSRefusalCountsEstateNotLoopback,TestTunnelDirectLoopbackRefusalIsNotAViolation. - Allowed paths:
TestPlainForwardDenyReasonClassifiesDestinations(public v4/v6 incl.140.82.121.4:443β allowed),TestTunnelDirectAllowPrivateForwardLiftsGuard,TestHandleConnectDirectGitHub,TestHandleConnectDirectAnthropicReroute*(MITM legs still use the plainmarkDialer),TestHandleConnCONNECTNonGitHub/TestTunnelDirectSuccess/TestHandleConnectDirectNonGitHubwith the override. - Package coverage 92.0% (floor 89%);
countViolationis a counter only (github_proxy_violations.go:264), so a mis-pointed tool degrades to a logged 403, not an agent pause. No drift insrc/crux/proxyon v5 since the PR base.
Follow-up (non-blocking): src/docs/env-vars.md:221 and src/docs/security-model.md:208 still describe the override as plain-HTTP-only; they should say it now covers uninspected CONNECT and transparent-TLS tunnels too.
Mirror: none needed β hivecommons/crux syncs its Go tree from src/crux.
|
LGTM label has been added. DetailsGit tree hash: 4fd0b87e399093f113b7bbbb9dfbc30237d3ce92 |
|
New changes are detected. LGTM label has been removed. |
|
[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 |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Since #16785 the proxy's destination guard covers plain-HTTP forwards, uninspected CONNECT tunnels and transparent-TLS passthrough, and HIVE_PROXY_ALLOW_PRIVATE_FORWARD=true lifts it for all three legs. env-vars.md and security-model.md still described the guard and its override as plain-HTTP-only; bring both in line with the code. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Summary
src/crux/proxyhas one destination policy for the plain-HTTP forward path (plain_forward_guard.go): the dialer'sControlhook refuses loopback, link-local, RFC 1918, CGNAT and multicast targets after name resolution, andHIVE_PROXY_ALLOW_PRIVATE_FORWARD=truelifts it. The two uninspected tunnel legs did not share it:tunnelDirect(a CONNECT to a host the proxy neither inspects nor intercepts) dialledr.Hostverbatim, anddialTunnelUpstream(transparent-TLS passthrough) dialled whatever the SNI named β both from the proxy's own uid, which the forced-egress redirect exempts.This factors the guarded dialer out into
guardedMarkDialer/(*GitHubProxy).tunnelDialerand routes all three legs through it, so the policy has a single definition and a single override. Refusals answer403with the same loopback-vs-estate split as the plain path (loopback is a client that ignoredNO_PROXY; everything else counts as a violation), and the boot-time warning now says what the override covers.Why here and not hivecommons/crux: crux's Go tree is a synced copy of
src/cruxand its Sync guard refuses*.gochanges; this is the source.Validation
go build ./crux/...insrc/go testis unavailable in this environment; CI runs the suite)BASE_REF=v5 bash src/scripts/check-changelog-fragment.shβ OKtunnel_destination_guard_test.gofails without thetunnelDirect/dialTunnelUpstreamchange (CONNECT to169.254.169.254:80/10.255.255.1:6443/100.64.0.1:443returns 200 instead of 403); the four existing loopback-tunnel tests opt in viaallowPrivateForward = true, the same pattern the plain-forward tests already useChecklist
git commit -s)changelog.d/fixed-proxy-tunnel-destination-policy.mdaddedβ hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88