Repository navigation
Description
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 checkedThe 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
- Gate on exit 3. A model may legitimately write
rtk ls -la, and feat:rtk rewrite— single source of truth for LLM hook rewrites #241's contract —
still pinned bytest_run_already_rtk_returns_some— makes the identity answer correct
forrtk rewrite. - Strip the prefix unconditionally. Wrong for
rtk gain,rtk discover,rtk proxy,
and for every command RTK actually filters. - Docs alone. Agent guidance tells agents to prefix shell builtins with
rtk, and promises it is safe —rtk cdexits 127 and aborts the compound #3969 will cut down how often agents prefix commands, but a host cannot
rely on the model's cooperation for an allowlist.
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
- rtk rewrite "rtk <builtin>" returns unchanged (exit 3) instead of stripping prefix — cd and other builtins silently no-op #2508 — where @rmsc reported instance 1
- fix(rewrite): strip rtk prefix from shell builtins #2534 — rejected; instance 2 is why
- Agent guidance tells agents to prefix shell builtins with
rtk, and promises it is safe —rtk cdexits 127 and aborts the compound #3969 — the guidance that makes agents prefix commands in the first place - refactor(hooks): consolidate the hook decision behind one shared decide #3955 — consolidates both hook decision paths behind one
decide; the natural place for
the verdict to be recomputed on the emitted command
Activity
rtk-wshm-sync-bot commentedon Sep 9, 2026
🔍 Automated Triage
bugcriticalSummary
Permission verdicts are computed on the raw input command rather than the command that actually executes, letting a model-authored
rtkprefix bypass host allow/deny rules; fix by recomputing the verdict on the emitted command.📁 Relevant files
src/hooks/hook_cmd.rssrc/hooks/permissions.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
test(hooks): failing regression tests for rtk-prefixed verdict bypass (…
fix(hooks): judge deny/ask/allow on the command behind an rtk prefix (r…
fix(permissions): keep the peel cap allow-neutral; flag unreadable rt…
test(hooks): failing regression tests for rtk-prefixed verdict bypass (…
fix(hooks): judge deny/ask/allow on the command behind an rtk prefix (r…
fix(permissions): keep the peel cap allow-neutral; flag unreadable rt…
test(hooks): failing tests for rtk err/summary/test runner bypass (rt…
fix(permissions): read the command rtk err/summary/test run behind th…
test(hooks): failing tests for Claude ask decision behind rtk prefix (r…
fix(hooks): tell Claude ask when the host would judge an rtk prefix (r…
11 remaining items
test(hooks): failing regression tests for rtk-prefixed verdict bypass (…
fix(hooks): judge deny/ask/allow on the command behind an rtk prefix (r…
fix(permissions): keep the peel cap allow-neutral; flag unreadable rt…
test(hooks): failing tests for rtk err/summary/test runner bypass (rt…
fix(permissions): read the command rtk err/summary/test run behind th…
test(hooks): failing tests for Claude ask decision behind rtk prefix (r…
fix(hooks): tell Claude ask when the host would judge an rtk prefix (r…
test(permissions): failing tests for rtk package-runner bypass (npx/b…
fix(permissions): read the command rtk's package runners execute behi…
test(permissions): failing tests for rtk bun run/exec bypass (rtk-ai#…
fix(permissions): read the command rtk bun run/exec executes behind t…
test(permissions): failing tests for rtk prefix hidden behind a line …
fix(permissions): judge the line bash runs, with line continuations j…
test(permissions): failing tests for rtk env falling back to the real…
fix(permissions): read the command rtk env's fallback to the real env…