Repository navigation
fix(auto-improvement): re-check eval and quoted separators in the runner gate - #30602
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change only adds refusals for commands the denylist already names, and a revert undoes it cleanly. Notes
[DESIGN-REVIEWED] b8cfda9 Description read[DESCRIPTION-READ] 7550ac6b9471bb6fa99ed0a6cbe1e0866590d07aec8981f3e5c3f42de34a1cde That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] b8cfda9 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item closes a way around a row the denylist already has, and the spec's existing "unwrap before it matches" decision covers that. The one note is that this is a text denylist, so bypass spellings will keep turning up. Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: stop a word in front of a refused command, such as
[FIRST-PRINCIPLES-REVIEWED] b8cfda9 Description read[DESCRIPTION-READ] ae2c3cad26eba1704fed4f2d9c0e8b4912baa31e23a553acd9fac596c54eb5d7 That sha256 names the PR description this verdict read. Recompute it with |
823d68b to
733e95e
Compare
|
Disposition for the Opus 5.5 block at
|
|
Disposition for the Opus 5.5 block at
|
733e95e to
5c068a9
Compare
|
Disposition for the Opus 5.5 block at
|
5c068a9 to
49a41a9
Compare
49a41a9 to
5f83a61
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the quick fix. This head closes the # it's gap. The new fail-closed branch, though, now refuses ordinary wrapped commands that main allows.
Earlier items from my last review:
# it'sturning off the refusals: fixed. The five rows andecho a#b; git pushare refused, andecho hi # don'tstays allowed.- Optional,
<and>inseps: fixed.printf x > test/bin/sshandecho hi > ./curlare pinned as allowed. - Optional, spec doc: fixed. It now covers
eval,script -cand the quote-aware split. - Optional, Tests paragraph wording: fixed.
-
agent_runner_gate.py:287-297. The fail-closed branch also runs on fragments from the quote-blind split. The trigger is a wrapper from_COMMAND_WRAPPERSin front of a shell-cwhose script holds a separator. Examples:timeout 300 bash -c 'cd /repo && python -m pytest -q'nohup sh -c 'echo "start"; sleep 1'env PYTHONPATH=src bash -c 'python -m pytest -q "test/a.py" | tail -5'sudo bash -c 'apt update && apt install -y x'
Each of these lexes cleanly at the top level. Line 311 adds the quote-blind split, which cuts inside the quoted script and yields a fragment like
timeout 300 bash -c 'cd /repo. The wrapper branch (lines 395-400) then passesbash -c 'cd /repoto_refusalat depth+1, where shlex raises. The new branch seesbashand-cand returns "command holds a nested script the gate cannot parse". Main allows all of these, and the review reproduced each refusal on this head. Without the wrapper,bash -c 'cd /x && pytest "a.py"'is still allowed. The Backwards compatibility section only names text that shlex cannot parse as a whole, so it does not cover this. The result is that the unattended runner is refused its most common way to bound a test run.Smallest fix: apply the fail-closed refusal only to text that the gate lexes whole, meaning the top-level command or a token from the quote-aware split. For example, thread a
blind: boolkeyword into_refusaland set it when you recurse from a_segmentsfragment. The# it'srows stay refused, because the comment breaks the lex at depth 0. Add_ALLOWEDrows such astimeout 300 bash -c 'cd /x && python -m pytest -q "t.py"',nohup sh -c 'echo "start"; sleep 1'andenv A=1 bash -c 'ls; echo "x"'.
Done well: main's quote-blind split still always runs, and the property test pins that whatever main refuses stays refused. A wide random comparison against main found no command that main refuses and this head allows.
Optional:
- PR Readiness is also red because a lane finding about
eval $'git push'was upheld, and this head has no disposition for it. Main allows the same spellings, so it is not a regression. A disposition that rebuts or defers it as a pre-existing class fits better than adding an ANSI-C decoder. - A quoted lone separator is read as a split, so
printf '%s\n' ';' curlis refused while main allows it. That contradicts "a quoted;stays in its word". Either list it under Backwards compatibility or keep such a token as a word. - No row pins the re-quoted
shlex.joinwrapper join. A_REFUSEDrow such assudo script -c 'timeout 5 git push' /dev/nullwould catch a later simplification back to a plain join.
|
|
5b792cd to
d5e2843
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the fixes on this head. One item from my last review still reproduces on d5e2843, so I am requesting changes again.
Earlier items:
- Item 1, wrapped
bash -cscripts refused: still stands (see below). - Optional, the
eval $'...'disposition: fixed. The disposition is posted, andeval $'gh -R o/p pr ready 1'is now refused. - Optional, a quoted lone separator read as a split: fixed.
printf '%s\n' ';' curlis allowed again and pinned as an_ALLOWEDrow. - Optional, a row that pins the re-quoted
shlex.joinwrapper join: still open (see Optional below).
src/kiro_crew/apps/builtins/auto_improvement/spine/agent_runner_gate.py:310-318. The fail-closed branch still runs on fragments from the quote-blind split. Trigger: a wrapper from_COMMAND_WRAPPERSin front of a shell-cscript that holds a separator, for exampletimeout 300 bash -c 'cd /repo && python -m pytest -q',nohup sh -c 'echo "start"; sleep 1',env A=1 bash -c 'make && make test'ornice -n 5 bash -lc 'cd x; pytest'. Line 332 cuts inside the quoted script and givestimeout 300 bash -c 'cd /repo. The wrapper branch passesbash -c 'cd /repoto_refusalone level down, where shlex raises, and the branch returns "command holds a nested script the gate cannot parse". Main allows every one of these. On this head the barebash -c 'cd /x && pytest'is still allowed. So the unattended runner cannot use its usual way to put a time limit on a test run, and the reason it is given is wrong. The Backwards compatibility section covers only text that shlex cannot parse as a whole, and these commands parse cleanly. The same check also fires inside a$(...)token: a heredoc commit message whose body has an apostrophe and the wordscriptis refused here and allowed on main.
Smallest fix: run the fail-closed check only on text the gate lexed whole, meaning the top-level command or a token from the quote-aware split. One way is ablind: boolkeyword on_refusal, set when you recurse from a_segmentsfragment. The# it'srows stay refused, because the comment breaks the lex at depth 0, andtimeout 300 bash -c 'cd x && git push'stays refused through the-crecursion. Add_ALLOWEDrows such astimeout 300 bash -c 'cd /x && python -m pytest -q "t.py"',nohup sh -c 'echo "start"; sleep 1'andenv A=1 bash -c 'ls; echo "x"'. If any over-refusal stays (for example the heredoc case), list it under Backwards compatibility.
Done well: main's quote-blind split still always runs, and the property test over every row pins that a command main refuses stays refused.
Optional:
- Deleting the
shlex.join(wrapped)half of the wrapper check leaves every test green and letssudo script -c 'timeout 5 git push' /dev/nullthrough again. A_REFUSEDrow for that command would pin it. - The last push widened the
**Goal:**line and## Not a goalwith no request from a maintainer. The$'...'fix was already in scope as a defect in added code, so the original wording could stay. - The body still calls #22408 open (it is merged, and this PR builds on its
_segmentshelper), and the Proof line names head 7878937 instead of the current head.
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the rebase. This head changes none of the touched files since d5e2843, so item 1 from my last review still reproduces. I am requesting changes again.
Earlier items:
- Item 1, wrapped
bash -cscripts refused: still stands (see below). - Optional, the
eval $'...'disposition: fixed on the earlier head, and still fixed. - Optional, a quoted lone separator read as a split: fixed on the earlier head, and still fixed.
- Optional, a row that pins the re-quoted
shlex.joinwrapper join: still open (see Optional below).
auto_improvement/spine/agent_runner_gate.py:310-318. The fail-closed branch still runs on fragments from the quote-blind split. Trigger: a wrapper from_COMMAND_WRAPPERS(timeout, nohup, env, nice, time, sudo) in front of a shell-cscript that holds&&,;or|. Examples aretimeout 300 bash -c 'cd /repo && python -m pytest -q',nohup sh -c 'echo "start"; sleep 1',env A=1 bash -c 'make && make test'andnice -n 5 bash -lc 'cd x; pytest'. Outcome: line 332 cuts inside the quoted script and givestimeout 300 bash -c 'cd /repo. The wrapper branch then passesbash -c 'cd /repoto_refusalone level down. There shlex raises, and the gate returns "command holds a nested script the gate cannot parse". The runner's permission handler then rejects the call asshell_denylist. Main allows every one of these commands, and barebash -c 'cd /x && pytest'is still allowed on this head. So the unattended runner loses its usual way to put a time limit on a test run, and the reason it is given is wrong. These commands lex cleanly at the top level, so the Backwards compatibility section and spec bullet D-143 do not cover them. No_ALLOWEDrow has a wrapper, a shell-cand a separator together, so the test file stays green.
Smallest fix: run the fail-closed check only on text the gate lexed whole, meaning the top-level command or a token from the quote-aware split. One way is ablind: boolkeyword on_refusal, set when you recurse from a_segmentsfragment.timeout 300 bash -c 'cd x && git push'stays refused through the-crecursion. Add_ALLOWEDrows such astimeout 300 bash -c 'cd /x && python -m pytest -q "t.py"',nohup sh -c 'echo "start"; sleep 1'andenv A=1 bash -c 'ls; echo "x"'. If you keep an over-refusal on purpose (for example the heredoc case), list it under Backwards compatibility and in D-143.
Done well: main's quote-blind split still always runs, and the property test over every row checks that a command main refuses stays refused.
Optional:
- If you delete the
shlex.join(wrapped)half of the wrapper check, every test stays green andsudo script -c 'timeout 5 git push' /dev/nullis allowed again. A_REFUSEDrow for that command would pin it. - The body still calls #22408 open. It is merged, and this PR builds on its
_segmentshelper. The Proof line names head 7878937, not the current head. Please correct both outside the frozen sections. - The red checks on this head (backend shard 6, Coverage Gate and Frontend Tests 1) fail in files this diff does not touch.
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The change only adds refusals: main's quote-blind split still runs on every command, and the new eval, script -c, $'...' and quote-aware handling each lead back to a command the denylist already names. I traced the key new refused and allowed rows by hand, plus the existing allowed commands in test_dogfood_learnings_tool_gate.py; all behave as expected. Only ValueError can come out of the tokenizer, and it is caught. There is one production caller and no state, config or limit changes. The blocking AI-lane findings are from an earlier commit and cover gaps that main shares and the PR lists as non-goals. Backend tests have not run in CI on this commit because of API rate limits and should be re-run before merging. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
|
|
|
|
|
|
@KiroCrewCaptain Review-ready on head fb99967: CI is green and readiness has passed. This head adds a comment state to the quote walk (an unquoted word-initial |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on one part. I read the whole diff and compared it with the head I last reviewed.
Fixed since my last review: the gh repo delete row is gone and the test now keeps it allowed. The eval, script -c and watch re-analysis, the quote-aware split and the wrapper handling apply main's existing git push and gh pr ready refusals to paths that skipped them, so they can stay on by default.
The new part is the fail-closed branch in _refusal in agent_runner_gate.py: if (not blind and tokens is None) or "$'" in text or '$"' in text: which returns "command holds a nested script the gate cannot parse". Main allows these commands, and this head refuses them:
bash -c "printf $'a\n'", which the spec in this PR calls out as refused although harmless.eval 'echo hi' # it's,sh -c 'ls' # it'sand anyeval,watch,scriptor shell-cline with an unclosed quote.
That is a new condition that makes a harmless command fail where main passes. Please keep main's behavior for it by default. Two ways that need no new refusal:
- For text the quote walk cannot read, run only the quote-blind split, as the previous head of this PR did and as main does.
- For
$'...'and$"...", read the$as a plain quote opener in the character walk, so the script inside is re-analyzed.eval $'gh pr ready 1'is then refused because the command is found, andbash -c "printf $'a\n'"stays allowed.
If you want the strict refusal kept, put it behind a setting that is off by default, and add tests for both states. Keep the quote-blind split as the safety net in either case.
I will look again when the head moves.
|
|
|
@bolichen97 @KiroCrewCaptain Review-ready on head b8cfda9: CI is green and readiness has passed. Per review 5887558754, this head adds no new refusal mechanism. Text the quote walk cannot read gets only main's quote-blind split, and the walk reads |
bolichen97
left a comment
There was a problem hiding this comment.
Approving. I read the whole diff and compared it with the head I requested changes on (fb99967).
- The fail-closed branch in
_refusalis gone. Text the quote walk cannot read, such as an unclosed quote or an apostrophe in a heredoc body, now gets only the quote-blind split, as on main, and is never refused for being unreadable. $'...'and$"..."are read as an ordinary quote opening at the$, so the script inside is re-analyzed.eval $'gh pr ready 1'is refused because the command is found, andbash -c "printf $'a\n'"stays allowed.- The
blindflag is removed along with the branch it served, and the docs and the D-143 bullet match. - New
_ALLOWEDrows pin main's behavior:bash -c "printf $'a\n'",eval 'echo hi' # it'sandsh -c 'ls' # it's. A new_REFUSEDrow coverseval $'gh pr ready 1'. The property test now calls the public gate, since no fragment is judged separately any more. - The
eval,script -candwatchre-analysis, the quote-aware split and the wrapper handling still apply main'sgit pushandgh pr readyrefusals to paths that skipped them. No regex in product code. - The cancelled runs on this head (PR Hygiene, GPT 6.1 Review, PR Policy, Issue Gate, Sensitive Change Review) each have a newer passing run, so they are stale.
I did not run the tests locally.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving head b8cfda9. This replaces my earlier change request.
Earlier items from my last review (on 6f3d6d7):
- Item 1, wrapped
bash -cscripts that hold a separator were refused: fixed. The fail-closed branch is gone.timeout 300 bash -c 'cd /repo && python -m pytest -q',nohup sh -c 'echo "start"; sleep 1',env A=1 bash -c 'make && make test'andnice -n 5 bash -lc 'cd x; pytest'are now allowed, as on main, and_ALLOWEDrows pin this shape. - Optional, a row that pins the
shlex.join(wrapped)join: fixed.sudo script -c 'timeout 5 git push' /dev/nullis now a_REFUSEDrow. - Optional, body wording: fixed. The body now says #22408 is merged, and the Proof line names this head.
What I checked on this head: I ran the gate from this head and from main on the commands above. eval git push, eval $'gh pr ready 1' and the sudo script -c row are refused on this head and allowed on main. bash -c "printf $'a\n'", eval 'echo hi' # it's, sh -c 'ls' # it's, gh repo delete o/p --yes and a heredoc commit message with an apostrophe are allowed on both. The review also compared 60,000 random commands against main and found none that main refuses and this head allows. It confirmed that every moved test row is still present, and that the new test file fails 33 refused rows when run against main's gate. PR Readiness is green, and every review lane passes on this head.
Security: this changes the unattended runner's shell denylist, and the change only makes it stricter. Main's quote-blind split still runs on every command, so whatever main refuses is still refused. The new refusals are eval, nested-shell, script -c and $'...' spellings of commands the denylist already names. No denylist row is added, and no command is refused just because the gate cannot parse it.
Done well: the property test over every row and the call-count cost test each pin one of the two properties that matter, and neither depends on timing.
The design is signed off under the standing maintainer sign-off for changes by team members.
Optional:
- No test row pins three new walk lines in
agent_runner_gate.py, though each one blocks a real bypass: the substitution-opener mark, the\x00re-walk of a quoted substitution, and the backslash-escape branch. All tests stay green if you delete any one of them. Rows such asecho "$(sh -c 'true; git push')"andecho \'; sh -c 'true; git push'; echo \'would pin them. - The quoted-substitution re-walk adds a few narrow over-refusals that the Backwards compatibility section does not name. One example is
echo "$(date) curl", which this head refuses and main allows, although bash never runs curl there. You could list these, or re-walk only the text inside the substitution. - The fix can be proven: the new test file fails 33 rows against main's gate in a few seconds, so the Proof line can say PROVEN. Also, the
if tokens is Nonemutant fails 14 tests (7 rows plus 7 property rows), not 16.
Problem / Motivation
Goal: The Auto Improvement runner's shell gate refuses a command it already refuses (
git push,gh pr ready, ...) even when that command is run througheval, a nested shell script, or a wrapper, including when the script is spelled with bash's$'...'/$"..."quoting.Today
shell_command_refusalrefusesgit push --force origin mainbut allowseval git push --force origin main,sh -c 'git push; true'andscript -c 'git push' /dev/null.Why it matters
The runner is unattended and reads outsider-written PR text. A prompt injection that says "run
eval git push ..." gets past the gate today. One word in front of a refused command should not turn it into an allowed one.Not a goal
ghwith an allowlist of read-only verbs. That is a design choice, left to a maintainer. This PR adds one denylist row only.gh repo deleteand the other repo-changinggh repoverbs (archive,rename,edit). Main has no rule for them, so refusing them is a new restriction: left for a follow-up with an off-by-default setting. An allowed row pinsgh repo delete o/p --yesas allowed.glab. Theglaballowlist (feat(auto-improvement): support GitLab repositories alongside GitHub #22408, merged) edits the same tables; this PR reuses its_segmentssplit and does not touch its rows.scriptspellings (script -c'git push',--comm='git push'). Main allows these too; not fixed in this slice.$'...'(eval $'gh pr rea\x64y 1'). The walk reads$'...'as a quote and does not decode escapes; main allows these too (maintainer review 5887558754 asks for no new refusal mechanism here).cat <<EOF/it's/EOFaroundsh -c "true;gh pr ready"). Main allows this too.What changed (motivation → approach → change)
eval git push --force origin maineval 'GH_TOKEN=x gh pr merge 1',script -c 'git push' /dev/nullgh repo delete o/p --yessh -c 'git push; true',eval 'true; git push'eval 'gh pr ready 1' # it's,eval $'gh pr ready 1'rg -F '$(curl' src,printf '%s\n' ';' curl,git commit -m "fix; gh pr ready"echo hi # don't, heredoc withit's,echo hi > ./curlwatch 'git push',command -p eval 'curl …'evalhad no handling, so the gate checkedevalitself and never the command behind it. It now has its own branch: the words afterevalare joined and checked again as a script, with the existing depth limit, before any option orVAR=valuestripping.A refused command could also hide behind a
;,&&or|inside a nested script, because the gate split on those characters before it read quotes. It now walks the characters with quote state, marks only unquoted separators and the substitution openers that bash runs ($(and backticks outside single quotes), then letsshlex(posix=True,punctuation_chars) split on those marks. Quoted text is data:printf '%s\n' ';' curlandrg -F '$(curl' srcstay allowed, as on main. A;inside ansh -corevalscript still starts a new command, and$(...)inside double quotes is still checked. No regex is involved.Design: the gate checks the union of both splits. The old quote-blind split (main's) always runs, and the quote-aware split only adds more commands to check. shlex and bash read some quotes differently (comments, heredocs,
${x:-"'"}), so the quote-aware split alone can be fooled; with both, whatever main refuses stays refused, and a test over every table row pins that. When shlex cannot parse the text (an apostrophe in a heredoc, or an unclosed quote), only the quote-blind split runs, as on main; no command is refused for being unreadable (maintainer review 5887558754). The walk reads$'...'/$"..."as a quote opening at the$, as bash does, so the script inside is re-analyzed:eval $'gh pr ready 1'is refused because the command is found, andbash -c "printf $'a\n'"stays allowed. Redirections (<,>) do not split, so a redirect target such as./curlis read as a file name, as on main.A wrapper's command is checked both as plain joined words (what main checked, and what
watchandscripthand to a shell) and re-quoted (what an exec-style wrapper likesudoorenvpasses on); either refusing refuses. Each distinct command is checked once, and the second join only when it differs from the first, so nested wrappers cost about one check per level rather than four.script's-c/--command[=]value is checked as a script before its options are skipped, soscript -q /dev/nullandscript -c 'ls' /dev/nullstay allowed.docs/system-specs/modules/auto-improvement.mddescribes theeval,script -cand quote-aware handling (D-143).The gate's test rows move from
test_ai_agent_runner_coverage.pyto a newtest_ai_agent_runner_shell_gate.py, which keeps the first file under the 2,000-line cap.The denylist itself is unchanged: it gains no rows. Only ways around the existing rows are closed.
Backwards compatibility
Breaking: the gate now refuses
eval <refused command>, a refused command after a separator inside a nested script, andscript -cwith a refused command. Main allowed all three; each only reaches a command main's denylist already names. No command is refused for being unreadable: text shlex cannot parse gets main's quote-blind split only, soeval 'echo hi' # it's,sh -c 'ls' # it'sandbash -c "printf $'a\n'"stay allowed (maintainer review 5887558754). The walk treats an unquoted word-initial#as a comment to the end of the line, as bash does, sols # it's fineandecho a#bstay allowed. Over-refusals kept on purpose, each needingeval,watch,scriptor a shell's-c: a heredoc body holding one of them around a refused command, a shell-cwhose later positional argument holds a separator, and a wrapper in front of quoted$(or separator data (timeout 5 rg -F '$(curl' src), read through the plain wrapper join. Everything main refuses is still refused (the quote-blind split and the plain wrapper join both still run). Writer sweep on origin/main @ 48dee00:shell_command_refusalhas one production caller,spine/agent_runner.py(the permission-request handler), and it only judges commands the model asks to run. No code or prompt underapps/builtins/auto_improvementsendsevalor a nested script holding a refused command, so nothing the app itself runs is refused.Removes nothing: the change adds refusals only; no key, path, record or function is removed.
Tests
test_ai_agent_runner_shell_gate.py(the moved denylist rows) gains_REFUSEDrows for each row of the issue table;eval '...',sh -c '...'andbash -c '...'around a refused command; the quoted-=evalscripts; the separator bypasseseval 'gh pr ready 1; true',sh -c 'git push && true',sh -c 'git push; true',eval 'true; git push';$(...)and backticks inside double quotes; a"nested in${...}hidinggit push;command -p eval 'curl …'; agit pushhidden by a quote in a comment (true # '\ngit push\n# ') or by a"nested in$(;watch 'git push',watch -n 1 'gh pr ready 1';$'...'hidinggit pushorgh pr merge;script --command 'git remote set-url ...',script -c 'git push' /dev/nullandscript --command='gh pr ready 1' /dev/null; a trailing# it'saftereval '...',sh -c '...'andscript --command '...', or before a newline andsh -c '...';echo a#b; git push. Allowed rows addscript -q /dev/null,script -c 'ls' /dev/null,echo hi # don't, a# don'tcomment aftergit status, a heredoc holdingit's,printf x > test/bin/ssh,echo hi > ./curl, the quoted-data rowsrg -F '$(curl' src,grep -F '`curl' README.md,printf '%s\n' ';' curl,printf '%s\n' '&&' curl, andprintf $'a\n'._REFUSEDaddseval,bash -c,script -c,script --command=andwatcharound$'gh -R o/p pr ready 1', andeval $"gh -R o/p pr ready 1". New_ALLOWEDrows pin the ordinary commands that must keep working:git commit -m "a; b",git commit -m "fix; gh pr ready",python3 -c "import os; print(1)",echo 'x && y',gh pr view 1 --jq ".body | length",grep -E "a|b" f,git log --format="%h; %s",eval echo hello,gh repo view o/p.A property test runs over every refused and allowed row: whenever one quote-blind segment is refused on its own, the whole command must be refused. A cost test counts
_refusalcalls for"sudo "*6 + "x "*500and caps them at 2 per wrapper level; removing either dedupe gives 127 calls and fails it.Hand mutants against these rows: disabling the
evalbranch fails theevalrows; running the quote-blind split only when shlex fails fails 16 rows (8 refused rows plus the property test on them); dropping the plain wrapper join fails bothwatchrows and thecommand -p evalrow; disabling thescript -ccheck fails bothscript -c/--command=rows; dropping the walk's quote state fails the four quoted-data rows; dropping the re-quotedshlex.joinwrapper join failssudo script -c 'timeout 5 git push' /dev/null. Not reading$'/$"as a quote fails the eight$'...'/$"..."rows, includingecho hi # it's/eval $'gh pr ready 1'/# it's. Dropping the walk's comment state fails the eight comment-apostrophe_REFUSEDrows (the five# it'ssuffix rows,echo hi # it's/eval $'gh pr ready 1'/# it's, and thesh -c/eval"true;gh pr ready" pair).Proof: not provable -- other: prove.py timed out on head b8cfda9 (baseline run over 900s); the hand mutants above stand in.
Manual verification
N/A — unit coverage sufficient: the gate is a pure function of the command string, and every shape is a test row.
Related Issues
Part of #29851
Sibling sweep
Swept:
git grep -nE "_COMMAND_WRAPPERS|_SHELL_BINARIES|_FORBIDDEN_SUBCOMMANDS" -- src/Sibling: src/kiro_crew/apps/builtins/auto_improvement/spine/agent_runner_gate.py -- changed here
Sibling: src/kiro_crew/hooks.py -- not affected -- the platform deny rules there are regex rules, not this wrapper-unwrapping tokenizer.
Pattern harvest
Rule candidate: review-prompt
Pattern: a shell denylist must read quotes before it splits on separators, and must unwrap every builtin that runs its arguments (
eval,exec,command,builtin), not only PATH binaries.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)