Skip to content

feat(cli): bubblewrap confinement for criteria commands and one sandbox policy #592

Closed

Description

@dan-petty

Context & Rationale

Executable Verification Criteria landed (#432): execute_criterion_command (src/devops_cli/ai/review/review_environment.py:230-295) runs model-authored commands in the reviewed repo for findings reaching verification.py:1229, confined only by a string allowlist and a process group. Its docstrings promise a "closed read-only allowlist" (:193) and a "bounded subprocess sandbox" (:231), yet the validator accepts reads anywhere (cat /etc/passwd, find /), writes via python3 -c, python3 -m pip install, and pytest, which runs the reviewed branch's code. Separately, container controls are literal SDK kwargs that disagree: sandbox/engine.py:231-235 sets read_only and a noexec tmpfs; docker/sandbox.py:266-270, the runner behind devops docker and devops test, sets neither; commands/sandbox.py:183-188 prints a third hand-typed copy. vibes renders one frozen policy with per-engine argv tests (examples/ephemeral-container-sandbox/sandbox.py:59-76,266-303).

Scope & Deliverables

  • Context & Rationale*: Executable Verification Criteria landed (feat(cli): executable verification criteria #432): execute_criterion_command (src/devops_cli/ai/review/review_environment.py:230-295) runs model-authored commands in the reviewed repo for findings reaching verification.py:1229, confined only by a string allowlist and a process group. Its docstrings promise a "closed read-only allowlist" (:193) and a "bounded subprocess sandbox" (:231), yet the validator accepts reads anywhere (cat /etc/passwd, find /), writes via python3 -c, python3 -m pip install, and pytest, which runs the reviewed branch's code. Separately, container controls are literal SDK kwargs that disagree: sandbox/engine.py:231-235 sets read_only and a noexec tmpfs; docker/sandbox.py:266-270, the runner behind devops docker and devops test, sets neither; commands/sandbox.py:183-188 prints a third hand-typed copy. vibes renders one frozen policy with per-engine argv tests (examples/ephemeral-container-sandbox/sandbox.py:59-76,266-303).
  • Deliverable*: PR1: adopt bubblewrap behind a narrow HostSandbox seam and route execute_criterion_command through it: --unshare-all --new-session --die-with-parent --clearenv with an explicit environment, --ro-bind of /usr (plus lib/lib64/bin symlinks) and the repo root, --tmpfs /tmp, no $HOME, $XDG_RUNTIME_DIR or session bus, so keyring, gh and devops credentials stay unreachable. Live tests: the child reads the repo, cannot list /home or write the repo, and connect to a non-loopback address fails. Add bubblewrap to .devcontainer/Dockerfile (installed today only incidentally) and document it as a host requirement. PR2: a frozen Pydantic SandboxPolicy in sandbox/models.py consumed by both _build_create_kwargs and HostSandbox, tested for identical security kwargs from both builders; delete the uncalled SandboxNetworkConfig.to_docker_args (models.py:278) and its tests. The drafted Sandbox Enforcement Audit (devops sandbox audit) reads DECLARED from this policy; whichever lands first deletes the dry-run literal. The harness Shell opts in once it has a production caller.
  • Constraint*: Fail closed with a CriterionExecutionResult error, never unconfined, when bwrap is missing or namespaces are refused. bwrap network is all-or-nothing and Landlock filters TCP ports, not addresses, so criteria get no network and private-range or metadata egress denial stays in the proxy and NetworkPolicy tiers, never reported as host-enforced. Do not port generate_bpf_c or generate_tetragon_policy: BPF LSM is not in this kernel's boot LSM list, and the cluster integration is Falco (k8s/security_stream.py), which detects rather than denies. Denials are not SARIF: they have no source location. No docker run/podman run argv renderer: execution stays on the Docker SDK. No maintained Python Landlock binding exists; revisit when one does.
  • Measured*: uv run --no-sync python over validate_criteria_command accepted cat /etc/passwd, find / -name '*.pem', python3 -c with write_text, and python3 -m pip install foo. bwrap --unshare-all --ro-bind /usr ... --ro-bind <ws> /work: repo read succeeds, ls /home exits 2, write fails read-only, TCP connect errno 101. zcat /proc/config.gz | grep -E '^CONFIG_(BPF_LSM|LSM)=': CONFIG_BPF_LSM=y, CONFIG_LSM without bpf. PyPI JSON for landlock via urllib.request: latest 1.0.0.dev5 (pre-release).
  • Source*: vibes patterns/kernel-enforced-lsm-sandbox-containment.md, examples/ephemeral-container-sandbox/sandbox.py, examples/ephemeral-container-sandbox/test_sandbox.py, examples/ebpf-lsm-kernel-gate/lsm_gate.py, examples/ebpf-lsm-kernel-gate/README.md, observations/systems/34-ebpf-lsm-kernel-gates-and-dynamic-containment-fuzzing.md

Strategic Alignment

  • Milestone: v0.2.23 (devops ai Review Quality, LLM Routing & Multi-Language Validation)
  • Roadmap Reference: docs/ROADMAP.md

Activity

  1. added this to the v0.2.23 milestone on Sep 25, 2026
  2. added
    type/feature
    scope/cli
    priority/p0-critical
    on Sep 25, 2026
  3. dan-petty commented on Sep 27, 2026

    @dan-petty
    OwnerAuthor

    Closed by #632, 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/p0-criticalscope/clitype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions