Add worktree + chmod sandbox mode#42
Merged
Merged
Conversation
Alternative to bwrap mount-namespace isolation. Uses git sparse-checkout worktrees and POSIX file permissions to enforce allow/deny rules: 1. Create sparse-checkout worktree (only allowed paths materialized) 2. chmod -R 000 (deny everything) 3. chmod a+x on traversal dirs (navigate but not list) 4. chmod a+r on allow.read files 5. chmod a+rw on allow.write files 6. chmod 000 on deny.read/deny.write (override allow) 7. Run script as band-runner (unprivileged) 8. Tear down worktree New files: - packages/runtime/src/worktree-chmod.ts — pure functions for plan generation, script building, sparse-checkout patterns, symlink filtering, path safety validation - packages/runtime/test/unit/worktree-chmod.test.ts — 45 tests covering traversal computation, chmod plan generation, script ordering, shell injection prevention, security invariants Integration: - band-server.ts gains sandboxMode: "bwrap" | "worktree-chmod" in ExecRequest, dispatching to the appropriate sandbox - ExecutionConfig.lima gains sandboxMode field - Default remains "bwrap" — worktree-chmod is opt-in Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
can't we ONLY have write, and not read? i don't think write needs to imply read. |
Contributor
Changed this in |
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.
Summary
Alternative to bwrap mount-namespace isolation for file access control. Uses git sparse-checkout worktrees and POSIX file permissions instead of Linux namespace bind-mounts.
How it works
allow.read/allow.writepatterns are materialized on diskallow.readfilesallow.writefilesdeny.read/deny.writefiles (deny overrides allow)band-runner(unprivileged) — kernel enforces permissionsAdvantages over bwrap
ls -lashows permissions)New files
packages/runtime/src/worktree-chmod.ts— pure functions: plan generation, chmod script building, sparse-checkout patterns, symlink filtering, path safety validation, shell quotingpackages/runtime/test/unit/worktree-chmod.test.ts— 45 unit tests covering security invariantsIntegration
band-server.tsgainssandboxMode: "bwrap" | "worktree-chmod"inExecRequestExecutionConfig.limagains optionalsandboxModefield"bwrap"— worktree-chmod is opt-in via band configTest plan
sandboxMode: "worktree-chmod"in BAND.md + git repo in VM)🤖 Generated with Claude Code