Skip to content

Sandbox: a parallel shell batch builds one policy for all its commands #473

Open

Description

@lydakis

Split out of #96, which collected three check-then-use races on a sandboxed bot's roots. Two of them are fixed by #1197 (narrowed 11-20):

What is left: batched shell calls (#291)

execute_parallel in src/server/turn.rs builds the sandbox policy once (self.sandbox(record, workspace)) and hands the same Arc<Policy> to every shell command in the batch (run_parallel). The lone path builds it per call. A command early in a batch that swaps a link inside a root can change what a later command in the same batch is allowed to reach, since the later command runs under a policy resolved before the swap.

It needs the bot to race its own sandbox inside one batch, so it is not ordinary use. The precedent is Codex and bubblewrap: open by descriptor, don't re-resolve.

Fix: build the policy per call, as the lone path does, or check that the roots it resolved still resolve the same before each command starts. Measure sandboxed command start at the low end and at a wide batch, since #1197 cut it to about 4.5 ms with 15 worktrees.

Done when each command in a batch runs under a policy resolved for it, with a test that swaps a link between two commands of one batch.

Activity

  1. changed the title [-]Sandbox: check-then-use races on a sandboxed bot's roots[/-] [+]Sandbox: a parallel shell batch builds one policy for all its commands[/+] on Nov 20, 2026
  2. lydakis commented on Nov 20, 2026

    @lydakis
    OwnerAuthor

    Narrowed against main e08a1cb. #1197 fixed two of the three races: new bots' folders are kept as checked when the request is read, and apply_patch removals run inside the sandbox's helper. What's left is the parallel shell batch, which still shares one policy across its commands (execute_parallel in src/server/turn.rs). The title and body now cover only that.


    Generated by Claude Code

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