Skip to content

Permission verdict is computed on a command that is not the one that runs — a model-authored rtk prefix escapes the host allowlist #3970

Open

Description

@KuSh

Summary

The permission verdict a hook reports is computed on a command that is not the one that
ends up running. Two independent instances, same root cause: decide_from_verdict(cmd, permissions::check_command_for(cmd, host)) (src/hooks/hook_cmd.rs:274) checks the raw
input, while what executes is decided elsewhere.

host checks actually runs how they diverge
1. rtk swallows the inner command rtk rm file rm file, as an rtk subprocess the host never sees rm; if rtk is allowed, rm is never checked
2. the rewrite hands back a different command rtk source x source x, stamped "allow" only reachable if a rewrite drops the rtk prefix

Instance 1 was reported by @rmsc on #2508. Instance 2 is not currently reachable on
develop — it is what made #2534's prefix-stripping approach unmergeable, and it is
recorded here so the constraint is known before anyone tries again.

Instance 1 — reproduction

$ rtk rewrite "rm file"
                 # exit 1 — passthrough; the host checks `rm` against its allowlist

$ rtk rewrite "rtk rm file"
rtk rm file      # exit 3 — "handled"; if `rtk` is allowed, `rm` is never checked

The same holds for every non-routed command: rtk curl …, rtk chmod …. A model that
prefixes commands itself — which the full awareness level instructs it to do, see #3969 —
therefore routes around the host's per-command rules.

Bash(rtk:*) in permissions.allow is the natural workaround for prefixed-command prompt
spam, which makes this the common configuration rather than an unusual one.

Instance 2 — reproduction (with #2534 applied)

command_matches_pattern (src/hooks/permissions.rs:406) is a word-boundary prefix match,
so Bash(source:*) does not match rtk source x. With
permissions: {"allow": ["Bash(rtk:*)"], "deny": ["Bash(source:*)"]}:

$ echo '{"tool_name":"Bash","tool_input":{"command":"rtk source /tmp/evil.sh"}}' | rtk hook claude
# develop:     (no output — Defer; the host applies its own rules to `rtk source …`)
# with #2534:  {"updatedInput":{"command":"source /tmp/evil.sh"},"permissionDecision":"allow"}

An explicitly denied command, emitted with an explicit auto-allow. With no allow rule the
verdict degrades to Ask, but the deny is still bypassed. Compound forms are protected by the
#1213 per-segment rule; this is the single-segment case.

Why the obvious fixes do not work

What the host needs is which command the rewrite ultimately runs, which the current
stdout/exit protocol does not express. Any fix that changes the emitted command must also
recompute the verdict on it, and take the stricter of the two.

Related

Activity

  1. rtk-wshm-sync-bot commented on Sep 9, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🔴 Priority critical
    🎯 Confidence 90%

    Summary

    Permission verdicts are computed on the raw input command rather than the command that actually executes, letting a model-authored rtk prefix bypass host allow/deny rules; fix by recomputing the verdict on the emitted command.

    📁 Relevant files
    • src/hooks/hook_cmd.rs
    • src/hooks/permissions.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. 11 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions