Skip to content

feat(sandbox): bubblewrap host confinement for criteria execution (#592) - #632

Merged
dan-petty merged 2 commits into
release/v0.2.23from
feat/592-bubblewrap-host-sandbox-criteria-confinement
Sep 27, 2026
Merged

dan-petty merged 2 commits into
release/v0.2.23from
feat/592-bubblewrap-host-sandbox-criteria-confinement

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Resolves #592 (Part 1 of 2: bubblewrap host confinement for criteria execution).

This PR introduces robust Linux container-free sandbox confinement via bubblewrap (bwrap) behind a narrow HostSandbox seam, routing executable criterion verification through strictly isolated namespaces.

Key Changes

  • Host Sandbox Seam (HostSandbox): Implemented in src/devops_cli/sandbox/host.py with zero boilerplate and bounded cyclomatic complexity (McCabe complexity <= 4, depth <= 2).
    • Configures bubblewrap (bwrap) with:
      • --unshare-all, --new-session, --die-with-parent
      • --clearenv + explicit sanitized minimal environment (CONST_HOST_SANDBOX_DEFAULT_ENV: PATH, TERM, LANG, TMPDIR)
      • --dev /dev, --proc /proc, --tmpfs /tmp
      • --ro-bind for system directories and resolved symlinks (/usr, /bin, /lib, /lib64, /sbin)
      • --ro-bind for target repository workspace
    • Enforces zero credential leakage: strictly purges $HOME, $XDG_RUNTIME_DIR, $DBUS_SESSION_BUS_ADDRESS, $GITHUB_TOKEN, LLM API keys, and keyring paths.
    • Fail-closed semantics: returns HostSandboxResult(exit_code=-1, error=...) if bwrap is missing or namespaces are refused, never allowing unconfined execution.
  • Criteria Execution Integration: Routed execute_criterion_command in src/devops_cli/ai/review/review_environment.py through HostSandbox.
  • Configuration & Defaults: Added constants CONST_FORBIDDEN_SANDBOX_ENV_KEYS, CONST_HOST_SANDBOX_DEFAULT_ENV, CONST_HOST_SANDBOX_SYSTEM_SYMLINKS, CONST_HOST_SANDBOX_SYSTEM_DIRS, and default DEFAULT_HOST_SANDBOX_BINARY in src/devops_cli/config/.
  • DevContainer & Documentation: Added bubblewrap to .devcontainer/Dockerfile, updated SECURITY.md and docs/DEVCONTAINER_USAGE.md.
  • Unit & Integration Test Suite: Added comprehensive tests in tests/test_host_sandbox.py verifying repo read access, home directory isolation, write denial, network isolation, credential stripping, and fail-closed handling.

Verification

  • Verified all 8 sandbox test cases in tests/test_host_sandbox.py with structural tuple equality assertions.
  • Verified 100% passing status across all 10 Gated CI checks (uv run devops ci).
  • Successfully passed pre-commit and pre-push quality gates.

@dan-petty
dan-petty marked this pull request as draft September 27, 2026 04:39
@dan-petty
dan-petty marked this pull request as ready for review September 27, 2026 04:56
@dan-petty
dan-petty merged commit b7f8e2d into release/v0.2.23 Sep 27, 2026
8 checks passed
@dan-petty
dan-petty deleted the feat/592-bubblewrap-host-sandbox-criteria-confinement branch September 27, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant