Repository navigation
fix(tools): derive HTTPS identity from the host grant, drop provider tables - #412
Merged
Merged
Conversation
Spawn policy no longer keys off gh or github.com. A host(...) allow fills HTTPS credentials on the host via git credential, rewrites git@<host>: remotes to HTTPS (SSH cannot use CONNECT), and serves those hosts through a spawn-local git helper. Git-dir writes follow git frontends, not a forge name. GH_TOKEN remains only as an adapter for HTTPS CLIs that do not speak git-credential.
`needs_git_writes` keyed off the leading executable of the command line, so a git write in any later segment was denied: `make release && git push` lost the carve-out because `make` led the line. Scan every segment instead, split on the shell operators that start a new command. Frontends that shell out to git are deliberately still not enumerated. Verified against real `gh` in the sandbox: a frontend needs `.git` writes only to auto-push a branch, which it cannot do without a TTY to prompt on, so the working shape is an explicit `git push` — which this rule already covers, including when the two are chained in one command line. Also stop `.git/hooks` being writable when the carve-out is lifted. Hooks are the one part of `.git` that is executed rather than read, and one written inside the sandbox runs with the user's full privileges the next time they use git on the host. Publishing never writes one.
mohitranka
added a commit
that referenced
this pull request
Aug 21, 2026
…tables (#412) * refactor(tools): project HTTPS identity from the host grant Spawn policy no longer keys off gh or github.com. A host(...) allow fills HTTPS credentials on the host via git credential, rewrites git@<host>: remotes to HTTPS (SSH cannot use CONNECT), and serves those hosts through a spawn-local git helper. Git-dir writes follow git frontends, not a forge name. GH_TOKEN remains only as an adapter for HTTPS CLIs that do not speak git-credential. * fix(tools): detect git writes per command segment, protect .git/hooks `needs_git_writes` keyed off the leading executable of the command line, so a git write in any later segment was denied: `make release && git push` lost the carve-out because `make` led the line. Scan every segment instead, split on the shell operators that start a new command. Frontends that shell out to git are deliberately still not enumerated. Verified against real `gh` in the sandbox: a frontend needs `.git` writes only to auto-push a branch, which it cannot do without a TTY to prompt on, so the working shape is an explicit `git push` — which this rule already covers, including when the two are chained in one command line. Also stop `.git/hooks` being writable when the carve-out is lifted. Hooks are the one part of `.git` that is executed rather than read, and one written inside the sandbox runs with the user's full privileges the next time they use git on the host. Publishing never writes one.
mohitranka
added a commit
that referenced
this pull request
Sep 11, 2026
…tables (#412) * refactor(tools): project HTTPS identity from the host grant Spawn policy no longer keys off gh or github.com. A host(...) allow fills HTTPS credentials on the host via git credential, rewrites git@<host>: remotes to HTTPS (SSH cannot use CONNECT), and serves those hosts through a spawn-local git helper. Git-dir writes follow git frontends, not a forge name. GH_TOKEN remains only as an adapter for HTTPS CLIs that do not speak git-credential. * fix(tools): detect git writes per command segment, protect .git/hooks `needs_git_writes` keyed off the leading executable of the command line, so a git write in any later segment was denied: `make release && git push` lost the carve-out because `make` led the line. Scan every segment instead, split on the shell operators that start a new command. Frontends that shell out to git are deliberately still not enumerated. Verified against real `gh` in the sandbox: a frontend needs `.git` writes only to auto-push a branch, which it cannot do without a TTY to prompt on, so the working shape is an explicit `git push` — which this rule already covers, including when the two are chained in one command line. Also stop `.git/hooks` being writable when the carve-out is lifted. Hooks are the one part of `.git` that is executed rather than read, and one written inside the sandbox runs with the user's full privileges the next time they use git on the host. Publishing never writes one.
mohitranka
added a commit
that referenced
this pull request
Sep 11, 2026
…tables (#412) * refactor(tools): project HTTPS identity from the host grant Spawn policy no longer keys off gh or github.com. A host(...) allow fills HTTPS credentials on the host via git credential, rewrites git@<host>: remotes to HTTPS (SSH cannot use CONNECT), and serves those hosts through a spawn-local git helper. Git-dir writes follow git frontends, not a forge name. GH_TOKEN remains only as an adapter for HTTPS CLIs that do not speak git-credential. * fix(tools): detect git writes per command segment, protect .git/hooks `needs_git_writes` keyed off the leading executable of the command line, so a git write in any later segment was denied: `make release && git push` lost the carve-out because `make` led the line. Scan every segment instead, split on the shell operators that start a new command. Frontends that shell out to git are deliberately still not enumerated. Verified against real `gh` in the sandbox: a frontend needs `.git` writes only to auto-push a branch, which it cannot do without a TTY to prompt on, so the working shape is an explicit `git push` — which this rule already covers, including when the two are chained in one command line. Also stop `.git/hooks` being writable when the carve-out is lifted. Hooks are the one part of `.git` that is executed rather than read, and one written inside the sandbox runs with the user's full privileges the next time they use git on the host. Publishing never writes one.
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.
Follow-up to #411. Removes the last provider-specific tables from confined-spawn credential projection, and fixes two
.gitpolicy bugs found while verifyingghagainst the real sandbox.Identity is derived from the granted host
https_cli_envmapped hosts to credential env vars with a hardcoded table (github.com→GH_TOKEN/GITHUB_TOKEN,gitlab.com→GITLAB_TOKEN, everything else → nothing). Replaced bytoken_env_name, which uppercases the first DNS label of the granted host:example.com→EXAMPLE_TOKEN,my-git.internal→MY_GIT_TOKEN, bare IPs → none. Self-hosted forges now get a token env var; GitHub getsGITHUB_TOKENas a consequence of the rule rather than a special case.Also isolates
XDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOMEinto the spawn-local identity dir, so an HTTPS CLI does not fall through to the host config and OS secret store — which is blocked in-sandbox and produced a confusing half-authenticated state.No provider name drives behavior anywhere in the codebase after this.
.gitwrites are detected per command segmentneeds_git_writeskeyed off the leading executable of the whole command line, so a git write in any later segment was denied —make release && git pushlost the carve-out becausemakeled the line. It now scans every segment, split on the shell operators that start a new command.Frontends that shell out to git are deliberately not enumerated. Verified against real
ghin the sandbox: a frontend needs.gitwrites only to auto-push a branch, which it cannot do without a TTY to prompt on. The working shape is an explicitgit push, which this rule already covers, including chained in one command line..git/hooksstays read-only even for publish spawnsHooks are the one part of
.gitthat is executed rather than read, and one written inside the sandbox runs with the user's full privileges the next time they use git outside it. Publishing never writes a hook, so the carve-out now stops short of them. This closes a hole that was open before this branch too.Verification
Driven against real
gh2.97 through the actual sandbox and egress proxy with a**.github.comgrant. Pushes went to a local bare remote; nothing was sent to GitHub and no PR was created by the probes.gh auth status✓ Logged in to github.com account … (GITHUB_TOKEN)— projected, not host keyringgh api user --jq .logingit commit --allow-emptygit push -u local HEAD.git/configwrite)gh pr create --head feature --dry-runWould have created a Pull Request with: …git push local HEAD && gh pr create … --dry-rungitgh --version && printf x > .git/refs/heads/sneakprintf x > .git/hooks/post-checkoutcargo fmt --all -- --checkclean,cargo clippy --all-targetszero warnings,cargo test --workspace2211 passed / 0 failed.Known gap
GITHUB_PERSONAL_ACCESS_TOKENreaches confined spawns via host environment inheritance rather than projection. That is an inheritance question inPROVIDER_CREDENTIAL_ENV, unrelated to the tables removed here, and is left for a separate change.