Skip to content

start_task in a nested repository runs that repository's hooks and config outside the sandbox #597

Closed

Description

@lydakis

Found by Codex's code review on #590 (the role eval), and it applies to Sonny itself.

What happens. The sandbox protects only the .git at the top of each writable root (src/sandbox.rs). A sandboxed agent can make a repository inside its folder (nested/) and write nested/.git/hooks/post-checkout, or nested/.git/config with core.fsmonitor, a smudge filter, and so on. start_task with folder: "nested" then runs git worktree add in that repository (sonny/src/task.rs, the git(here, &["worktree", "add", ...]) call). That git runs outside any sandbox, as the person. Git runs post-checkout on worktree add, and the config's fsmonitor and filters also run as the person.

Who it reaches. Any row where start_task is allowed without the person seeing it: a model reviewer approving a start, or full. In ask the person approves, but nothing on the card says the folder's git is agent-written.

Precedent in this repo. sonny/src/snapshot.rs and sonny/src/home.rs already pass -c core.hooksPath=/dev/null to the git they run. task.rs doesn't. That flag alone doesn't cover core.fsmonitor, filters, core.sshCommand, or the rest of the repository's own config.

Options

  1. Only start tasks at a folder whose repository's .git is kept from the sandbox (the lead's own repository). A nested one would need the person, or would be refused.
  2. Run that git with hooks off and the repository's config neutralized (-c core.hooksPath=/dev/null -c core.fsmonitor= ...). This is partial, because config has many command-running keys.
  3. Extend the sandbox's PROTECTED names to .git at any depth (Codex protects only the top level too).

The role eval (#590) denies start_task with folder for now. This is a Sonny decision, so it's here for discussion first.

Activity

  1. lydakis commented on Nov 1, 2026

    @lydakis
    OwnerAuthor

    Two more points and a revised recommendation.

    Fourth option: run Sonny's own git worktree add inside the agent's sandbox, allowed to write only the new worktree path and that repository's .git. A hook or config command then runs with no more rights than the agent already has.

    Why not option 1 alone: start_task with folder supports a lead in a folder that holds several repositories (for example, a lead in ~/Developer). Refusing nested repositories would break that.

    Why not option 3 alone: on Linux, protection is bound per path when a sandbox starts. A single command can git init nested and write its hook before any later sandbox would protect it, so the hook is already there when Sonny's git runs.

    The same reasoning already exists for setup. task.rs runs only the lead's own .agents/setup, never a nested repository's, because the nested one isn't kept from the lead's sandbox. The worktree's git needs the same rule.

    Recommendation: option 4.


    Generated by Claude Code

  2. added a commit that references this issue on Nov 1, 2026
    dc69406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions