Repository navigation
fix(sandbox): harden the git tool, which runs on the host, when a command consumer is on (#748) - #873
Merged
Merged
Conversation
…mand consumer is on (#748) Always pass -c core.fsmonitor=false. With a command consumer on also pin core.hooksPath to the read-only <repo>/.git/hooks of a real .git directory (/dev/null otherwise), set GIT_CONFIG_NOSYSTEM=1 and pass --no-ext-diff --no-textconv to diff, so a core.hooksPath into the writable workspace (husky style) and a core.fsmonitor command no longer run on the host through the tool, while the owner's installed hooks still do. The run_command and job_start summaries and tole doctor tell the model that git writes fail in the sandbox and to use the git tool.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
…sted at start-up, and say what the hardening does not cover (#748) With a command consumer on, the tool trusts only a real .git directory that enclosed its workdir when it was built (a snapshot, re-checked per call against a swap) and refuses a bare-repository workdir, so a repository a sandboxed command created (hook, filter, gpg.program, .gitattributes) never runs on the host. Docs state the residuals: owner hooks run workspace content, an owner include.path into the workspace, GIT_CONFIG_NOSYSTEM side effects. The doctor line no longer claims hooks are pinned in the refused case. The fixture no longer calls set_var from threads.
…trusting a start-up snapshot (#748) With a command consumer on, the git tool now pins core.hooksPath=/dev/null and --no-verify, sets GIT_CONFIG_NOSYSTEM=1, passes --ignore-submodules=all to status and diff, and before every op asks git which git directory it uses. It refuses anything but a plain .git directory at the work tree root (not bare, not a linked worktree, submodule gitdir file or separate git dir), then reads that config without running anything and refuses any key outside an allowlist of inert ones. add is refused while the index holds a submodule entry. The start-up snapshot is removed.
The spawned git re-reads .git/config after the vet, so a still-running sandboxed process that writes it in that window can get the in-flight call to execute planted content; later calls refuse. Also document that a sandbox-written .gitattributes can trigger the owner's global filter.lfs command on attacker-influenced input, and that gc.autodetach can leave a detached maintenance run that outlives the vet. Comments and docs only.
| for k in [ | ||
| "GIT_DIR", | ||
| "GIT_WORK_TREE", | ||
| "GIT_COMMON_DIR", |
5 of 8 tasks
…nd consumer is on (#748) The vet reads one file, <gitdir>/config, but git also takes config and programs from the process environment: GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_CONFIG, GIT_CONFIG_COUNT/KEY_n/VALUE_n, GIT_CONFIG_PARAMETERS, HOME and XDG_CONFIG_HOME, GIT_EXEC_PATH, GIT_ATTR_SOURCE, LD_PRELOAD and more. A tole started by a sandboxed command inherits whatever that command set, so the host-side tool could run a filter or program the vet never saw. With a consumer on, git now gets only PATH (absolute entries), locale, TZ, TERM, the temp dir, HOME from the account's passwd entry and GIT_CONFIG_NOSYSTEM / GIT_TERMINAL_PROMPT=0. Behaviour with no consumer is unchanged. Tests run the production GitTool::new() path in a child process under each hostile variable; none may fire a marker.
…ptors, when a command consumer is on (#748) A tole started by a sandboxed command inherits that command's PATH, and the host-side tool resolved `git` (and the sh, gpg, ssh and git-* helpers git spawns) against it, so a planted program in a writable directory ran with no vet involved. With a consumer on, git is now looked up only in /usr/local/bin, /usr/bin, /bin and /opt/homebrew/bin (never under the workdir, the temp dir or a home), that list is also the PATH git gets, and no git there is a clear refusal. An embedder with git elsewhere sets an absolute GitTool::with_bin. Also: no file descriptor above stderr is inherited, GIT_AUTHOR_*, GIT_COMMITTER_*, USER, LOGNAME and TMPDIR are no longer passed, the passwd home is None on non-unix hosts, and a sandbox grant that holds the account's passwd home is refused like $HOME (the git tool reads its global config there).
This was referenced Nov 16, 2026
ajianaz
added a commit
that referenced
this pull request
Dec 2, 2026
…26-12-02) (#808) (#1389) The Open work by area table of docs/epics.md carried its 2026-11-15 stamp: closed issues were still listed as open, the container section predated the first nightly publish, and Track F was absent. The table is rewritten from a one-by-one re-check of the tracker on 2026-12-02: closed items moved out, the container row records the daily green nightly and the public GHCR package (anonymous pull verified, plus a local arm64 build and smoke run of the committed Dockerfile), Track F carries its model-first slices and the F1 gate that is next. The owner-decision list keeps only the decisions still open and records the decided ones. Stale passages elsewhere in the file were corrected in the same change: epic #941 and #949 states, #781/#812/#583/#600/#601/#873/#878 closed, the sandbox default flip shipped in 0.12.0, and the E4 remaining-order line rewritten to what remains parked or deferred (#875, the #748 cgroup limits). Refs #808.
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.
What
The
gittool (status, diff, add, commit;Risk::Writethrough the Approver) runs on the host, outside the command sandbox, and is how a model commits when.gitis read-only in the sandbox. It was not hardened. This PR hardens it when a command consumer is on (no new tool, no writable.git, nogit = "write"option) and points the model and the owner at it. Refs #748.Why
The tool runs on the HOST and git executes what the repository config, hooks, attributes, environment and
PATHname. With the consumers on, a sandboxed command cannot write.gitin a repository that existed at launch (#849), but: the owner's config can namecore.hooksPathscripts inside the writable workspace or acore.fsmonitorcommand; in a workspace with no repository a sandboxed command cangit initand plant a hook, afilter.x.clean, agpg.program, a bare layout or a nested repository; and a tole process started by a sandboxed command inherits an environment andPATHthat name config files and programs. A start-up snapshot of "the repository that existed" was tried and dropped: the tool is rebuilt per serve session, cron run, resume and child, so a repository planted in an earlier session looks like the owner's. The rule: with any command consumer on, no host-side code execution is reachable from state a sandboxed command can write, whenever and by whomever the repository was created.Changes
integrations/git.rs, invocation: ALWAYS-c core.fsmonitor=false. With any command consumer on (Consumer::ALL, cron included):-c core.hooksPath=/dev/nulland--no-verifyon commit (no hook runs for a commit made through the tool, the owner's own pre-commit and commit-msg included; a human's owngit commitstill runs them); a FIXED git binary andPATH(gitis looked up in/usr/local/bin,/usr/bin,/binand/opt/homebrew/binonly, never under the workdir, the temp dir,$HOMEor the account home; that list is also thePATHgit's helpers get; no git there is a refusal naming the directories; an embedder with git elsewhere uses an absoluteGitTool::with_bin; the CLI has no setting, so the owner links git into a trusted directory); no inherited descriptor above stderr (close-on-exec, Linux 5.11+); an ALLOWLIST environment instead of the tole process's (locale,TZ,TERM,HOMEfrom the account's passwd entry and never$HOME,GIT_CONFIG_NOSYSTEM=1,GIT_TERMINAL_PROMPT=0;GIT_AUTHOR_*,GIT_COMMITTER_*,USER,LOGNAME,TMPDIRand everything else are dropped, so identity comes only from config or the passwd entry);--no-ext-diff --no-textconvon diff;--ignore-submodules=allon status and diff. With no consumer on the tool behaves as before apart fromcore.fsmonitor.integrations/git.rs, per-call vet (vet_repository, fail closed, no snapshot): before every opgit rev-parse(same hardened options) says which git directory git really uses. The tool refuses unless it is a plain.gitDIRECTORY at the work tree root, not bare, with the common dir equal to it (a bare layout including a bare ancestor, a linked worktree, a submodule gitdir file and a separate git dir are refused). Thengit config --file <gitdir>/config --list -z(no includes followed, nothing executed) is checked against an ALLOWLIST of inert keys (inert_key): any other key (filter.*,include.*,alias.*,core.fsmonitor,core.hooksPath,core.sshCommand,core.worktree,gpg.*,credential.*,extensions.*, unknown keys) makes the tool refuse, naming the key and the way out.addis also refused while the index holds a submodule entry.sandbox.rs:check_grantalso refuses a grant that holds the passwd home, as it does for$HOME, so~/.gitconfigis never sandbox-writable.paths.rs:account_home()(None on non-unix hosts; the command sandbox is Linux only).run_command.rs,jobs.rs,sandbox/command.rs: summaries and onetole doctorline say git writes fail inside the sandbox, that thegittool is the way out, that hooks are off for its commits, and when it refuses.tole-corestays platform-agnostic; no newRisk, no new tool; the Destructive enforcement layers are untouched.job_startfrom an earlier turn, a long command) that writes the config between the vet and the spawn can get that SAME call to execute it, because the spawned git re-reads.git/configafter the vet (later calls refuse; the window is narrow and there is no cheap fix for wildcard keys); a sandbox-written.gitattributesor.git/info/attributeswith* filter=lfstriggers the OWNER's globalfilter.lfs.*command;gc.autodetachcan leave a detachedgit maintenance run --autothat outlives the vet; an owner (global)include.pathinto the workspace is not vetted; a program the owner's global config names is looked up in the fixedPATH, and a process run with another$HOMEuses the account's global config;GIT_CONFIG_NOSYSTEM=1drops/etc/gitconfigand can cause "dubious ownership" or a missing identity.Callers and impact (grep, each checked):
GitTool::executeis the only place the tool spawns git;GitTool::new().in_dir(..)is howtool_roster.rsregisters it;GitToolhas no struct-literal users outsidegit.rs(the new fields are private;with_envandwith_binare additive public API);command_lineand the approvaldescribestring are unchanged;check_grantapplies to every grant (command consumers, MCP server profiles, cron). Behaviour change with a consumer on: no hook runs for the tool's commits; the tool refuses a non-plain layout, a config with a non-inert key, or a host without git in the trusted directories; a workspace that holds the passwd home is refused. Tests to rerun:integrations::gitunit tests,git_tool_hardening,git_tool_default,command_tests,command_sandbox*,layering.Testing
git_tool_hardening(consumers on): an owner repository with inert config works and no hook runs; a repository planted before a freshly built tool is refused; bare layout in an ancestor, a bare workdir and a linked worktree are refused; each key that names a program or a file is refused and its marker never fires; a nested repository with a hostile filter never runs.git_tool_default(no consumer): the tool does not refuse and fsmonitor never runs. Unit tests: exactinvocation()argv,inert_keyallow and deny lists, the environment allowlist, acheck_granttest for the passwd home, an inherited-descriptor test.a_hostile_process_environment_never_reaches_gitruns the productionGitTool::new()path in a child process under hostileGIT_CONFIG_*,HOMEandXDG_CONFIG_HOME(noset_varin the test process; a no-hostile-env control round must seeaddandcommitsucceed).a_hostile_path_never_supplies_the_git_binaryputs fakegitandshon hostile absolutePATHentries inside the workdir and a temp dir: no marker, the real git commits.cargo fmt --all;cargo clippy --workspace --all-targets -- -D warnings(default and--no-default-features);cargo clippy -p tole-core;cargo check -p tole-core --no-default-features --tests;cargo test --workspaceandcargo test -p tole-core(default and--no-default-features --features shell-tools) withTOLE_REQUIRE_BWRAP=1: green. CI: all checks green, Cora Review "No issues found" on the final head. The one Test failure seen on this head wastui_steers_queues_and_returns_the_queue_on_cancel, a known flaky TUI test; the failed job was re-run and passed.PATHresolvesgit) shaped this PR; each is fixed with a fail-first test. cora is not installed here, soscripts/review-local.shwas not run; the CI Cora Review is the gate.