Repository navigation
✨ Sandbox Jobs: authenticated GitHub reads via a read-only hive relay - #18868
Conversation
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review findings from Read the relay ( Open question (not verified, no code cited): whether Not approving; that is a human's call. Findings not on a changed line
Review findings from Needs a maintainer call because this adds a new credential-bearing listener. I read the relay, policy, enroll path and config in the diff; I found no read-only bypass. Verified OK: Open decision (the question above). Low, noted: the relay key is checked only at CONNECT. An already-established tunnel keeps working after One line finding is inline (token mint failure path). Findings not on a changed line
Review findings from HUMAN DECISION NEEDED — confirm a sandbox Job may read every project repo (incl. private) through the relay's single shared read token. Delta re-review at fdf97f0. The relay code ( Previous finding Limits: I read only the security-relevant files in the 84-file delta (relay, boot wiring, executor, CA forging); the dashboard, automerge and config-UI changes were not reviewed. Review findings from Style re-review at fdf97f0: no blockers. Advisory: the PR body still says |
There was a problem hiding this comment.
Correctness review at head 4327d29.
- High — does not compile.
src/cmd/hive/sandbox_read_relay_boot.go:82callsb.agentMgr.SetSandboxGitHubReadRelay, butagentMgrishostedRuntime(crux.Runtime+crux.Host) and the method is only added to*agent.Manager.crux.Host(src/crux/host_wiring.go) and the other implementers are untouched; CI build-go / build-and-test / golangci-lint are failing. Add it tocrux.Hostand implement it everywhere; decide what sidecar mode does, since its Job kicks run out of process. - Low — read-token mint failures are not backed off (see inline).
The policy table, key auth, header stripping and read-only enforcement read correctly.
— hive: agent=adjudicator backend=claude model=claude-sonnet-5-5 claude=2.1.326
| // issues, all read), narrowed to the project's repositories. It is never the | ||
| // write-capable credential. | ||
| func (b *boot) sandboxReadToken() (string, error) { | ||
| auth := b.appAuth |
There was a problem hiding this comment.
Build break. b.agentMgr is hostedRuntime (crux.Runtime + crux.Host). SetSandboxGitHubReadRelay exists only on *agent.Manager; it is not in crux.Host (src/crux/host_wiring.go) and the PR doesn't touch that file, sidecarHost, or the cruxtest fakes. CI build-go/build-and-test/golangci-lint are red. Add the method to crux.Host and implement it on every Host (sidecarHost: forward or no-op with a warning, since sidecar-mode Job kicks run out of process).
| }, nil | ||
| } | ||
|
|
||
| // authenticate returns the agent a Proxy-Authorization header belongs to. |
There was a problem hiding this comment.
Mint failures aren't negative-cached: tokMu is held across opts.Token() (up to 20s), and a failure leaves tokFetched stale, so during an App outage every injectable request retries serially. Suggest a short failure backoff (e.g. 30s) before retrying.
|
Scanner (suggestion only; branch is busy): 🐝 Hive Agent: — hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.326 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Owner decision on the reviewer-2 needs-decision item (listener bind and cleartext key), implemented in head a0579d9:
Left out by the same decision: the tunnel that outlives its released key, tracked in #18895. |
There was a problem hiding this comment.
Decision needed: @clubanderson should every sandbox Job kick get a read token covering all of project.repos, or should the relay scope it to the repos that kick is working on?
This adds a credential-attaching network listener and mints a GitHub App read token for Jobs, so it is a trust-surface change a person should sign off on. I read crux/proxy/sandbox_read_relay.go and cmd/hive/sandbox_read_relay_boot.go in full and did not find a defect in the mechanics.
What I checked and found sound:
SandboxReadPolicyonly attaches a credential to GET/HEAD on the four fixed hosts, plusgit-upload-packPOST. Push discovery and every other method get a 403.applySandboxReadAuthstrips the Job's ownAuthorizationandProxy-Authorizationbefore attaching anything.sandboxReadRequestTargetsHoststops a request inside the CONNECT tunnel from naming another host and riding the credential decision.- The listener is TLS-only, and the per-kick key is stored as a SHA-256 digest and revoked on release.
Open question (the only reason this is routed): sandboxReadToken (sandbox_read_relay_boot.go:92) mints one shared-uid-read token for all of b.cfg.Project.Repos. Any Job that holds a relay key can therefore read every repo in the project, including private ones, through api.github.com and raw.githubusercontent.com. The linked issue's option-1 decision does not say whether that breadth is intended. I could not find a per-agent or per-kick narrowing in the diff; please correct me if it exists.
Not verified: the 1,891-line diff is mostly tests and docs, and I did not run anything. Concurrency of the keys map and readToken looked correct on a read.
— hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.326
| } | ||
| ctx, cancel := context.WithTimeout(context.Background(), sandboxReadTokenTimeout) | ||
| defer cancel() | ||
| return auth.ScopedTokenForRepos(ctx, crux.SharedUIDReadTokenTier, b.cfg.Project.Repos) |
There was a problem hiding this comment.
This token is scoped to all b.cfg.Project.Repos and cached for 45 minutes, then attached to every Job's reads. A Job working on one repo can read every other project repo, private ones included. If that is intended, say so in sandbox-isolation.md. If not, mint per-kick tokens for the repos the kick needs.
…elay (#18865) Adds an opt-in relay (agent_sandbox.job.github_read_proxy, default off) that sandbox Jobs reach through HTTPS_PROXY. It attaches a read-only, repo-scoped App token (shared-uid-read tier) to GET/HEAD for api.github.com, codeload.github.com, raw.githubusercontent.com and git fetch on github.com; refuses writes, GraphQL and push discovery; tunnels other hosts untouched. The Job holds only a per-kick relay key, never a GitHub credential. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…host check (#18865) - Add SetSandboxGitHubReadRelay to crux.Host and implement it on every Host: Manager, the sidecar host (in-process-only), the cruxtest recorder, and the api HostSetters table. boot calls it through the interface. - Move SandboxGitHubReadRelay into the crux package (agent aliases it) and keep the Manager's relay wiring in one atomic value so the relay and its NO_PROXY hosts can never be read from different installs. - Keep agent/manager.go and config/agent_config.go under their ratchets by moving code out (ACMM level accessors, sandbox job types and the relay config) instead of raising any limit. - Refuse a request inside a tunnel whose Host or absolute URL names a host other than the CONNECT target, so the credential decision cannot be borrowed for another host. - Fix the boot test's Config literal (AgentSandbox is promoted). - Tests: relay logs never contain the token, relay key or agent header; keys are per kick; Host mismatch is refused without an upstream dial; manager install/clear copies noProxy. Signed-off-by: Andy Anderson <andy@clubanderson.com>
…ratchet (#18865) Signed-off-by: Andy Anderson <andy@clubanderson.com>
… SA4023) (#18865) Signed-off-by: Andy Anderson <andy@clubanderson.com>
… retrying per request (#18865) Signed-off-by: Andy Anderson <andy@clubanderson.com>
… v5 merge (#18865) Signed-off-by: Andy Anderson <andy@clubanderson.com>
…int, NetworkPolicy docs (#18865) Owner decision on the needs-decision review item: - listen_addr has no default; enabling without it fails config validation with an error naming the key (default off is unchanged). - The listener serves TLS only, with a certificate issued by the existing hive proxy CA for the endpoint host (DNS or IP SAN); endpoint must be https:// and http:// is rejected at validation. No new CA or key on disk. - Jobs verify the https proxy against the hive CA bundle, including libcurl's separate proxy CA setting for git (http.proxySSLCAInfo). - Tests: plain HTTP is refused and its key never logged, no key still gets 407 over TLS, certificate SANs, config validation, env. - Docs: example NetworkPolicy, two-layer statement, client TLS-to-proxy limits, example config, changelog fragment. Follow-up for the tunnel that outlives its key: #18895. Signed-off-by: Andy Anderson <andy@clubanderson.com>
a0579d9 to
f05bcfd
Compare
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
Owner confirms the reviewer-2 needs-decision answers above (no default bind address, TLS only with a certificate from the hive proxy CA, feature default off). Proceeding to rebase onto v5 and merge. |
There was a problem hiding this comment.
HUMAN DECISION NEEDED — @clubanderson: accept or narrow the read token's scope (credential policy): the relay mints one shared-uid-read token spanning every project.repos entry for all Jobs.
Intent-alignment at fdf97f0 (delta from a0579d9, which is mostly merges from base; the PR's own 31 files stay scoped to #18865, no scope creep):
- Issue #18865 acceptance (authenticated reads, no write capability, token out of the Job): met by
src/crux/proxy/sandbox_read_relay.go(GET/HEAD plus git-upload-pack only; other methods get 403) andsrc/crux/agent/sandbox_github_read_relay.go(the env carries a relay key, no GitHub token). - Previous security finding (
src/cmd/hive/sandbox_read_relay_boot.go:92, token spans all project repos): still present.ScopedTokenForRepos(ctx, SharedUIDReadTokenTier, b.cfg.Project.Repos)is unchanged, and no per-agent or per-kick narrowing was added. It needs a human decision, not an agent fix. - Description drift (low): the PR body says
listen_addrdefaults to:18445.src/crux/config/sandbox_job_types.gosays there is deliberately no default and requires it when enabled. Update the body or the code so they agree. - Not verified: I did not run the tests, and the
uv lock --upgradeno-clone acceptance is not tested in the diff.
— hive: agent=adjudicator-3 backend=claude model=claude-sonnet-5-5 claude=2.1.326
…ub-read-relay Signed-off-by: Andrew Anderson <andy@clubanderson.com> # Conflicts: # src/hive.yaml.example
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Fixes #18865
Owner decision on the issue: option 1. Sandbox Job GitHub reads go through hive, which attaches a read identity the Job never sees.
Why this is a relay and not just the inject flag
Sandbox Jobs run in their own pods. Today they bypass the hive proxy entirely: the proxy listens on loopback, identifies callers by socket UID, and kubejob sets no proxy or CA env. So
HIVE_PROXY_INJECT_GH_AUTHcannot reach a Job. This PR wires the Job through a second, narrow listener that reuses the proxy's CA, cert forging, destination-guarded dialers and upstream chain.What it does (default off)
Config:
agent_sandbox.job.github_read_proxywithenabled,endpoint(required, how Job pods reach hive),listen_addr(default:18445),no_proxy. Hive-wide only; a per-agent job block cannot enable or repoint it. Documented insrc/docs/sandbox-isolation.md.When enabled, each
sandbox.runtime: jobagent kick getsHTTPS_PROXY(with a per-kick relay key), a CA bundle written to<workspace>/.hive/github-read-ca.pem(system roots plus hive CA), and the usualSSL_CERT_FILE/GIT_SSL_CAINFO/etc. env.Authorizationstripped, read token attachedCredential
The existing
shared-uid-readtier (metadata, contents, actions, checks, pull requests, issues: all read) viaScopedTokenForRepos, narrowed toproject.repos. The codebase does distinguish read and write tiers, so no new credential type. It is never the write token, never in the Job env, files or logs. The Job holds only a per-kick relay key (revoked when the kick ends) that authenticates it to hive's listener. Token cached 45 min in hive memory. If no read token can be minted, reads go out anonymously as today and the agent's own Authorization is still stripped.Tests (not run locally per repo rules; CI is the gate)
Notes for review
HIVE_PROXY_INJECT_GH_AUTH(which governs placeholder tokens for pod-local agents); it has its own opt-in. Say so if you want it additionally gated on that env.🤖 Generated with Claude Code