Skip to content

fix(security): host sandbox applies no output, process or tmpfs limits and binds the wrong repository root #663

Closed

Description

@dan-petty

Summary

Found in the release/v0.2.23 review (line numbers at 7fdaa9d).

The bubblewrap host sandbox runs LLM-generated verification criteria, but applies none of its policy's resource limits.

  1. Output is unbounded until the process exits. proc.communicate() buffers all output, and max_output_bytes is applied only afterwards (src/devops_cli/sandbox/host.py:61-83). A criterion such as cat /dev/zero passes validate_criteria_command. It produced 328M characters and 1.27 GB RSS in one second, so the default 5-second timeout means several GB.
  2. Process and tmpfs limits are ignored. The policy's pids_limit and the tmpfs size=64m,noexec options are never passed to bwrap (host.py:95-96, :158-159; src/devops_cli/sandbox/models.py:332-336). A fork loop such as python3 -c "import os\nwhile 1: os.fork()" passes the AST check and can exhaust host PIDs for the whole timeout.
  3. The wrong directory is bound. The sandbox binds find_worktree_root(cwd), which returns the top-most directory holding .git or pyproject.toml (host.py:150-162).
    • For a clone nested under a workspace (repos/<clone>), that exposes the whole workspace to the reviewed repository's code, .env files and sibling repositories included.
    • For a linked worktree, the git directory that its .git file points to is not bound, so every git grep/log/diff criterion fails with "not a git repository".
    • test_host_sandbox_cannot_list_home uses tmp_path, so it never exercises either case.

Remediation Plan

  1. Stream stdout and stderr with a byte cap, and kill the process group once the cap is exceeded.
  2. Enforce pids_limit (for example an RLIMIT_NPROC set before exec) and pass tmpfs size limits to bwrap. Document any option bwrap cannot express.
  3. Bind the nearest repository root of the reviewed tree. For linked worktrees, also bind the common git directory read-only.
  4. Add tests:
    • output over the cap is cut off and the process is killed;
    • the process limit holds;
    • a nested clone cannot read its parent;
    • git criteria work in a linked worktree.

Activity

  1. added this to the v0.2.23 milestone on Sep 28, 2026
  2. added
    type/security
    scope/security
    priority/p1-high
    on Sep 28, 2026
  3. dan-petty commented on Sep 28, 2026

    @dan-petty
    OwnerAuthor

    Closed by #676, merged into release/v0.2.23.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

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

    priority/p1-highscope/securitytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions