Repository navigation
Run Sonny's git in a sandbox where an agent may have written the repository - #603
Conversation
The eval answered every ask with allow, and the sandbox asks exactly before a write outside the run, so a fake HOME did not keep agents out of the real one: an S1 backup landed in the owner's ~/Backups. The ACP client and allow_waiting now deny a call that names a path in the real home outside the run's root, and allow the rest as before (escalations with no path, system paths, anything in the run). After each run, what changed in the real home a few levels down (past hidden folders and Library) goes to outside.txt and is said on stderr. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
A command's write targets can't be read from its words, so the check now denies what could reach the real home rather than only literal paths in it: a folder above it (cd /Users && mkdir me/x), a `..` that climbs out of the run from its shallowest folder, a `~name`, and a call listed cut (task asks whose arguments were bounded) or one Sonny offered only to deny. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…scripts Scanning a command's words can't stop a path built at run time (a Python call reading the real home from the user database), so the path check was a mitigation, not isolation. Runs now use an `eval` permissions row: the sandbox writes the agents' folders plus the run's backups and origin, the network (and with it every Unix socket) is off, and every call that would leave the sandbox comes to the eval, which allows only one plain call of ~/.agent/trigger or ~/.agent/memory (no operators, expansions or line breaks) and denies the rest, logging each answer. outside.txt stays as the after-run check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
An approved `~/.agent/trigger add --if CMD` ran CMD in the scheduler, outside every sandbox. The eval now allows each script's verbs with only the flags that run nothing else: no `--if`, no `--start`, no `memory schedule` or `cleanup`. Runs lived under /tmp/role, which every sandbox writes, so an agent could replace the run's copy of the build, its sources' script, or another run. They now live under ~/.role-eval. Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
The eval row's reviewer is the person, so a task's call parks until the eval answers it. Only settling answered them, after the lead's prompt returned, so a lead waiting on a task before answering waited out the prompt. Acp.ask now serves them every few seconds while a request is out. Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
shlex read `{watch,--if,'cmd'}` as one name, but Bash expands it into
`--if cmd`. The allowlist now tokenizes the command itself and refuses
anything Bash would expand, substitute or redirect: outside quotes a word
holds only letters, digits and `_./:,@%+-`; double quotes refuse `$`, a
backtick, a backslash and `!`.
Refs #521
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
The eval row extends `ask`, so start_task, subscriptions and triggers wait on the eval, which denied every call but a shell one: the lead could not delegate or subscribe, and the scores would have measured the harness. The eval now allows a task started in the lead's folder (its setup is the lead's read-only .agents/setup), a removal, a subscription and a trigger without `if` or `start`; new projects, panes, scripts, goals and the browser stay denied. Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
Sonny runs `git worktree add` outside the sandbox in the folder's repository, and a repository an agent made inside the lead's has hooks, config and filters the agent wrote. The day needs no folder, so a start naming one is denied (#597 tracks it in Sonny). Refs #521 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…sitory Git runs a repository's hooks and the programs its config names (an fsmonitor, a filter) even to list its files. A sandboxed agent can make a repository inside its folder and write those, and Sonny ran git there as the person: the file tree's status on viewing the folder, the seed's listing, and start_task's `git worktree add` with `folder`. `agent sandbox [--writable PATH]... [--network] -- COMMAND` runs one command in the sandbox a bot's commands run in, with no daemon, as Codex's `codex sandbox`. Sonny now runs those git calls through it: the tree's status and the seed's listings read-only, a task's worktree writing only the repository's git folder and the new worktree, with the lead's network, and a task's change check read-only before its worktree is removed with `--force` and its branch deleted with no hook. On a machine with no sandbox, where no agent is confined either, git runs as before. Fixes #597 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
With the network on, a sandbox reaches every Unix socket but those the daemon names, and agent sandbox has no daemon to name its own, so a hook could reach the daemon and run anything through it (Codex security review on #603). The sandbox now always runs off the network, where it can make no Unix socket at all (seccomp on Linux, Seatbelt on macOS). Sonny's worktree git loses only the network an LFS smudge would fetch with. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…and go Removing a worktree with --force skipped git's own refusal to remove one holding submodules, whose repositories go with it, and its status check, which counts submodule work whatever submodule.NAME.ignore says. Both now run in the sandbox before removal (Codex review on #603). A start whose branch agent/NAME was kept from an earlier task now fails before git runs, rather than deleting that branch while undoing a worktree add that could never have made it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…out confined The sandbox keeps a git folder read-only whole when its config includes other files or turns on per-worktree config, so a confined worktree add could not make its branch there (Codex review on #603). Sonny now makes the worktree with git running none of the repository's code (no checkout, hook or fsmonitor), then checks it out in the sandbox writing only the worktree and its own git folder. The checkout is what runs filters and the post-checkout hook; the shared git folder is never written from the sandbox. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…exit; submodule names as bytes agent sandbox ran its command without the hold a bot's command takes, so on Linux a commondir the command made, and the mount placeholders, stayed after it (Codex review on #603). It now holds them while the command runs and lets go on its own thread before exiting (Hold::release), since a drop's thread would end with the process. The submodule guard read index names as UTF-8 and skipped others; it now reads their bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
A daemon the CLI starts keeps .git, .agents and .codex (and an existing .aws) read-only at the top of every writable root; agent sandbox took none, so a command could leave hooks or agent settings in a checkout it was given (Codex review on #603). It now takes the same lists. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
macOS refuses the name with EILSEQ, so such a submodule can't be checked out there to lose; the test checks the case where it can. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
|
The Since then, main gained #601, a sky change. I merged main in (no conflicts; the Sonny tests and clippy pass), and that push starts a fresh CI run. If the sky test fails there again, I'll look into it as a real bug in that test. Generated by Claude Code |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90269dbe9c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: dc69406cce
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc69406cce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…e protected A sandbox keeps .agents and .codex read-only at its top, so a worktree of a repository that tracks them could not be checked out; the confined checkout now writes those the commit holds, as any tracked file (a hook or filter could already write those). And agent sandbox dropped the agent home's protection when it was not there yet, since it could not canonicalize it; it now keeps it by its parent's real path, so it can't be made. (Codex review on #603.) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 056af67054
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06b5aef837
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb464c5d82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…p clone is not set up A scheduler the system started after its HOME was deleted made HOME again opening its doorbell, so never saw it gone and ran on idle; it now checks before making anything. And backup counted as set up once ~/agent-home had a remote, though a clone made by hand has had no restore or first sync and the scheduler never syncs it; setup now needs that first sync too. (Codex code review on review-only #607, for #529.) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…-hue6af # Conflicts: # sonny/FEATURES.md
Fixes #597. Also fixes the two code findings from #607's review of #529 (scheduler, backup), listed at the end.
The hole
Git runs a repository's hooks and the programs its config names, even just to list its files. I checked this on git 2.43:
statusandls-filesruncore.fsmonitor, whilerev-parseandbranch --show-currentdon't.A sandboxed agent can
git inita repository inside its folder and write those hooks and settings. Sonny then ran git there as the person in three places:git statusruns when you view the folder, with no approval at all.ls-filesruns when a task's worktree is seeded.start_taskwithfolder. It runsgit worktree add, which fires thepost-checkouthook, fsmonitor and filters.The fix (George picked this on 11-01: run Sonny's git in the sandbox)
agent sandbox [--writable PATH]... -- COMMAND. It runs one command in the sandbox a bot's commands run in, with no daemon, like Codex'scodex sandbox.--writable, the command is read-only..git,.agentsand.codexat the top of each root.--networkflag existed, so that flag is gone.Hold::release.task::confined):The tree's
statusand the seed's two listings run read-only, with--no-optional-locks.A task's worktree is made in two steps.
worktree add --no-checkout -bitself. Git runs none of the repository's code here: no checkout, no hooks, no fsmonitor.checkout -f) in the sandbox. The sandbox can write only the worktree, its own git folder, and any.agents/.codexfolders the commit tracks. The network is off.The checkout is what runs filters and the post-checkout hook. The shared git folder is never written from the sandbox, so a config with an include or with per-worktree config still works.
A start whose branch
agent/NAMEwas kept from an earlier task now fails before git runs. Before, the undo deleted that kept branch.Before a removal without
discard, git's own checks run in the sandbox, since--forceskips them:--ignore-submodules=none;Removal then uses
worktree remove --force. The branch is deleted with no hooks.git --version.Also: #607's code findings for #529
~/agent-homeas set up as soon as it had a remote. It now also needs setup's first sync, so setup still restores the clone.Trade-off
A repository's own hooks and filters now run confined when Sonny checks out a task worktree. A legitimate
post-checkoutthat writes outside the worktree, or a filter that needs the network (an LFS smudge for an object the repository doesn't hold), makes the start fail with git's message and leaves nothing behind. Git behaves the same way when an agent runs it in its own sandbox, and Codex confines git the same way.Tests
what_an_agent_left_in_a_repository_runs_only_in_the_sandbox. It checks that:post-checkouthook runs but can't write outside the sandbox, even when the config has an include;.agents/AGENTS.mdis checked out.a_submodule_is_found_whatever_bytes_its_name_hasa_task_s_worktree_with_a_submodule_is_removed_only_with_discarda_task_named_for_a_kept_branch_does_not_start_or_delete_ita_scheduler_started_for_a_home_already_gone_makes_it_no_morea_clone_made_by_hand_is_not_set_up_until_setup_syncs_itsandboxsocket(AF_UNIX)fails with EPERM inside the sandbox;.git/hooksand.codexcan't be written;~/.agentcan't be made;commondirthe command makes is removed afterwards.cargo test -p sonnypasses, the CLI tests pass, and clippy is clean with-D warnings.Docs: a
docs/RUST_PROTOTYPE.mdSandbox paragraph, and thesonny/FEATURES.mdTasks, tree, triggers and backup rows.🤖 Generated with Claude Code