fix(sandbox): auto-deny dangerous paths and .git/hooks across all allowedWrite roots - #518
Open
connerkup wants to merge 1 commit into
Open
fix(sandbox): auto-deny dangerous paths and .git/hooks across all allowedWrite roots#518connerkup wants to merge 1 commit into
connerkup wants to merge 1 commit into
Conversation
…owedWrite roots * linux: scan all allowedWritePaths alongside process.cwd() for mandatory deny targets (.git/hooks, .git/config, dotfiles) * linux: use isAtOrUnder for isWithinAnyAllowedWritePath and findSymlinkInPath to prevent root '/' containment bypass * macos: normalize allowOnly roots before scanRoots filtering to avoid dropping tildes or symlinked paths * macos: emit root-specific static paths and dual directory/subtree globs for .git/hooks * test: add integration test for external allowedWrite repo and unit test for multi-root pattern emission
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
Ensures mandatory write-denies (such as `.git/hooks`, `.git/config`, `.vscode`, and shell dotfiles) are automatically discovered and denied across all directories specified in `allowedWritePaths` / `allowOnly`, rather than solely `process.cwd()`.
Problem
Previously, `linuxGetMandatoryDenyPaths` and `macGetMandatoryDenyPatterns` only scanned `process.cwd()`. When a sandboxed command is executed with `allowOnly` or `--allow-write` targeting an external workspace directory outside CWD (common in multi-repo workflows or orchestrator harnesses), mandatory deny rules were not generated for that target path. This allowed sandboxed processes to write into `.git/hooks/` of the allowed repository, enabling potential host-level code execution on subsequent git operations outside the sandbox.
Additionally, containment checks in `linux-sandbox-utils.ts` used string concatenation (`candidatePath.startsWith(allowedPath + '/')`), which evaluates to `'//'` when `/` is an allowed write root, inadvertently bypassing deny-bind generation.
Solution
Test Plan