Skip to content

fix(hooks): emit permissionDecision allow for simple Copilot CLI rewrites - #3149

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
guyoron1:fix/copilot-permission-decision
Jul 25, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
guyoron1:fix/copilot-permission-decision

Conversation

@guyoron1

@guyoron1 guyoron1 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Heyaaa! : )

I've been testing RTK with Copilot CLI and since version 1.0.66, every rewrite triggers a permission prompt — even safe stuff like cargo test → rtk cargo test. Copilot changed how it handles missing permissionDecision: now treats it as "always ask." Since AskRewrite omitted the field, every rewrite became manual approval.

Fix: emit permissionDecision: "allow" for simple single-segment commands. Compound commands (newlines, &, ;, pipes) still omit it so Copilot shows its own prompt. Uses existing split_for_permissions() — all CVE bypass security tests still pass.

Closes #3037

Test plan

  • All 17 Copilot CLI tests pass (including security CVE tests)
  • Simple commands (cargo test) now get permissionDecision: "allow"
  • Compound commands (git status\nrm -rf /) still omit permissionDecision
  • Full test suite passes (cargo test --all)
  • cargo fmt --all && cargo clippy --all-targets clean

…ites

Copilot CLI 1.0.66+ treats a missing permissionDecision field as
"always prompt", forcing a permission dialog on every RTK-rewritten
command. For simple (non-compound) commands, emit
permissionDecision: "allow" so Copilot auto-accepts the rewrite.

Compound commands (containing newlines, background &, subshells, or
pipes) still omit the field, preserving the security guarantee that
hidden dangerous segments trigger a manual prompt.

Uses split_for_permissions() to detect compound commands — if the
command decomposes into more than one segment, it's not safe to
auto-allow.

Closes rtk-ai#3037

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@pszymkowiak pszymkowiak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified on a compiled build, both unit and end-to-end. The security boundary (split_for_permissions(cmd).len() <= 1) holds — I drove the real rtk hook copilot with Copilot-CLI-shaped JSON on stdin:

cargo test / git status          → {"modifiedArgs":{"command":"rtk cargo test"},"permissionDecision":"allow"}
git status && git push           → {"modifiedArgs":{...}}                 (no permissionDecision → Copilot prompts)
cargo test; rm -rf x             → {"modifiedArgs":{...}}                 (no allow — the rm -rf isn't auto-approved) ✓
cargo test $(rm -rf /tmp/x)      → (no response → defer)
cargo test && echo hi > /etc/passwd → (no response → defer)

So only simple, single-segment rewrites get allow; anything compound or dangerous keeps Copilot's own prompt, and substitution/redirect forms defer entirely. Also confirmed decide_from_verdict handles Deny before AskRewrite, so this never auto-allows a denied command. 44 copilot/hook tests pass, including the CVE ones (newline_bypass/background_bypass never auto-allow).

One semantic note (non-blocking): AskRewrite maps to verdict Ask, which covers both the default (no rule) and an explicit user ask rule — so a simple rewritable command a user explicitly marked "ask" would now auto-allow under Copilot. Given this is scoped to Copilot CLI's 1.0.66 behavior, rtk only rewrites a curated command set, and the verdict doesn't expose default-vs-explicit, it's a reasonable trade-off — maybe worth a line in the docs.

LGTM 👍

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM thanks

Comment thread src/hooks/hook_cmd.rs Resolved
Change AskRewrite(String) to AskRewrite { rewritten, explicit } so the
Copilot path only auto-allows when the user didn't explicitly configure
"ask" for a command. Addresses KuSh's review feedback on rtk-ai#3149.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@KuSh
KuSh merged commit 23d1e89 into rtk-ai:develop Jul 25, 2026
10 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 25, 2026
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.

rtk hook copilot emits permissionDecision "ask", forcing a permission prompt on every command in Copilot CLI >= 1.0.66

3 participants