feat(tool-host): route shell through an opt-in bubblewrap sandbox - #50
Open
arcuru-bot wants to merge 1 commit into
Open
feat(tool-host): route shell through an opt-in bubblewrap sandbox#50arcuru-bot wants to merge 1 commit into
arcuru-bot wants to merge 1 commit into
Conversation
The BubblewrapToolHost has sat in-tree since it landed but no config could select it, so every shell command still ran in-process. Wire it up behind `tool_host: bubblewrap` (default stays native) and make the sandbox actually refuse escapes instead of just passing happy-path tests. The profile already isolated the filesystem (empty root + read-only system dirs + a read-write working dir) and network (`--unshare-net`), but it mounted `/proc` without `--unshare-pid`, which exposed the host's PID namespace — including systemd's cmdline and a `/proc/<pid>/root` route back to the host filesystem. Drop the `/proc` mount entirely; the shell tool doesn't need it and the host process list must not be visible. Add integration tests that run a real bwrap sandbox and assert the negative case: network connects are refused with a diagnostic on stderr, writes outside the working dir (and to read-only system dirs) fail, writes inside the working dir land on the host, and `/proc` is absent. They skip cleanly where bwrap or unprivileged user namespaces are unavailable. bwrap is added to the Linux test/dev/wrapper inputs (guarded so Darwin still evaluates).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
BubblewrapToolHosthas been in-tree since it landed but no config could select it, so every shell command still ran in-process. This wires it up behindtool_host: bubblewrap(default staysnative) and makes the sandbox actually refuse escapes.Changes
tool_host: native | bubblewraptop-level option, wired inbuildto construct eitherNativeToolHostorBubblewrapToolHost./procleak closed: the profile mounted/procwithout--unshare-pid, exposing the host's PID namespace (systemd's cmdline, the host process list, and a/proc/<pid>/rootroute back to the host filesystem)./procis no longer mounted — the shell tool doesn't need it and the host process list must not be visible.bwrapsandbox and assert the negative case — network connects refused with a stderr diagnostic, writes outside the working dir (and to read-only system dirs) fail, writes inside the working dir land on the host, and/procis absent. They skip cleanly where bwrap or unprivileged user namespaces are unavailable.bwrapadded to the Linux test/dev/wrapper inputs (guarded withstdenv.isLinuxso Darwin still evaluates).Verification
just nix fullpasses (lint, treefmt, test, doc, build), with the bwrap integration tests running inside the Nix sandbox (not skipped).sh -c true.Notes
shellis sandboxed;web_fetch, file read/write, and HTTP capabilities still fall through to native execution (unchanged from the existing design).