Skip to content

fix: use authorized broker sessions for admin commands - #1714

Open
steipete wants to merge 2 commits into
mainfrom
codex/admin-github-session
Open

fix: use authorized broker sessions for admin commands#1714
steipete wants to merge 2 commits into
mainfrom
codex/admin-github-session

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Admin and image commands reject an operator's configured GitHub session locally unless a separate admin token is configured, even though the coordinator already supports admin grants for immutable GitHub owners. This blocks legitimate host-management workflows before the server can authorize the request.

Why This Change Was Made

Use the normal configured broker authentication when no explicit admin token exists. An explicit admin token still takes precedence and suppresses the normal token command. Missing broker credentials still fail locally before any guest-side checkpoint preparation. A server denial is authoritative: there is no retry with another credential and no server policy or privilege change.

User Impact

Operators with an existing coordinator-side GitHub admin grant can use their login for admin and image commands. Ordinary users and shared-token callers remain subject to the same server-side refusal. Documentation now describes the existing authorization boundary consistently.

Evidence

  • Regression reproduced on the original owner: configured session, token command, and server-denial propagation failed; three explicit-token controls passed.
  • All six cases pass with the fix: go test ./internal/cli -run '^TestAdminLeasesUsesConfiguredAuthorization$' -count=1 -v.
  • go build -trimpath -o <task-binary> ./cmd/crabbox passed.
  • Live negative proof: a configured session without admin authority reaches the exact host-quota endpoint and still receives HTTP 403. No host was allocated and no server authorization was changed. Successful live admin access is not claimed.
  • Managed Codex Autoreview: clean for P0 findings; no accepted actionable findings.
  • Current production delta: +7/-4 (net +3), all in the existing admin client constructor to preserve credential precedence and reject missing authentication before guest preparation. Tests: +105/-6. Remaining changes are documentation; no changelog edit remains.
  • Broader admin/coordinator/auth/image race tests passed: 161 top-level tests, 287 leaf executions. go vet ./internal/cli and node scripts/build-docs-site.mjs also passed.

Follow-up on CI

The first CI run caught a missing-credential regression in the legacy checkpoint path: it reached guest preparation before refusing absent broker authentication. The follow-up restores that early guard using the existing client authentication predicate, without requiring a separate admin token. Both regression cases failed on the previous head and now pass alongside all six authorization controls (eight leaf cases total). Fresh managed Codex review found no accepted P0 findings.

The broader checkpoint-inclusive local race run did not complete green: an existing built-CLI abandonment fixture exceeded its unchanged 15-second deadline, then the package hit the unchanged 10-minute deadline. It recorded 191 passing leaf executions, one failure and one intentional skip before termination. The exact failed fixture passed once standalone (7.23 seconds) without changing its deadline; that diagnostic does not replace missing broad coverage or establish the original cause. Fresh vet and build passed on the follow-up. The earlier narrower race run and docs build above apply to the first head. Fresh CI passed on the follow-up, including full Go tests, Go coverage, Windows cancellation, Apple VM, connector lifecycles, scripts and docs (run 33465959137).

The live successful-admin proof requested by review remains unavailable: the current account is denied by the broker. No admin grant was changed and no AWS Mac host was allocated.

Current-main refresh (2026-09-01)

Mechanically refreshed onto c9cdc35987531d6f71c317693cb18cbbb0dbe8d9; the current head is abab2880c31f1d33fa06fa94baa4c3ae7a7cb1e8. The sole merge conflict was the old unreleased changelog entry. The finalized main changelog is retained byte-for-byte and this PR no longer changes it. All eight remaining implementation, test, and documentation files are byte-identical to the previously reviewed 6d503e20c525e7219d89b8ff539d00518f579fb0 head; the two-commit range comparison differs only by that removed changelog entry.

Fresh validation on the refreshed head:

  • GOMAXPROCS=4 go test -race ./internal/cli -run '^Test(Admin|CreateAWSAMICheckpointRejectsMissingBrokerAuthBeforeCloudInit$|Coordinator.*(Token|Auth)|GitHubLogin|Login|Whoami|WriteBrokerLogin)' -count=1 -json passed: 49 top-level tests, 61 leaf cases, no failures or skips. Package time was 113.074 seconds; the command exited 0 after 449.275 seconds including compilation and Go cleanup. The process was allowed to finish normally; no deadline was changed.
  • git diff --check origin/main...HEAD, node scripts/check-docs-links.mjs, and node scripts/build-docs-site.mjs passed.
  • Fresh managed Codex Autoreview of the complete refreshed branch completed with the configured P0 scope and no returned findings, rejected findings, or filtered findings. The source remained unchanged during validation.
  • Production remains +7/-4 (net +3), tests +105/-6, documentation +22/-17. There is no new authentication logic, configuration, permission, or deployment change in this refresh.

The earlier negative live-authentication evidence above applies to the original head. Exact-head validation is now terminal green: full CI and the required release check both passed on attempt 1; connector smokes, CodeQL, and docs visual proof also passed. The final check rollup has 24 successful checks, one neutral check, one skipped optional check, and no pending or failed checks. The successful GitHub-admin live proof remains outstanding: an already-granted immutable GitHub owner must succeed on a non-destructive admin route, alongside the nearest unauthorized-principal denial. Mocked tests and explicit-admin-token success are not substitutes. The known denied login was not retried, and no credential, grant, server configuration, or cloud resource was changed for this refresh. GitHub also still requires an independent approval. Auto-merge remains off while the live authorization proof is missing.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 1, 2026 02:38
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 8:20 PM ET / September 2, 2026, 00:20 UTC.

ClawSweeper review

What this changes

This PR lets coordinator-backed admin and image commands send the configured broker credential, including a GitHub login session, when no explicit admin token is configured while retaining explicit-token precedence.

Merge readiness

Blocked until stronger real behavior proof is added - 4 items remain

Keep open: the focused CLI change aligns with the existing coordinator authorization design, but this external PR still lacks real successful-path proof for the newly reachable GitHub-admin session flow.

Priority: P2
Reviewed head: abab2880c31f1d33fa06fa94baa4c3ae7a7cb1e8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-consistent, but missing deployed allowed-path proof prevents merge readiness for this authorization-boundary change.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the CLI now selects a normal broker session for an admin route, while the unchanged coordinator revalidates that session and derives admin from the immutable-owner grant before the final route gate. The added test uses an in-process server and the PR body explicitly lacks a successful granted-session result; the reported denial does not prove the newly allowed path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the CLI now selects a normal broker session for an admin route, while the unchanged coordinator revalidates that session and derives admin from the immutable-owner grant before the final route gate. The added test uses an in-process server and the PR body explicitly lacks a successful granted-session result; the reported denial does not prove the newly allowed path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Introduced CLI credential selection: The changed helper uses the normal broker credential unless an explicit admin token exists, disables the token command only for that explicit token, and fails early only when no authentication is configured.
Existing coordinator authorization boundary: The unchanged coordinator authenticates signed GitHub user tokens, revalidates membership, and computes admin status from the immutable owner grant before forwarding the request.
Final admin-route gate: After authentication, the coordinator injects trusted authorization headers; the fleet rejects admin routes unless that derived admin header is true.
Findings None None.
Security None None.

How this fits together

Crabbox’s CLI selects a broker credential before calling coordinator admin routes. The coordinator revalidates the credential, derives admin status from immutable GitHub-owner grants, and either permits or rejects the route.

flowchart LR
  A[Operator admin command] --> B[CLI credential selection]
  B --> C[Coordinator request]
  C --> D[GitHub session validation]
  D --> E[Admin-route authorization]
  E --> F[Admin operation]
  E --> G[403 rejection]
Loading

Decision needed

Question Recommendation
Should this authorization-boundary change wait for real granted-session proof, or be merged based on source review and mocked coverage alone? Require deployed proof: Keep the PR open until a granted immutable GitHub owner succeeds on a read-only admin route and the nearest ungranted principal is denied before provider I/O.

Why: The patch intentionally makes an existing server-side grant reachable from the CLI, and only a real coordinator can prove the final authorization effect for the newly allowed principal.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the CLI now selects a normal broker session for an admin route, while the unchanged coordinator revalidates that session and derives admin from the immutable-owner grant before the final route gate. The added test uses an in-process server and the PR body explicitly lacks a successful granted-session result; the reported denial does not prove the newly allowed path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - An allowed GitHub-admin session can now reach admin and image operations, but no redacted deployed-coordinator trace proves the granted principal succeeds while the nearest non-granted principal is rejected before provider I/O.
  • Complete next step (P2) - The remaining merge blocker is contributor-provided deployed authorization evidence, not a mechanical repair candidate.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused implementation delta production +7/-4; tests +105/-6; docs +22/-17 The branch is narrowly scoped to credential selection, regression coverage, and corresponding authorization documentation.

Merge-risk options

Maintainer options:

  1. Prove the final authorization effect (recommended)
    Add redacted terminal or runtime evidence that an already granted immutable GitHub owner reaches a non-destructive admin endpoint and that a non-granted session receives 403 before provider I/O.
  2. Merge with the deployment proof gap
    A maintainer may accept the existing source and mocked coverage while taking responsibility for unverified deployed grant configuration.

Technical review

Best possible solution:

Record a redacted real-coordinator run where an already granted immutable GitHub owner succeeds on a non-destructive admin route and a comparable ungranted session receives 403 without provider activity.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: the base helper rejected every admin call without an explicit admin token before the coordinator could evaluate a signed GitHub session. The deployed successful grant path has not been exercised.

Is this the best way to solve the issue?

Yes: retaining the coordinator as the sole authority and only changing CLI credential selection is the narrowest maintainable repair; it needs final-effect evidence before merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c9cdc3598753.

Labels

Label justifications:

  • P2: This is a bounded fix to established coordinator-admin behavior without evidence of an active outage or confirmed bypass.
  • merge-risk: 🚨 security-boundary: The branch changes which credentials may reach privileged coordinator routes, so deployed allow and deny behavior needs final-effect proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the CLI now selects a normal broker session for an admin route, while the unchanged coordinator revalidates that session and derives admin from the immutable-owner grant before the final route gate. The added test uses an in-process server and the PR body explicitly lacks a successful granted-session result; the reported denial does not prove the newly allowed path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Introduced CLI credential selection: The changed helper uses the normal broker credential unless an explicit admin token exists, disables the token command only for that explicit token, and fails early only when no authentication is configured. (internal/cli/admin.go:727, abab2880c31f)
  • Existing coordinator authorization boundary: The unchanged coordinator authenticates signed GitHub user tokens, revalidates membership, and computes admin status from the immutable owner grant before forwarding the request. (worker/src/auth.ts:123, c9cdc3598753)
  • Final admin-route gate: After authentication, the coordinator injects trusted authorization headers; the fleet rejects admin routes unless that derived admin header is true. (worker/src/coordinator-entry.ts:230, c9cdc3598753)
  • Regression coverage is transport-mocked: The new table test verifies credential precedence, token-command suppression, missing credentials, and a 403 response using an in-process HTTP server; it does not exercise the deployed coordinator’s GitHub grant path. (internal/cli/admin_test.go:17, abab2880c31f)
  • Authorization-area history: Current-main history shows repeated coordinator authentication work by steipete, including the merged GitHub OAuth retry hardening commit. (worker/src/auth.ts:69, 74c6bafde41e)
  • Submitted proof gap: The reviewed PR body reports green checks and a denied-session observation, but expressly states that successful live proof for an already granted GitHub owner remains outstanding. (abab2880c31f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for an already granted immutable GitHub owner and the nearest ungranted principal, showing rejection before provider I/O.
  • Post a redacted terminal trace or runtime log with endpoint and HTTP outcomes, then update the PR body for re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-01T02:43:30.119Z sha 97f85ab :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T03:27:14.404Z sha 6d503e2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T03:51:57.251Z sha 6d503e2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T03:58:42.979Z sha 6d503e2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T23:55:21.188Z sha abab288 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-02T00:00:04.683Z sha abab288 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/admin-github-session branch from 6d503e2 to abab288 Compare September 1, 2026 23:48
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch is mechanically refreshed onto current main at abab2880c31f1d33fa06fa94baa4c3ae7a7cb1e8. The changelog-only conflict is resolved by preserving the finalized main changelog; the eight remaining PR files are byte-identical to the previous reviewed head. Fresh focused race checks passed 49 top-level tests and 61 leaf cases with no failures or skips, documentation checks passed, and managed Codex review returned no findings in its configured P0 scope. Full new-head CI is running.

The PR body still explicitly records the missing successful live path for an already-granted GitHub admin principal. No grant or credential was changed, and the denied login was not retried. This refresh does not claim to close that proof gap or satisfy GitHub's independent approval requirement.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant