Skip to content

fix(tools): reject unresolved parent traversal (C-03)#39

Merged
euxaristia merged 6 commits into
Cairn:mainfrom
PierrunoYT:fix/workspace-confinement-new-paths
Jul 24, 2026
Merged

fix(tools): reject unresolved parent traversal (C-03)#39
euxaristia merged 6 commits into
Cairn:mainfrom
PierrunoYT:fix/workspace-confinement-new-paths

Conversation

@PierrunoYT

Copy link
Copy Markdown
Collaborator

Fixes #13.

Problem

resolve_in_workspace canonicalized the deepest existing ancestor, then appended unresolved path components without lexical normalization. A path such as target/missing/../../../outside.txt could therefore pass starts_with(cwd) and later escape when a file tool created parent directories.

Resolution

  • Reject every ParentDir component before canonicalizing or rebuilding the path.
  • Preserve existing support for valid files and new nested workspace paths.
  • Cover the vulnerable nonexistent-prefix form in the shared workspace helper.
  • Add file-write and file-edit regression tests.
  • Add a Windows backslash traversal regression test.

Validation

  • Focused workspace tests: 6 passed.
  • Focused file tool traversal tests: 2 passed.
  • cargo test --locked --all-targets -- --test-threads=1: 227 passed.
  • The default parallel suite reproduced the existing unrelated M-08 environment-test race in notify::tests::enabled_defaults_true_without_env; that test passed independently.

Audit finding: C-03.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@PierrunoYT, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 888941ce-d757-45a2-8f7a-6d9ab53bd238

📥 Commits

Reviewing files that changed from the base of the PR and between 4208cd2 and 16a5eb4.

📒 Files selected for processing (5)
  • src/tools/file_edit.rs
  • src/tools/file_history.rs
  • src/tools/file_undo.rs
  • src/tools/file_write.rs
  • src/tools/workspace.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PierrunoYT

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

PierrunoYT and others added 5 commits July 23, 2026 02:05
Keep main's capability-backed Workspace as the shared confinement layer while preserving distinct no-follow, atomic mutation, and safe undo behavior from C-03.

Amp-Thread-ID: https://ampcode.com/threads/T-019f8e74-3362-7335-b8d0-f8b02839fa60

Co-authored-by: Pierre Bruno <pierrebruno@hotmail.ch>

@euxaristia euxaristia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Approved after audit.

@euxaristia
euxaristia merged commit 45b7e0e into Cairn:main Jul 24, 2026
4 checks passed
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.

[Critical][C-03] Fix workspace confinement bypass for new paths

3 participants