Skip to content

fix(tools): restore confined host CLI toolchains - #461

Merged
mohitranka merged 2 commits into
mainfrom
ao/forge-30/sandbox-gh-cargo
Aug 28, 2026
Merged

mohitranka merged 2 commits into
mainfrom
ao/forge-30/sandbox-gh-cargo

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

  • Resolve the executable named by each shell segment from the command and PATH, then expose only that executable (and the runtime paths it actually needs) read-only; there is no gh/cargo binary allowlist.
  • Re-expose a selected Rustup installation without reopening the home tree, redirect mutable Cargo state and XDG client config/cache/state into the session scratch directory, and apply the same spawn-time policy to persistent exec_command sessions.
  • Preserve deny-by-default host(...) egress, credential isolation, workspace/.git/.forge confinement, and destructive-git approval semantics.

This fixes the #447 regression: strict read confinement excluded the normal user-installed toolchain/runtime paths, while the default personal host policy must continue to deny network access until an explicit host grant is present. Relative ../ command paths and relative PATH entries cannot widen the runtime exception outside the workspace.

The implementation does not add implicit GitHub or crates.io access. The command and host names in tests/docs are representative examples; runtime access is derived from the selected executable and explicit egress grants. Standard external-client credential variables are scrubbed from confined children and are not execution or network grants.

Validation

  • cargo fmt --all -- --check — pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
  • cargo test -p forge-tools --lib sandbox::tests --locked -- --nocapture — 18 passed
  • cargo test -p forge-tools --test sandbox_enforcement --locked -- --nocapture — 40 passed
  • cargo test --workspace --all-targets --locked — pass; all suites passed (including 337 forge-tools tests and 1,045 forge-tui tests)
  • cargo build --release --locked --package forge-cli && ./target/release/forge --version — pass; forge 0.1.0-beta.7

Platform notes

The real sandbox enforcement tests passed on macOS Seatbelt. Linux bubblewrap path/profile coverage is included in unit tests but was not runnable on this macOS host. The interactive nested Forge PTY reproduced the original macOS harness limitation: Forge itself was already inside a Seatbelt and could not reliably enter a second one; the pre-fix child reported bash: cargo: command not found (exit 127), and gh reached host git but failed with the macOS Xcode developer-tools request. Source-backed sandbox integration tests cover the fixed path without claiming a live network/API result.

@mohitranka
mohitranka merged commit 88013a6 into main Aug 28, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(tools): restore confined host CLI toolchains

* test(tools): accept platform-specific sandbox denials
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(tools): restore confined host CLI toolchains

* test(tools): accept platform-specific sandbox denials
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