fix(tools): enforce repository boundary for hosted-repair file tools - #169
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR closes a critical containment gap in hosted-repair mode by enforcing that file-oriented tools can only operate within the repository working directory, even when the permission layer is running under BypassPermissions.
Changes:
- Introduces
ToolContext::check_hosted_repair_path()and supporting path helpers to reject paths outsideworking_dirunder hosted-repair file-tool mode. - Applies the hosted-repair path check across file tools (read/write/edit/patch/batch/notebook) and search tools (grep/glob) before normal permission checks.
- Adds unit tests covering in-workspace acceptance, parent-directory escape rejection, and symlink escape rejection.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src-rust/crates/tools/src/lib.rs | Adds hosted-repair path boundary enforcement and path canonicalization helpers + unit tests. |
| src-rust/crates/tools/src/file_read.rs | Enforces hosted-repair repository boundary before permission checks for reads. |
| src-rust/crates/tools/src/file_write.rs | Enforces hosted-repair repository boundary before permission checks for writes. |
| src-rust/crates/tools/src/file_edit.rs | Enforces hosted-repair repository boundary before permission checks for edits. |
| src-rust/crates/tools/src/apply_patch.rs | Enforces hosted-repair repository boundary before applying patches to files. |
| src-rust/crates/tools/src/batch_edit.rs | Enforces hosted-repair repository boundary for each batch edit target path. |
| src-rust/crates/tools/src/notebook_edit.rs | Enforces hosted-repair repository boundary for notebook edits. |
| src-rust/crates/tools/src/grep_tool.rs | Enforces hosted-repair repository boundary for grep base path and discovered files. |
| src-rust/crates/tools/src/glob_tool.rs | Enforces hosted-repair repository boundary for glob base dir and matched paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
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.
Motivation
BypassPermissions, allowing the permission layer to alwaysAllowand thereby bypass any workspace containment checks.Description
ToolContext::check_hosted_repair_path(tool_name, path)which rejects paths outside the working directory whenhosted_review.allow_file_write_toolsis set, and run it before normal permission checks.normalize_pathandcanonicalize_existing_prefix) and apath_is_within_working_dirhelper that handles non-existent children and symlink/parent escapes.Read,Write,Edit,ApplyPatch,BatchEdit,NotebookEdit,Grep, andGlobso containment is enforced pre-permission-bypass.src-rust/crates/tools/src/lib.rs,file_read.rs,file_write.rs,file_edit.rs,apply_patch.rs,batch_edit.rs,notebook_edit.rs,grep_tool.rs,glob_tool.rs.Testing
cargo fmt --alland formatting passed.cargo test -p claurst-tools hosted_repair_path_check -- --nocaptureand the three new tests passed (all checks OK).cargo check -p claurst-toolsand the package-level check completed successfully.cargo clippy -p claurst-tools --all-targets -- -D warningsand clippy passed for theclaurst-toolscrate.cargo check --workspaceand it failed in this environment due to a missing system dependency required byalsa-sys(pkg-config could not findalsa.pc); this is an environment issue and unrelated to the change.If you'd like, I can open a PR with this patch and include the small regression tests; next steps would be review of the path helpers for any platform edge cases and optional expanding of
permission_allowed_rootssemantics.Codex Task