Skip to content

fix(settings): strip repository workspace_paths in project sanitization - #173

Merged
BunsDev merged 1 commit into
mainfrom
fix/sanitize-workspace-paths
Jul 31, 2026
Merged

fix(settings): strip repository workspace_paths in project sanitization#173
BunsDev merged 1 commit into
mainfrom
fix/sanitize-workspace-paths

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

Security follow-up from the #170 review (tracked as Cave bead cave-smv6v): Settings::sanitize_project_settings removed every executable and provider surface from repository settings but left config.workspace_paths intact — and merge() concatenates that Vec. An untrusted <project>/.coven-code/settings.json could therefore append arbitrary roots (/, ~/.ssh) to the default-mode read allowlist, widening plain-headless read access beyond the project with no LSP or command execution involved.

The sanitizer now clears workspace_paths, so only the user's own settings layers (shared/global) contribute read roots. A future explicit trust-this-project policy can relax that deliberately rather than by default — matching the sanitizer's existing "untrusted until the user chooses to trust" contract.

Verification

  • New regression test sanitize_strips_repository_workspace_paths: the sanitizer strips repo-provided paths, and a merge of trusted-global + sanitized-project preserves exactly the trusted roots.
  • Full config:: test module: 31/31 pass; cargo fmt --check clean.

🤖 Generated with Claude Code

sanitize_project_settings removed every executable and provider surface
from repository settings but left config.workspace_paths intact, and
merge() concatenates that Vec — so an untrusted
<project>/.coven-code/settings.json could append arbitrary roots (/,
~/.ssh) to the default-mode read allowlist and widen plain-headless
read access beyond the project. Unlike the read/write tool paths, this
needed no LSP or command execution.

Only the user's own settings layers may contribute read roots now; a
future explicit trust-this-project policy can relax that deliberately
rather than by default. Regression test proves the sanitizer strips
repo-provided paths and that a merge preserves exactly the trusted
global roots.

Follow-up from the coven-code #170 review (Cave bead cave-smv6v).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 31, 2026 16:10
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 31, 2026 4:10pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens project-settings sanitization in claurst_core::config::Settings to prevent untrusted repository config from widening default-mode filesystem read allowlists via workspace_paths, aligning with the “repo settings are untrusted until explicitly trusted” security contract introduced in PR #170.

Changes:

  • Clear config.workspace_paths inside Settings::sanitize_project_settings() so repository-local settings cannot contribute additional read roots.
  • Add a regression test ensuring sanitized project settings do not contribute workspace_paths, and that merging trusted global + sanitized project preserves only trusted roots.
Suppressed comments (1)

src-rust/crates/core/src/lib.rs:2370

  • The new regression test only covers workspace_paths, but the same trust boundary applies to config.additional_dirs (it is included in ToolContext::permission_allowed_roots() alongside workspace_paths). Extending this test to include additional_dirs would prevent regressions where repository settings widen read roots via --add-dir-equivalent config.
            let global = Settings {
                config: Config {
                    workspace_paths: vec![PathBuf::from("/home/user/trusted-workspace")],
                    ..Default::default()
                },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1851 to +1857
// workspace_paths widen the default-mode read allowlist, and merge()
// concatenates them — an untrusted repository could add arbitrary
// roots (e.g. "/" or "~") and read outside the project in plain
// headless mode. Only the user's own settings layers may contribute
// read roots; a future explicit trust-this-project policy can relax
// this deliberately rather than by default.
settings.config.workspace_paths.clear();
@BunsDev
BunsDev merged commit e97db82 into main Jul 31, 2026
5 checks passed
@BunsDev
BunsDev deleted the fix/sanitize-workspace-paths branch July 31, 2026 16:23
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.

2 participants