Skip to content

Sandbox: protect nested repositories' .git, not only the root's #414

Closed

Description

@lydakis

The daemon's sandbox (src/sandbox.rs, PROTECTED / GIT_PROTECTED) keeps .git read-only only at the top of a writable root. When a bot's root is a folder that holds repositories, which is common for a workspace folder that isn't git itself (ws/src/api, ws/src/web, …), a sandboxed bot can write ws/src/api/.git/hooks/* and .git/config (core.fsmonitor, filters, core.hooksPath…). Anything that later runs git there as the person then runs the bot's program outside the sandbox:

Precedent:

  • Codex: protects .git at the top of a writable root only, so it has the same gap.
  • Claude Code: its sandbox reportedly denies writes to .git/hooks and .git/config at any depth.

Open questions, to discuss before any daemon change:

  • How to find nested .git folders cheaply in very large workspaces with deep trees and big caches. Options are scanning at sandbox setup, a depth limit, or seatbelt regex rules on macOS and their Linux equivalent.
  • Whether a .git the bot makes after the sandbox starts needs covering, as PROTECTED_MISSING does at the root.

Until then, Sonny could run git worktree add for a folder repository with hooks off (-c core.hooksPath=/dev/null). That only covers the reported vector: filters and fsmonitor stay open, so it is a stopgap, not the fix.

Activity

  1. added a commit that references this issue on Oct 30, 2026
    17d6ece
  2. added a commit that references this issue on Oct 30, 2026
    0f8e0e9
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