feat(sandbox): run gh outside the sandbox so keyring auth works#706
Merged
Conversation
gh authenticates via the OS keyring, which the in-process sandbox blocks, so gh commands failed with keyring / "not logged in" errors. Excluding gh from the sandbox lets it use the real host auth. Confirmation is safe-by-default: permissions.ask matches Bash(gh *) so every gh command prompts unless a more-specific read-only allow rule (gh pr view, gh * list, ...) exempts it — so every destructive or unknown gh subcommand is confirmed. gh auth token / gh auth refresh stay denied so the token cannot be dumped. Generated-by: Claude Code (Opus 4.8)
a05abdb to
b44c02f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ghauthenticates via the OS keyring, which the in-process sandbox blocks —so sandboxed
ghcalls fail with keyring / "not logged in" errors. This addssandbox.excludedCommands: ["gh *"]to the shipped Claude baseline soghruns against the real host auth.
ghwrite/destructivesubcommands remain gated by
permissions.ask, andgh auth token/gh auth refreshstay inpermissions.denyso the token can't be dumped.Type of change
tools/*/withpyproject.toml) — sandbox-lint validatordocs/,README.md,CONTRIBUTING.md)Test plan
prek run --files <changed>passes (markdownlint, typos, lychee, ruff, mypy, workspace pytest, spec-validate)uv run --project tools/sandbox-lint pytest— 64 passed (2 new: baseline excludes gh;excludedCommandsset-semantics)sandbox-lintreports the framework's own settings match the updated baselineRFC-AI-0004 compliance
ghmutations stay gated onpermissions.ask; no new auto-approved mutationLinked issues
Notes for reviewers
ghhost accessoutside the sandbox. That is the point —
ghcannot reach the OS keyring whilesandboxed. The trade-off is bounded by (a)
gh auth token/refreshdenied,(b) all
ghwrites behindask, (c)credentials.envVarsstill denyGH_TOKEN/GITHUB_TOKENfor other sandboxed commands. The existingcredentialscommentin
secure-agent-setup.mdalready assumed "ghis sandbox-bypassed"; this makesthat true.
agent-guardis deny-only and can't express"ask + run-outside-sandbox";
excludedCommandsis the idiomatic, harness-enforced(deterministic) mechanism. Confirmation stays as the existing curated
asklistrather than a blanket
gh *ask, which would prompt on everygh pr viewin thepr-management skills.
the OS-level clean-env sandbox, which already runs
ghwith the host keyring), andsandbox-lint --opencodealready requirespermission.bashto default toask/deny, soghwrites prompt by default. Documented rather than adding aknob that doesn't exist.
Generated-by: Claude Code (Opus 4.8)