Skip to content

fix(tools): enforce REPL execution permissions#28

Open
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-repl-tool-permission-bypass-amynd2
Open

fix(tools): enforce REPL execution permissions#28
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-repl-tool-permission-bypass-amynd2

Conversation

@BunsDev
Copy link
Copy Markdown
Member

@BunsDev BunsDev commented Jun 3, 2026

Motivation

  • The REPL tool previously executed model-supplied code (bash/python/node) without consulting the repository's permission handler, allowing a model or prompt-injection to run arbitrary local commands despite PermissionLevel::Execute metadata.
  • Enforce the existing permission model so headless/default AutoPermissionHandler and interactive flows can deny or prompt before code execution.

Description

  • Add an explicit permission check using ctx.check_permission(self.name(), &reason, false) before spawning or reusing a REPL session in crates/tools/src/repl_tool.rs.
  • Validate requested interpreter language with interpreter_for(&language) and return an error for unsupported languages before prompting.
  • Add a regression test in repl_tool.rs that uses a DenyPermissionHandler and asserts the tool returns a permission error and does not create a REPL session.
  • Keep the change minimal and localized to crates/tools/src/repl_tool.rs and its unit tests to preserve existing architecture and behavior.

Testing

  • Ran the new unit test: cargo test --package claurst-tools repl_tool::tests::execute_denies_without_repl_session_when_permission_denied -- --nocapture — passed.
  • Ran package-level checks: cargo check --package claurst-tools — passed.
  • Ran formatting check: rustfmt --edition 2021 --check src-rust/crates/tools/src/repl_tool.rs — passed.
  • cargo check --workspace could not be completed in this environment due to missing system alsa pkg-config files required by alsa-sys (external system dependency), and cargo clippy --all-targets -D warnings is blocked by pre-existing clippy warnings in claurst-core unrelated to this patch.

Codex Task

Copilot AI review requested due to automatic review settings June 3, 2026 10:35
Copy link
Copy Markdown

Copilot AI left a comment

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 the Rust REPL tool’s security model by ensuring code execution is gated by the repository’s permission handler, preventing model-supplied code from running without an explicit Execute permission decision.

Changes:

  • Adds an explicit ctx.check_permission(...) gate before creating/reusing a REPL session.
  • Validates the requested interpreter language early and errors out for unsupported languages before any permission prompt.
  • Adds a regression test asserting permission denial prevents REPL session creation.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants