Skip to content

fix(security): read a git grep pager as a program in the self-kill floor - #34166

Open
CrysisDeu wants to merge 1 commit into
mainfrom
crew/bug-resolve/34098-git-grep-pager
Open

CrysisDeu wants to merge 1 commit into
mainfrom
crew/bug-resolve/34098-git-grep-pager

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a git grep whose pager would kill the product is refused by the self-kill floor, in each of the five spellings #34098 lists, with no ordinary git grep newly refused.

git grep runs a pager over the matching files. The pager is taken from -O / --open-files-in-pager, a -c core.pager= / -c pager.grep= global option, or GIT_PAGER / PAGER in the environment. The self-kill argv floor reads pkill / killall only as a word of the command line, so a kill handed to git as a pager was judged allowed. Each of the five forms in #34098 returned None from security.is_denied on main.

Why it matters

The self-kill floor stops an agent from terminating the gateway that runs it. These forms get around it with one git grep call.

Not a goal

  • git log / git show pagers. The issue scopes this to git grep.
  • A pager.<alias> key for a user-defined alias. -c pager.grep= is in scope and handled exactly like -c core.pager=; values set outside the git command ("$x", export, --config-env with an unseen variable) are known limitations (below), not non-goals.
  • Any change to the regex tier or the catalog.
  • Mixed-case shell wrappers (BASH -c, Sh -c) bypass non-kill deny rules on main; that is out of scope here. The shell-name fold this PR adds is used only by the self-kill floor's pager read.
  • Being stricter than git for anything but the exact pager spellings the issue names: an ordinary git grep (patterns, -e/-f values, pathspecs, a non-killing pager) keeps its current verdict.

Intended? / Repro

Intended? No. Nothing in docs/system-specs/modules/security.md, the floor's docstrings or git history says a pager kill should pass. #34097 (chenmingwei23's draft) pins these five forms as strict xfail against its own test file and the issue says the fix should turn each into a refusal. On main the kill check is _is_self_kill in src/kiro_crew/security/argv_floor_self.py: it tests each token with _is_kill_by_name_program, and a pager value such as the token -Opkill -f kirocrew # or core.pager=pkill -f kirocrew never has pkill as its basename.

Repro (origin/main @ ddb535e187): I called security.is_denied directly from a small script, without running the test suite. With <K> a by-name kill program and <F> a tracked file, all five returned None:

  • git grep -e x -- <F> -O'<K> -f kirocrew #'
  • git grep -nO'<K> -f kirocrew #' -e '*;' -- <F>
  • git -c core.pager='<K> -f kirocrew' grep -e '*;' -- <F>
  • GIT_PAGER='<K> -f kirocrew' git grep -e '*;' -- <F>
  • a=('-O<K> -f kirocrew #'); git grep "${a[@]}" -e '*;' -- <F>

Real git 2.50.1 in a scratch repo, with a pager that only writes a marker file, confirms the -nO and array forms run the pager with no terminal; -c core.pager and GIT_PAGER are the pager git uses when it paginates. Form 1 (-O after --) is read as a pathspec by git 2.50.1 and runs nothing there, but -O after a pathspec with no -- is parsed as an option and does run; the floor refuses the -O pager spelling regardless, since it cannot know which git is installed.

What changed (motivation → approach → change)

  • Root cause: a pager value is one word to the tokenizer, so the kill check never sees its program.
  • Approach: read the pager git would run, then ask the same _is_self_kill about it. _git_grep_pager_commands (new, argv_floor_self.py) rebuilds each frame's commands from that frame's text as submitted. It decodes $'…' with _decode_shell_quoted_literals and takes commands and words from the shared reader shell_commands.read_commands, which walks _iter_shell_chars and cuts only at unquoted separators, so quoting is read in one place and a quoted ; or | inside an argument (-e 'x|y') does not cut one git grep in two. A wrapping shell's name is matched in any case (BASH -c) for this read only, through _shell_payload_walk(..., fold_shell_names=True); every other caller keeps the case-exact match. For each git grep command it reads only the positions git parses as options for that invocation:
    • git found after any wrapper and VAR=x words, with the existing argv_rules._program_args step-over (sudo, env, timeout 5, …); a GIT_PAGER= / PAGER= word anywhere before git;
    • a -c core.pager= / -c pager.grep= option between git and grep (key case-folded, as git folds config keys); every git global option that takes the next word as its value (-C, -c, --git-dir, --work-tree, --namespace, --super-prefix, --config-env, --attr-source) skips that word, so git -C . grep -O… and git -c user.name=x grep -O… reach grep; a bare --exec-path, --version/-v or --help/-h ends the read, since git then prints or runs version/help and never runs grep;
    • among grep's own arguments, the LAST -O<cmd> / --open-files-in-pager=<cmd> (git's rule, so -O<kill> -Ocat runs cat), including each element of a literal array expanded there. "${a[*]}" is one word, "${a[@]}" one per element, unquoted forms split, and an expanded element never takes the real word after it as its value;
    • the environment and config pagers count only when git would page: a later -P / --no-pager, or a git-boolean-false -c pager.grep (false, no, off, 0, empty; the last one wins), turns them off. An explicit -O<cmd> still runs either way, as in git.
      A short cluster is walked one letter at a time, as git's parse-options walks it: O is the pager only before the first letter that takes a value (e, f, m, A, B, C), because the rest of the cluster is that value. So -nO<cmd> and -FO<cmd> run a pager, and -eO<cmd> / -C3O<cmd> do not. A separate value word is skipped too (-e <pattern>, -f <file>, --regexp, --context, … and unique prefixes of them), so a kill-shaped pattern is never read as a pager. _is_self_kill is called on each pager command; a pager string is a substring of one word, so strictly shorter and the recursion ends.
  • Case is matched exactly. git's short options are case-sensitive (-F/-E are flags; -f/-e take a value), and the floor otherwise reads lower-cased text, which hid -FO<cmd>. deny_gate now hands _is_self_kill the command as submitted (raw_text=), the same way it already does for _is_credential_mint, and only the pager read uses it. Every other kill shape in _is_self_kill still reads text_lower, and a pager command is recursed on as command.lower(), so no other verdict depends on case. Checked by running 22 non-git grep kill shapes (PKILL -f kirocrew, Kill $PPID, KILL -9 $(pgrep …), Kill $(pidof KIROCREW), BASH -c '…', sudo PKILL …, echo PKILL …, kill 1234, echo 'a|b'; PKILL …, pkill -f 'kiro|crew', ls | grep -e 'x|y'; pkill …, kill -0 $$, …) through is_denied at origin/main and at this head: the outputs are byte-identical (15 refused, 7 allowed on both; Kill $PPID is allowed on both). The program name and the -c key are folded; GIT_PAGER / PAGER match as written, since POSIX environment names are case-sensitive. The security.md sentence that named mint as the only raw-text predicate is updated.
  • Long-option prefixes follow git. --open-files-in-pager is matched by a prefix only when that prefix is unique among grep's long options: --op=<cmd> runs the pager, but --o=<cmd> is ambiguous with --or, git refuses it, and the floor allows it as on origin/main.
  • No regex is added or widened. The reader's existing _ARRAY_EXPAND_RE is reused; everything else is argv walking.
  • Cost: one pass per frame. The linear-time test counts the characters passed to _grep_arg_pager (no clock): work(2000) <= 6 * work(500) and work(500) <= 2 * len(cmd). A planted per-word rescan fails it (ratio 15.8; the real code reads 4.0).
  • Arrays: the read makes its own pass over each text's commands, in order, and does not use the shared _array_assignments (unchanged from origin/main, so other floors keep their verdicts): the last assignment wins, a+=(…) appends, a[N]=… sets one index, a=x on an array sets element 0, and $a / ${a[0]} / ${a[N]} read one element.
  • Module: the pager read lives in a new owner module, src/kiro_crew/security/argv_floor_pager.py (1,016 lines), first in argv_floor._OWNERS; argv_floor_self.py imports only _git_grep_pager_commands from it and is 1,254 lines (1,235 on main).
  • The security package line budget rises by the 1,138 lines this PR adds to the package (36,794 → 37,932 on main f336729).

Wider alternative, and why it lost: make every pager value a nested payload in shell_normalizer._nested_shell_payloads, so every floor (mint, publish, kill) sees it, failing closed on any value the floor cannot resolve. That would also cover git log and unknown variables, but it changes what every floor sees, refuses ordinary git grep "$pattern" lines that open no pager, and AGENTS.md puts narrowing at the deciding site, not in the reader. This PR changes only the kill decision, for git grep, parsed as git parses it.

Rule for what is read: anything visible in the same simple command as the git call is read; anything set by an earlier statement is a known limitation, except plain scalar and array assignments earlier in the same text, which the issue's form 5 needs. So the floor reads GIT_PAGER= / PAGER=, GIT_CONFIG_COUNT / GIT_CONFIG_KEY_<n> / GIT_CONFIG_VALUE_<n> and GIT_CONFIG_PARAMETERS assignment words before git; -c core.pager= / -c pager.grep= (the last of each wins); --config-env=<key>=<var> when <var> is assigned before git on the same command; an inline -c alias.<name> chain that ends at grep; a git grep run by find -exec; and each command of a here-document fed to a shell that reads its script from standard input (bash <<EOF, bash -s <<EOF, bash -o pipefail <<EOF), at any depth. Array assignments earlier in the same text are the one exception the issue itself names (form 5), so they are read too (see Arrays above).

Review history: four blind adversarial review rounds (artifact and contract only) ran on earlier heads, and each returned BLOCK; what each found and fixed is in that head's Sensitive Change comment. Round 5 (this head) had no blind review: the four rounds are used, so its fixes are checked only by direct is_denied probes against origin/main and by CI. Round 5 fixed:

  • a number with more than 19 significant digits in GIT_CONFIG_COUNT, a GIT_CONFIG_KEY_<n> name or a subscript (assigned, read or compound) is never converted, so is_denied cannot raise; on the pager path the command is refused;
  • the "no git in this text" shortcut looks at the text with quotes, backslashes, line continuations and empty substitutions removed, so g''it, "g"it and gi\t are read;
  • a plain scalar set in the same chain is read as element 0 (p='-O<kill>'; git grep "$p", -O"$p");
  • an assignment after && / ||, in a pipeline or with & keeps the earlier value as a candidate, and each git grep is read under every combination (at most 8 candidates per variable and 16 combinations, else refused);
  • GIT_CONFIG_COUNT is read as git reads it (+1, leading zeros, k/m/g), and the numbered pairs come before GIT_CONFIG_PARAMETERS, which wins;
  • the one pager git runs is read, in git's order (GIT_PAGER, a pager.grep command, core.pager, PAGER), so GIT_PAGER=cat git -c core.pager=<kill> grep -O is allowed;
  • an alias whose words start with git's own -p / --paginate / -P / --no-pager resolves to grep;
  • the expansion budget is per git grep (MAX_SCANNABLE_COMMAND_CHARS), with 16 times that for a whole text, so the honest 3,194-char growing-array script passes.

Round 7 (head 1d20dfc): Security Scope Review on 9019655 confirmed three over-cap flag-toggling searches main allows (--only-matching, --or, -e 'core.pager=') that this PR refused. Past the caps, a grep word of plain characters now counts only when it is an -O cluster or a long option whose name (over 2 characters) is a prefix of --open-files-in-pager; any other word and every candidate value keep the wide test. Three blind review rounds; round 3 found no new allow and one false refusal (a bare --), fixed by the length guard. Allow and deny rows for these shapes are in the test file.

Round 8 (head 7721537): Security Scope Review on a5f6d2b confirmed one more over-cap false refusal main allows: five optional empty flags past the 16-combination cap, then a single-quoted regex (git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew). Past the caps, a grep word bash passes exactly as written (each character plain or quoted literally, _is_literal) now gets only the pager-option test, as a plain word already did; a killing -O, quoted or not, is still refused. Allow and deny rows are in the test file. One blind review round, CLEAN.

Round 6: the candidate caps count only values that could carry a pager, so the two scripts Security Scope Review found newly refused on round 5 are allowed again, and so is a variable past the cap that the git grep never reads (Opus, first round-6 push). Allow tests for both and deny tests for over-cap killing -O shapes are in the same commit. Rebased onto main ab16fd6 (#22646's refusal span), with the kill floor's span taking the command as submitted. No blind review for rounds 5 and 6.

Open, for a maintainer to rule (with severities):

  • Medium, bypass (GPT 6.1 on round 6, security-class): a bare -O inside an expansion after a literal -Ocat (a=(-O); git -c core.pager='<kill>' grep -Ocat "${a[@]}") is read as cat, but git runs the configured pager. origin/main allows it too.
  • Medium, bypass (GPT 6.1 on round 6, security-class): pager.grep=2 (and -1, +1, 01) is read as a program, but git reads it as true and runs core.pager. origin/main allows it too.
  • Medium, bypass (GPT 6.1 on 85b7117, security-class): an append after a conditional assignment (p=-Opk; false && p=-Ocat; p+='ill …') updates only the current value, so the killing result is never read. origin/main allows it too.
  • Medium, bypass (GPT 6.1 on 85b7117, security-class): bash - / sh - with a here-document is read as a script file, so the here-document body is not read. origin/main allows it too. Opus 5.5 flagged the same gap again on 205e859 (argv_floor_pager.py:355, a lone - read as a script file).
  • Medium, bypass (Opus 5.5 on 4c4576b): busybox sh <<EOF (and other busybox shell applets) is skipped outright (argv_floor_pager.py:432, program != "busybox"), so the here-document body is not read, though busybox sh runs it from standard input. origin/main allows it too.
  • Medium, bypass (GPT 6.1 on 205e859 and again on 2f69b67, security-class, upheld by its adjudicator): an array or scalar assignment in a subshell ((a=(-Ocat)), (p=-Ocat)), a command substitution (x=$(a=(-Ocat))), or a pipeline / background compound (a=(-Ocat) & wait) replaces the parent's value, so a=('-O<kill>'); (a=(-Ocat)); git grep "${a[@]}" -e x is allowed. A quoted or escaped assignment name ('a=-Ocat', which bash runs as a command) is read the same way. Bash keeps the parent's killing pager. origin/main allows it too.
  • Medium, bypass (Opus 5.5 on 9019655): bash -eo pipefail <<EOF reads pipefail as a script file (_shell_reads_stdin steps one word past a cluster ending in o), so the here-document body is not read; same as the lone - entry above. origin/main allows it too.
  • Medium, bypass (blind review of the held narrowing, pre-existing on this head): an expansion that ends in a value option shifts which word is a value: a=-e; git grep $a -e '-O<kill>' is read with -O<kill> as the pattern, but git runs it as the pager. set -k also moves assignment-shaped grep words (GIT_PAGER=…) into git's environment, which the floor does not read. origin/main allows both.
  • Medium, over-refusal (Security Scope Review on 1d20dfc, script-confirmed): past the candidate caps the floor still refuses an over-cap git grep carrying a literal non-killing -O (-Ovim, -Ocat; GPT 6.1 too), or a quoted pattern with a space that names a pager setting or a --o… word (-e 'core.pager = less', -e 'kirocrew --open'). main allows these.
  • Medium, bypasses (Opus 5.5 on 1d20dfc): an unquoted $(…) before the -O word cuts the command so git is not found (git grep -e x $(true) -O'<kill>'); git appends matching paths to the pager, so -O'pkill -f' … -- kirocrew with a file named kirocrew runs a kill the pager text alone does not name; ${a[-1]} and ${p:-} are dropped as references. origin/main allows all three.
  • Medium, bypasses (GPT 6.1 on 1d20dfc, besides the subshell and expanded-order entries above): an empty expansion is counted as a word, so a=; git grep -e $a '-O<kill>' reads the pager as -e's value; an unconditional write after a conditional one keeps an obsolete killing candidate. origin/main allows both.
  • Medium, bypass (Opus 5.5 on 7721537): an array literal written across lines (a=( newline -i '-O<kill> -f kirocrew #' newline ), then git grep "${a[@]}" -e x -- src) is read as an empty array, because the shared reader cuts at the newline after a=( (argv_floor_pager.py:527), so the pager inside it is never checked. origin/main allows it too.
  • Low, over-refusal (GPT 6.1 on round 6): an unconditional element write (p=-Ocat after false && p=…) does not clear the earlier candidates, so a killing earlier value still refuses.
  • Low, over-refusals (GPT 6.1, downgraded by its adjudicator): option state does not carry across an expanded / literal word boundary, so a=(-e); git -P grep "${a[@]}" '-O<kill>' is refused although git reads that word as a pattern. A killing pager inside an array, or a configured one, is still refused when a later -Ocat or a --no-open-files-in-pager inside or after the expansion overrides it (GPT 6.1 again on 2f69b67, downgraded to LOW: an inserted -O is distrusted on purpose, because the array the floor read may not be the one bash expands).
  • Design (PASS) and First Principles (BLOCK on 2f69b67): both call the reader (1,016 lines now) a spelling chase. First Principles now blocks on it: items 5-9 of its inventory (mixed-case wrapper shells, alias chains, GIT_CONFIG_* / --config-env, find -exec and here-docs, conditional candidate sets and octal/hex subscripts) are outside the Goal's five spellings; it clears when those are removed or a human amends the Goal. Design suggests treating -O, core.pager=, pager.<cmd>= and GIT_PAGER= values as payload carriers in the existing _nested_shell_payloads walk, which would cover every paging subcommand. First Principles suggests dropping the here-doc, find -exec, alias, GIT_CONFIG_*, --config-env and conditional-world reads.
  • Medium: array forms not read: declare -a / local / readarray assignments, negative and arithmetic subscripts (${a[-1]}, ${a[i]}), slices (${a[@]:1}), and a copy through an expansion (b=("${a[@]}")).
  • Medium: export GIT_PAGER=… / export PAGER=… / declare -x / export GIT_CONFIG_* in an earlier command are not read; the value reaches git's environment outside the git command.
  • Medium: nested here-document cost. Each body fed to a shell is read once, but the shared reader rescans an inner body once per enclosing level, so a deep nest with git at the bottom grows about 4x per doubling (1.86 s at 13.4 KB through is_denied, origin/main 0.44 s; 0.25 / 0.67 / 2.0 s at 3.2 / 6.6 / 13.4 KB in this PR's own measure). Commands over 20,480 characters are refused before any scan, which bounds this. A linear read would need a new mode in the shared shell_commands.read_commands, which this PR does not add.
  • High (from round 3): an array expanded before the subcommand is not read: a=(-c core.pager='<kill>'); git "${a[@]}" grep -O x, cmd=(git grep -O'<kill>'); "${cmd[@]}" x.
  • Low: git config core.pager '<kill>' run as an earlier command; --config-env=core.pager=X when X is not assigned on the same command; aliases from config files; non-shell wrappers in upper case (SUDO, ENV) before git.
  • Low, over-refusals of commands that spell a product kill: -O<kill> after --; an array -O followed by a real -Ocat; --html-path / --man-path / --info-path missing from the exit options; unset a not tracked.
  • Low: git-level quoting (GIT_CONFIG_PARAMETERS, alias words) is split with shlex, which differs from git's sq_dequote / split_cmdline at the edges; no bypass was found.

Blind review rounds for each head are listed in that head's Sensitive Change comment.

Backwards compatibility

Compatible: a command is refused only when a git grep pager or pager setting in it runs a by-name kill of the product. Every other command gets the same verdict as on origin/main. Conditional values are kept once per distinct value. Past 8 of a variable the git grep reads, or 16 combinations, the floor refuses only when a candidate or a word of that git grep could carry a pager; inert candidates (rc=1 after each failed check, optional flags) are dropped and the current value is read, and a variable the git grep does not read never counts. The probe in Manual verification checks the allowed shapes, including a plain git grep, an -e pattern shaped like a pager (separate and glued, -eO…), -C3O…, a lower-case git_pager=, and an echo of a pager spelling after a git grep.
Removes nothing: no key, path, record or public function is removed. The shared _array_assignments and its caller are as on origin/main.

Tests

test/test_argv_floor_git_grep_pager.py (new, ours — this PR does not touch #34097's file):

  • test_the_five_named_pager_forms_are_refused: the five Self-kill argv floor does not refuse five git grep pager forms #34098 forms.
  • test_adjacent_pager_spellings_are_refused: --open-files-in-pager=, --open= abbreviation, -c pager.grep=, PAGER=, an array with a leading decoy element, -O clustered after -F / -nE / a number (-3O), an upper-case GIT, a mixed-case -c Core.Pager=, sudo git grep -nO…, env GIT_PAGER=… git grep, and -O after a plain pathspec with no --.
  • test_a_git_grep_without_a_killing_pager_is_allowed: a plain git grep (also under sudo), -o/--only-matching/context flags, GIT_PAGER=less, git -c core.pager=<kill> log, the kill text as an -e pattern (separate, in an array, and glued as -eO…), -nC3O…, --reg '-O…', a lower-case git_pager=, the kill text in a separate echo command or echoed as GIT_PAGER=…, and git log --grep.
  • test_a_long_pager_option_list_is_checked_in_linear_time.
  • test_a_quoted_separator_before_the_pager_does_not_hide_it: a quoted ; and a quoted | before the pager, in forms 1, 2 and 5 (six cases). The allowed list adds git grep -e 'x|y' -n -- f, -e 'x;y' and the ambiguous --o='<kill>'.
  • test_a_capitalised_kill_is_still_refused, test_a_capitalised_command_that_kills_nothing_of_ours_is_still_allowed and test_the_submitted_case_changes_no_verdict_outside_a_git_grep: the raw-text hand-off changes no verdict outside a git grep (_is_self_kill(lower, raw_text=cmd) == _is_self_kill(lower)).
  • test_adjacent_pager_spellings_are_refused also covers a value-taking global option before grep: git -C ., git -c user.name=x, git --git-dir .git, and -c Pager.Grep=<kill> / a later pager.grep=true turning core.pager back on.
  • test_quoting_wrappers_and_array_boundaries_do_not_hide_the_pager: $'…' pager words, BASH -c / Sh -c, and array boundaries ("${a[*]}" before a real -O).
  • test_a_git_grep_without_a_killing_pager_is_allowed adds git -P / --no-pager with a killing core.pager, last -O wins (-O<kill> -Ocat), and -c pager.grep=false / Off with a killing core.pager or GIT_PAGER.
  • test_the_shell_name_fold_reaches_only_the_self_kill_floor: with the pager read's shell-name fold switched off, no verdict on a non-kill command changes.
  • test_a_pager_the_same_command_shows_is_refused and test_a_pager_the_same_command_overrides_or_never_runs_is_allowed: one deny and one allow case for each of the here-document, --no-open-files-in-pager, last pager.grep / core.pager, GIT_CONFIG_*, --config-env and inline alias reads.
  • test_an_array_pager_is_read_as_bash_assigns_it and test_an_array_element_bash_does_not_pass_is_not_read: one deny and one allow case each for a later re-assignment, +=, a[N]=, "$a", "${a[0]}" and "${a[N]}".
  • test_repeated_array_references_are_read_once: work counted up to 36 KB for a long element and for many short ones; 4x the command costs at most 6x the work (measured 4.0x; the previous head measured 16x).

Proof: not provable -- other: the host forbids local test runs, so the prepare-pr prove.py cannot run here. Behaviour was checked by calling security.is_denied directly at both commits (see Manual verification).

Once this and #34097 both merge, #34097's strict-xfail tests for these five forms should flip to pass; this PR's own tests are the forward-looking pins in the meantime.

Manual verification

I called security.is_denied directly from a script (this does not run the test suite), with the worktree's src on PYTHONPATH:

  • 22 refusal shapes (adds git -C ., git -c user.name=x, git --git-dir .git, git --no-pager -C ., and a second -c after a non-pager one) — the five named forms plus the adjacent spellings above (-FO, -nEO, -3O, GIT, Core.Pager, sudo, env GIT_PAGER=, timeout 5, cd … &&) — all refused with rule=self-protection-kill.
  • 18 allowed shapes — plain git grep (also under sudo and git -C .), a kill spelling as the value of -C or -c user.name=, -no/-C 3/-Ovim, GIT_PAGER=less, lower-case git_pager=, git -c core.pager=<kill> log, the -e-pattern cases (separate and glued -eO…), -nC3O…, --reg '-O…', the two echo cases, git log --grep — all allowed, each matching origin/main's verdict.
  • Cost: 4000 pager-shaped words 0.57 s; 3000 stacked sudo words 0.13 s; 3000 -C . pairs 0.17 s; an 800-deep nested git grep -O… pager 0.18 s.
  • 22 more refusal shapes from the round 3 class: a quoted ; or | (single, double or backslash-escaped) before the pager in forms 1, 2 and 5, inside bash -c "…", after an earlier echo hi;, and in $( … ) — all refused. 14 more allowed shapes — git grep -e 'x|y' -n, -e 'x;y', --o='<kill>', a # git grep -nO… comment, an echoed git grep -nO… string, and the earlier allowed set — all allowed.
  • Cost: 3000 quoted -e 'a|b' words before the pager 0.29 s.
  • Cost near the 20,480-char ceiling matches origin/main within 0.1 s.

Blind adversarial review (a fresh reviewer given only the diff and the contract), round 1 on an earlier head: BLOCK with 3 findings. A value-taking git global option before grep (git -C ., git -c user.name=x) skipped the invocation; fixed and pinned. A wrapper before git (sudo, env, nice) skipped it; fixed via argv_rules._program_args and pinned. Nested git grep -O'git grep -O…' recursion was flagged as possibly quadratic (Optional); measured at 0.18 s for 800 levels, so it is left as is. Round 2 on the next head: BLOCK, one Required and one Optional. git --attr-source x grep -O… skipped the invocation; --attr-source and --config-env now take their value word, pinned. A bare git --exec-path grep -O… was refused though git runs no grep; it now ends the read, pinned as allowed. Round 3: BLOCK, one Critical, one Required, one Optional. The shared splitter strips quotes before it cuts commands, so -e 'x|y' before the pager cut one git grep in two and hid forms 1, 2 and 5; the pager read now rebuilds the command from the submitted text with quotes in force, and the shared splitting is unchanged (Critical). The tests now put a quoted ; / | before the pager (Required). --o=<cmd> was refused though git rejects it as ambiguous; a prefix must now be unique (Optional).

Screenshots / video

N/A: no user-visible UI change.

Related Issues

Fixes #34098

Sibling sweep

Swept: git grep -nE "pager|open-files-in-pager|core\.pager|GIT_PAGER" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/readonly_bash.py -- not affected -- it prompts for pagers on the read-only path; it does not decide self-kill
Sibling: src/kiro_crew/security/argv_floor_self.py -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: "a program run from an option or environment value (pager, editor, -exec) hides that program from argv-position checks; read it the way the host tool parses the invocation"

Known limitations

  • src/kiro_crew/security/shell_normalizer.py is 1,828 lines on this head against 1,790 on main (+38, this PR's own change); it is not split in this PR.
  • A -O value built by joining a variable with a quoted word (x=-O; git grep "$x"'pkill -f kirocrew' x) is not refused. This gap is on main too (probed on 5762722: is_denied False), so this PR does not make it worse.

Checklist

  • At most two commits (one here), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 9, 2026 22:40
@CrysisDeu
CrysisDeu requested a review from buluoray November 9, 2026 22:40
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ad76aa1
  • What rule changed: the self-protection kill floor (self-protection-kill) now reads the pager a git grep would run (-O, --open-files-in-pager=, -c core.pager= / pager.grep=, GIT_PAGER= / PAGER=, literal array elements) and asks the same kill check about it. deny_gate hands _is_self_kill the command as submitted (raw_text=), as it already does for _is_credential_mint; only the pager read uses it.
  • Before -> after (what was allowed/blocked, now): before, git grep -nO'pkill -f kirocrew' … and the other four named forms were allowed. After, they are refused, also behind wrappers (sudo, env, timeout), git global options (-C, -c, --git-dir, --attr-source) and quoted ; / | arguments. A plain git grep, an -e pattern shaped like a pager, an echoed pager spelling, --o= and git --exec-path grep -O… stay allowed, as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): an ordinary git grep is refused, or a kill-shaped pager still gets through. The first only fires when a pager slot holds a by-name kill of the product; the second leaves main's behaviour.
  • Evidence checked (which sandbox result proves it): direct security.is_denied probes at this head: 22 refusal and 14 allowed git grep shapes give the expected verdict, and 22 non-git grep kill shapes produce byte-identical output to origin/main (15 refused, 7 allowed). Four blind adversarial review rounds; the last returned LOW-ONLY.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, the comment-history, brand, file-line-cap and docs-lint gates, and the PR description check, all clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): _is_self_kill's new raw_text keyword defaults to None, so every existing caller and test keeps its call shape; _array_assignments' one other caller joins the list it now returns into the same string as before.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/argv_floor.py

  • src/kiro_crew/security/argv_floor_pager.py

  • src/kiro_crew/security/argv_floor_self.py

  • src/kiro_crew/security/deny_gate.py

  • src/kiro_crew/security/shell_normalizer.py

  • @CrysisDeu posted a complete reasoning template for 72f922e.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 72f922e814e88c8919d997949cfd49ae2bd8aad9 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 72f922e814e88c8919d997949cfd49ae2bd8aad9 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the floor reads a real shell command line, the fix reuses the existing kill check on the pager git would run, and nothing is taken away.

Notes

  • The roughly 1,000-line argv_floor_pager copies git's own option parsing: cluster walking, unique long-option prefixes, --config-env, alias.<name>=grep. That is upkeep that must follow git's parse-options rules forever. A cruder check would be cheaper: any pager-bearing word in a git grep whose value contains a kill-by-name program. It would wrongly refuse a few rare forms, such as -eO<kill>.
  • Any pager the agent writes to a file first (-O./k.sh) still gets past this floor. Record that next to the known limitations so the next issue doesn't start another round of chasing spellings.

[DESIGN-REVIEWED] 72f922e

Description read

[DESCRIPTION-READ] b940c285ec473fb7eb9464fc8c9dc10213ab188ed83eb299c41f9473e8d00f73

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 72f922e814e88c8919d997949cfd49ae2bd8aad9 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The five spellings in #34098 are real gaps, and no OS control covers them (the sandbox deliberately adds no PID namespace). The excess past the Goal can be deleted later, so it is a note rather than a block.

Notes

  • Items 5–7 — oversized: the Goal is "each of the five spellings Self-kill argv floor does not refuse five git grep pager forms #34098 lists", but the 1,024-line argv_floor_pager.py also emulates GIT_CONFIG_COUNT (k/m/g suffixes), --config-env, alias.<name> chains, find -exec, here-documents at any depth, and bash array semantics (a+=, octal or hex subscripts, candidate "worlds"). None of these is one of the five spellings. Subtraction: delete _env_config_settings, _git_count, _config_env_setting, _grep_subcommand's alias walk, _find_exec_spans, the here-document branch, and _TextState/_worlds beyond a single literal a=(…), keeping the reads for -O, -c, GIT_PAGER/PAGER and the plain array.
    Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (10 items) — 7 justified

Intent: stop an agent killing its own gateway through a git grep pager. FIX.

  1. A -O/--open-files-in-pager kill pager (including -nO clusters) is refused — justified
  2. A -c core.pager=/pager.grep= kill pager is refused — justified
  3. A GIT_PAGER=/PAGER= kill pager is refused — justified
  4. A -O kill pager expanded from a literal array is refused — justified
  5. Pagers set through GIT_CONFIG_PARAMETERS/COUNT and --config-env are read — oversized, beyond the five spellings
  6. Inline alias chains, find -exec and here-document bodies are read — oversized, beyond the five spellings
  7. Full bash array emulation with conditional candidates — oversized, beyond form 5
  8. A pager read too large to check is refused — justified
  9. Mixed-case wrapping shells are recognised for this read only — justified
  10. The MCP listing module ceilings each rise by 1 — justified

[FIRST-PRINCIPLES-REVIEWED] 72f922e

Description read

[DESCRIPTION-READ] 9056239dd2656560d36c02c398a81e56c124a73c8b1e7a50b9a7bac8364d59cd

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

Reviewed 72f922e814e88c8919d997949cfd49ae2bd8aad9 — this comment is updated in place on each push.

_array_refs reads a $name reference straight past a closing quote. So "$x"'…' builds a -O pager that the new self-kill read never expands, and a git grep whose pager kills the product gets through.

BLOCKING — src/kiro_crew/security/argv_floor_pager.py:950

end = _name_end(value, i + 1)
refs.append((i, end, value[i + 1 : end], 0))

Trigger: x=-O; git grep "$x"'pkill -f kirocrew' x (or "$x"pkill' -f kirocrew'). x=-O is stored as arrays['x']. _shell_word then gives the grep word $xpkill -f kirocrew, with quoting [2,2,1,…]. _name_end ignores that quoting, so _array_refs reads the name as xpkill. That name isn't in state.arrays, so expansion() returns None and _grep_arg_pager reads the word as plain.
Outcome: bash ends $x at the closing quote, so git gets -Opkill -f kirocrew and runs it as its pager, killing the product. The self-kill floor this PR adds to is_denied allows it, even though it reads the -O"$p" and ${x} spellings of the same scalar. Nothing in the sandbox isolates PIDs, so nothing else stops the kill.
Anchor: defect
Fix: pass quoting into _name_end and stop the name where the quoting state changes (quoting[end] != quoting[at]). Apply it to both the $name and ${name branches.

[BLOCK-MERGE] 72f922e
[OPUS-REVIEWED] 72f922e

Verdict parsed from the review's SHA-scoped output markers for commit 72f922e814e88c8919d997949cfd49ae2bd8aad9.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 72f922e814e88c8919d997949cfd49ae2bd8aad9 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 72f922e814e88c8919d997949cfd49ae2bd8aad9. Adjudication produced no [GPT-ADJUDICATED] marker for 72f922e: the adjudication stage FAILED TO RUN (its raw output is in the Adjudication details block -- typically an API or setup error), so no proportionality review took place and GPT's blocking verdict stands unreviewed.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/security/argv_floor_pager.py:405 -- Subshell assignments erase the parent’s killing pager

state.assign_list(opener[0], words, opener[1], conditional=opener[2])
Trigger: a=('-Opkill -f kirocrew #'); (a=(-Ocat)); git grep "${a[@]}" -e kirocrew -- src reaches is_denied → _self_kill_span → this shared-state update.
Outcome: The gate returns None, but Bash retains the parent’s killing array and Git executes pkill. The Linux sandbox permits these targeted signals, allowing the gateway to be terminated.
Anchor: residual/security
Fix: Preserve shell execution scopes so subshell, pipeline, and background assignments cannot overwrite the invoking shell’s array state.
Sites: Replacing (a=(-Ocat)) with a=(-Ocat) | cat or a=(-Ocat) & wait produces the same bypass.

BLOCKING -- src/kiro_crew/security/argv_floor_pager.py:408 -- Quoted command words overwrite assignment state

parts = [_assignment_parts(word) for word in sub]
Trigger: p='-Opkill -f kirocrew #'; 'p=-Ocat' || :; git grep "$p" -e kirocrew -- src reaches the pager reader, which recognizes the dequoted command word as an assignment.
Outcome: The gate returns None. Bash instead attempts to execute p=-Ocat, leaves p unchanged, and passes the killing pager to Git.
Anchor: residual/security
Fix: Use the retained quoting metadata when recognizing assignments; quoted or escaped assignment syntax must not update variable state.
Sites: 'p'=-Ocat and p\=-Ocat in place of 'p=-Ocat' produce the same bypass.

BLOCKING -- src/kiro_crew/security/argv_floor_pager.py:189 -- Expansion boundaries change Git’s option semantics

pending = "inserted" if leaves_pending else ""
Trigger: a=(-e); git grep "${a[@]}" '-Opkill -f kirocrew' -- src reaches is_denied → the pager reader → _scan_grep_args.
Outcome: The gate refuses a harmless search. Git consumes the following word as the -e pattern and runs no pager, but the reader classifies that word as a killing pager.
Anchor: a-sandbox-widening-is-not-incidental-scope
Fix: Scan the combined effective argv with one pending-value state and Git’s last-pager-wins semantics per candidate world.
Sites: _scan_expansion retains a killing pager in a=('-Opkill -f kirocrew #' -Ocat); _scan_grep_args also retains an expanded killing pager followed by a literal --no-open-files-in-pager, although Git runs neither.

BLOCKING -- src/kiro_crew/security/argv_floor_pager.py:733 -- Unconditional writes retain obsolete killing candidates

current[index] = current.get(index, "") + value if appends else value
Trigger: p='-Opkill -f kirocrew #'; false && p=-Ocat; p=-Ocat; git grep "$p" -e kirocrew -- src reaches assign_word, then _worlds during pager inspection.
Outcome: The gate refuses the command because alternatives retains the earlier killing value, although the final unconditional assignment makes every execution use cat.
Anchor: a-sandbox-widening-is-not-incidental-scope
Fix: Apply unconditional element writes to every retained candidate and invalidate their cached versions, removing candidates made identical by the overwrite.
Sites: Replacing the final scalar assignment with p[0]=-Ocat produces the same false refusal.

[BLOCK-MERGE] 72f922e
[GPT-REVIEWED] 72f922e
False positive or not applicable? A repository writer can comment:
/ai-review override gpt 72f922e814e88c8919d997949cfd49ae2bd8aad9 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 72f922e814e88c8919d997949cfd49ae2bd8aad9 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 29 classified, 0 newly refused, 29 still allowed.
  • ubuntu-latest (platform posix): 29 classified, 0 newly refused, 29 still allowed.
  • windows-latest (platform windows): 5 classified, 0 newly refused, 5 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: This change adds a pager read to the self-kill argv floor. The read sits inside the sensitive-bash composite, so the classifier can rule on it. No regression has been confirmed by script yet, and I make no confirmation claim of my own. The refuse-instead-of-read paths (expansion budget, candidate and combination caps, a pager longer than its text) are a narrowing risk I can argue but have not demonstrated. They are named below and do not block.

TIGHTENING: the self-kill floor (_self_kill_span, sensitive-bash tier) now reads the pager a git grep would run, from the command as submitted, and refuses when that pager kills the product -- the threat is a kill passed to git as a pager, from argv_floor_self.py: for command in _git_grep_pager_commands(source): if command == _PAGER_OVER_BUDGET: return whole ... if _is_self_kill(command.lower(), raw_text=command): return whole, fed by deny_gate.py: span = _argv._self_kill_span(lower, raw_text=tool_name).

ADJUDICATED: 34 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix (29 rows) probes the parts of git and bash grammar the diff now models:

  • -O, a bare -O, --open-files-in-pager=, -nFO clusters, and the --only-matching / --or prefix rivals
  • GIT_PAGER= / PAGER=, -c core.pager, -c pager.grep=false, -p
  • arrays and conditional += / || assignments, a scalar -O"$pager"
  • find -exec, a here-document to bash, sh -c, sudo, timeout, git -C
  • the kill text written as a plain -e or positional grep pattern
  • kill-tier neighbours such as pgrep -fl

windows (5 rows) covers the spellings the diff assumes differently there:

  • backslash pathspecs
  • double-quoted -O"code --wait" and -c core.pager="less -R", because the reader tokenizes with POSIX quoting
  • cmd set GIT_PAGER=cat && and PowerShell $env:GIT_PAGER='cat';, because the reader only treats NAME=value words before git as environment

Not probed by any row:

  • git.exe as the program name. The reader's check found[0].lower() != "git" skips it, which can only under-match, not over-refuse.
  • Wrapping shells in upper case (BASH -c) on a case-insensitive host. The new fold_shell_names path is reachable only from this read.

UNADJUDICATED: Some refusals in argv_floor_pager._git_grep_pager_commands return _PAGER_OVER_BUDGET instead of a pager, and _self_kill_span then refuses the whole command. They are reached only after _self_floor_can_fire passes, i.e. the text names the product or carries $, `, [, {, *, ?, ~ or an escape. They fire on:

  • a GIT_CONFIG_COUNT or array subscript longer than 19 digits
  • an array expansion over MAX_SCANNABLE_COMMAND_CHARS per command, or 16x that per text
  • more than 8 conditional candidates per variable, or 16 combinations, when any candidate or grep word "may reach a pager" (_may_carry_pager_option counts any short-option word holding O and any non-plain -- word)
  • a resolved pager longer than the source text

A shell row could probe these, but a realistic legitimate input for them needs a generated script with more than 8 conditional reassignments of a grep option array that also carries an -O or a non-plain long option. I could not attribute such a script to a real code path, so I wrote no row. The case I would have submitted is a long generated CI wrapper that builds git grep options through many [ … ] && opts+=(…) lines, one of them --open-files-in-pager=…. Separately, _scan_grep_args deliberately does not treat -- as ending option parsing, so a real pathspec spelled -O… after -- is read as a pager. Only a pathspec that is itself a product kill would be refused, which is the attack shape, so I wrote no row for it.

[SCOPE-REVIEWED] 72f922e

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 9, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 10, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34098-git-grep-pager branch from ad76aa1 to cd866f6 Compare November 10, 2026 17:08
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: cd866f6
  • What rule changed: none since ad76aa1. This head rebases onto main 3694b2b and touches only tests. test/test_argv_floor_git_grep_pager.py builds its capitalised kill case from _TARGET.title() instead of a product-name spelling (brand gate), and its linear-time check carries a flake-ok reason (flake ratchet). test/test_security_gate_liveness.py merges main's package line budget with this change: 35,227 + 244 = 35,471, re-measured.
  • Before -> after (what was allowed/blocked, now): same as ad76aa1. No source line in src/kiro_crew/security/ changed in this push.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): same as ad76aa1.
  • Evidence checked (which sandbox result proves it): git range-diff against ad76aa1 shows only the three test edits above. The source changes are byte-identical to the reviewed head.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, the brand, comment-history and file-line-cap gates, all clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): unchanged from ad76aa1.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 10, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34098-git-grep-pager branch from cd866f6 to d7ad17c Compare November 10, 2026 18:25
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d7ad17c
  • What rule changed: none since cd866f6. CI on cd866f6 found three gaps that main's newer guards check. This push fixes them, and no floor logic changed:
    • src/kiro_crew/security/argv_floor.py: the facade's TYPE_CHECKING lists now name the 12 new argv_floor_self names, plus _ARRAY_EXPAND_RE, _array_assignments and _argv_rules from their home modules (test_facade_mirror_guards, test_argv_floor_facade).
    • test/test_argv_floor_git_grep_pager.py: the linear-time check times thread CPU over 2000 words instead of wall time over 4000. Wall time read 3.3 s on a loaded Windows/coverage shard. Uninstrumented, the read measures 0.115 / 0.14 / 0.28 / 0.56 / 1.12 s at 500 / 1000 / 2000 / 4000 / 8000 words, which is linear.
    • test/test_security_gate_liveness.py: the package line budget is re-measured at 35,486 (+15 for the facade lines).
  • Before -> after (what was allowed/blocked, now): same as ad76aa1.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): same as ad76aa1. The facade lines are under TYPE_CHECKING and do not run.
  • Evidence checked (which sandbox result proves it): an AST comparison run by hand, as the two facade tests do it: the facade's outside-home imports equal the served outside names, and every owner-defined served name is listed. No src/kiro_crew/security/ logic line changed.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, the comment-history and file-line-cap gates, all clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): unchanged from ad76aa1.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment). The test_slack_code_channel_* and test_session_markdown reds on cd866f6 also fail on feat(kas-auth): organization (external IdP) sign-in on the KAS vault #25758 with an unrelated diff, so they come from main.
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 10, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Request changes

Why: the decider found 2 problems and estimates an 80% chance that this change introduces a defect, at or above the 80% level where it asks for changes.

The PR adds a large git grep pager reader to the self-kill floor. The code confirms an admitted regression: once past the candidate caps, any literal -O cluster such as -Ocat gets the command refused, while main allows it. This breaks the stated 'no ordinary git grep newly refused' goal, and the CI security-scope adjudication failed with newly-refused candidates. Simple substitution spellings also appear to bypass the new check. Requesting changes.

Problems found:

  • Commands main allows (an over-cap git grep with a harmless literal -O pager) are newly refused. This contradicts the stated Goal of 'no ordinary git grep newly refused' and the backward-compatibility claim that every other command keeps its verdict. (src/⁠kiro_crew/security/argv_floor_pager.py, medium)
  • Simple substitution spellings of the very -O pager form the PR targets still get a product-killing pager past the new floor, so the protection the PR adds only covers some paths. (src/⁠kiro_crew/security/argv_floor_pager.py, medium)

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 acb83c213a · 1860 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 13, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34098-git-grep-pager branch from 1d20dfc to 4c4576b Compare November 13, 2026 03:58
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4c4576b
  • What rule changed: none since 1d20dfc. This head adds the four new pager-module names (_PLAIN_CHARS, _is_plain, _may_carry_pager_option, _grep_words_may_reach_pager) to the argv_floor facade's TYPE_CHECKING manifest, which test_facade_mirror_guards.py requires, and re-measures _PACKAGE_LINE_BUDGET to 36,953.
  • Before -> after (what was allowed/blocked, now): unchanged from the 1d20dfc template; the manifest is type-checker imports only.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): none, because the change is import-only and runs no rule.
  • Evidence checked (which sandbox result proves it): Backend Tests (3.12, 7) and (Windows) (2) failed on 1d20dfc with exactly these four names missing from the manifest.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, black and isort on the facade, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the facade's runtime forwarding is unchanged.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/34098-git-grep-pager branch from 4c4576b to a5f6d2b Compare November 13, 2026 17:11
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 13, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a5f6d2b
  • What rule changed: none since 4c4576b. This head is a rebase onto main ee52eac to clear a merge conflict. The only conflict was _PACKAGE_LINE_BUDGET in test/test_security_gate_liveness.py: main raised it to 35,997, so this PR's raise of 1,129 is re-measured from there, to 37,126 (src/kiro_crew/security/*.py total on this head).
  • Before -> after (what was allowed/blocked, now): unchanged from the 4c4576b template; no file under src/kiro_crew/security/ differs from that head except what main brought in.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the budget test fails on a miscount, which blocks CI and changes no verdict.
  • Evidence checked (which sandbox result proves it): the line total was counted on the rebased tree (37,126) and on origin/main (35,997, equal to main's budget).
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8 on the test file, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the rebase changes no rule code.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 7721537
  • What rule changed: one narrowing in argv_floor_pager.py, on the over-cap path only (past 8 candidates per variable or 16 combinations). A git grep word that bash passes exactly as written, because each character is plain or quoted literally (single quotes or a backslash), now gets only the pager-option test (_may_carry_pager_option), as a plain word already did. New helper _is_literal, named in the argv_floor facade's TYPE_CHECKING manifest. _PACKAGE_LINE_BUDGET re-measured to 37,135.
  • Before -> after (what was allowed/blocked, now): before, the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) was refused although origin/main allows it. After, it is allowed. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): blind adversarial review of the fix diff (artifact and contract only), verdict CLEAN: the option-only test is a subset of the full test, so the change can only allow more; every option shape is still caught on literal words; _shell_word's quoting marks match what bash passes. New allow row for the exact script, a deny row for a whole-quoted killing -O next to the same regex, and unit asserts for literal versus unquoted quoting.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, isort, file line cap and comment-history gate, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

@bolichen97 a maintainer ruling is needed on head 7721537 before this PR changes again.

GPT 6.1 blocks on three false refusals: commands origin/main allows and this PR refuses. All three are already listed in the description.

  1. Five optional flags set conditionally, then a literal -Ocat (git grep $i $w $n $l $c -Ocat -e kirocrew -- src), are refused once the read passes the 16-combination cap (argv_floor_pager.py:843).
  2. A literal -Ocat after an array that holds a killing -O is refused, though git runs only the last pager, cat (argv_floor_pager.py:188).
  3. A plain assignment after a conditional one (p='-O<kill>'; false && p=-Ocat; p=-Ocat) keeps the old killing value as a candidate, so the harmless git grep "$p" is refused (argv_floor_pager.py:733).

Which do you want?

  • (a) Accept them as documented costs. They stay under Known limitations, and nothing changes in the code.
  • (b) Redesign the option and value tracking: one ordered option state across literal and expanded words, and candidate invalidation on every write. That is the restructure First Principles questions, so this choice would also answer that lane.

No code change or push is planned until you pick.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 02acbf1
  • What rule changed: one narrowing in argv_floor_pager.py, on the over-cap path only (past 8 candidates per variable or 16 combinations). A git grep word that bash passes exactly as written, because each character is plain or quoted literally (single quotes or a backslash), now gets only the pager-option test (_may_carry_pager_option), as a plain word already did. New helper _is_literal, named in the argv_floor facade's TYPE_CHECKING manifest. _PACKAGE_LINE_BUDGET re-measured to 37,135.
  • Before -> after (what was allowed/blocked, now): before, the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) was refused although origin/main allows it. After, it is allowed. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): blind adversarial review of the fix diff (artifact and contract only), verdict CLEAN: the option-only test is a subset of the full test, so the change can only allow more; every option shape is still caught on literal words; _shell_word's quoting marks match what bash passes. New allow row for the exact script, a deny row for a whole-quoted killing -O next to the same regex, and unit asserts for literal versus unquoted quoting.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, isort, file line cap and comment-history gate, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase only: 02acbf1b2b is 77215373a9 on main 549cc1a. The one conflict was the security package line budget: main's 36,253 plus this PR's 1,138 = 37,391, counted on the tree. No code changed.

The re-run lanes on this head, for the open ruling (comment 6865561673):

  • First Principles BLOCK again on scope: it wants items 6–9 (GIT_CONFIG_* / --config-env, alias chains, find -exec and here-documents, branching assignments) removed, or a human to amend the Goal.
  • GPT 6.1, four fenced findings, not fixed here (blind-review rounds are used up and the ruling is pending):
    • Security: an explicit -O drops a stdout pager that pager.grep turned on (git -c pager.grep='pkill -f kirocrew' grep -Ocat …), argv_floor_pager.py:561.
    • Security: numeric true values (pager.grep=2, 01, +1) are read as a pager command, not as git's boolean true, so core.pager is missed (:538).
    • Security: a ( … ) subshell or an if false branch assignment overwrites the outer array's pager value (:410).
    • False refusal: after an expanded -e, a pattern spelled -O<kill> is read as a pager (:173).

Backend Tests shard 3 is main's red #37243 (test_back_to_back_rounds_keep_a_spend_bound), not this PR.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6af816c
  • What rule changed: one narrowing in argv_floor_pager.py, on the over-cap path only (past 8 candidates per variable or 16 combinations). A git grep word that bash passes exactly as written, because each character is plain or quoted literally (single quotes or a backslash), now gets only the pager-option test (_may_carry_pager_option), as a plain word already did. New helper _is_literal, named in the argv_floor facade's TYPE_CHECKING manifest. _PACKAGE_LINE_BUDGET re-measured to 37,135.
  • Before -> after (what was allowed/blocked, now): before, the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) was refused although origin/main allows it. After, it is allowed. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): blind adversarial review of the fix diff (artifact and contract only), verdict CLEAN: the option-only test is a subset of the full test, so the change can only allow more; every option shape is still caught on literal words; _shell_word's quoting marks match what bash passes. New allow row for the exact script, a deny row for a whole-quoted killing -O next to the same regex, and unit asserts for literal versus unquoted quoting.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, isort, file line cap and comment-history gate, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebased again for the line budget: head 6af816c2ed on main f336729, 36,794 + 1,138 = 37,932. No code changed.

New on this head, all left for the open ruling (comment 6865561673), not fixed here:

  • Opus 5.5: a bare -O uses git's pager lookup (GIT_PAGER, core.pager, PAGER) even when pager.grep=false, -P or --no-pager is set, and the floor counts that pager as off (argv_floor_pager.py:564).
  • GPT 6.1: three findings on the branching-assignment and array-expansion reads (:671, :188, :733), the same class as the four listed earlier today.
  • Security Scope: one script-confirmed new refusal, git grep $i $w $n $l $c -Ovim -e kirocrew -- src after optional-flag assignments (the over-cap class already listed).
  • Backend Tests shard 7: test_the_scan_is_linear_not_quadratic took 0.501s against a 0.5s budget. That path never reaches the pager read (it returns early without git), so it is rerun once as runner noise.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: fa07317
  • What rule changed: one narrowing in argv_floor_pager.py, on the over-cap path only (past 8 candidates per variable or 16 combinations). A git grep word that bash passes exactly as written, because each character is plain or quoted literally (single quotes or a backslash), now gets only the pager-option test (_may_carry_pager_option), as a plain word already did. New helper _is_literal, named in the argv_floor facade's TYPE_CHECKING manifest. _PACKAGE_LINE_BUDGET re-measured to 37,135.
  • Before -> after (what was allowed/blocked, now): before, the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) was refused although origin/main allows it. After, it is allowed. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): blind adversarial review of the fix diff (artifact and contract only), verdict CLEAN: the option-only test is a subset of the full test, so the change can only allow more; every option shape is still caught on literal words; _shell_word's quoting marks match what bash passes. New allow row for the exact script, a deny row for a whole-quoted killing -O next to the same regex, and unit asserts for literal versus unquoted quoting.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, isort, file line cap and comment-history gate, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase only: head fa07317403 on main 1dee6bb8ed, to clear a new conflict.

  • shell_normalizer.py: main added literal_single_quotes to _shell_payload_walk and its uncached walk, this PR added fold_shell_names. Both walks now take both. The memo key carries both, so a folded and an unfolded walk never share frames.
  • argv_floor.py: the type-checker imports keep main's read_commands and this PR's MAX_SCANNABLE_COMMAND_CHARS.
  • Line budget: main moved to rows, so _PACKAGE_LINE_BUDGET stays as main has it and test/security_line_budget/self-kill-git-grep-pager.txt carries +1137, this PR's own net delta.

No rule changed. The open ruling (comment 6865561673) is unchanged.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 6) is red on fa07317403, and it is this PR's, not main's. test_mcp_listing_import_budget.py counts one more kiro_crew module than its ceiling for mcp-cron, mcp-guide and mcp-mate (357 against 356 for cron). #29423 lowered the headroom on 11-14, and this PR's new security/argv_floor_pager.py loads with the security package. The fix is a +1 on those three ceilings with the reason, in the test file. I have not pushed it, because this PR waits on the ruling in comment 6865561673 before it changes again. Coverage Gate is red from the same shard.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: acb83c2
  • What rule changed: one narrowing in argv_floor_pager.py, on the over-cap path only (past 8 candidates per variable or 16 combinations). A git grep word that bash passes exactly as written, because each character is plain or quoted literally (single quotes or a backslash), now gets only the pager-option test (_may_carry_pager_option), as a plain word already did. New helper _is_literal, named in the argv_floor facade's TYPE_CHECKING manifest. _PACKAGE_LINE_BUDGET re-measured to 37,135.
  • Before -> after (what was allowed/blocked, now): before, the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) was refused although origin/main allows it. After, it is allowed. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): blind adversarial review of the fix diff (artifact and contract only), verdict CLEAN: the option-only test is a subset of the full test, so the change can only allow more; every option shape is still caught on literal words; _shell_word's quoting marks match what bash passes. New allow row for the exact script, a deny row for a whole-quoted killing -O next to the same regex, and unit asserts for literal versus unquoted quoting.
  • No regression:
    • Tools still work (which tools/commands were run, result): flake8, isort, file line cap and comment-history gate, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Head acb83c213a fixes the shard 6 red from my note above. It is test-only: test/test_mcp_listing_import_budget.py raises the mcp-cron, mcp-guide and mcp-mate ceilings by 1 each, following that file's rule for a raise ("names what it added and why a listing needs it"). The one module is security.argv_floor_pager, which argv_floor_self imports at module level. No rule changed, so the open ruling (comment 6865561673) is unchanged.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Rebase only: head 6a53abc37d on main 10e113c8d6 to clear a conflict in test/test_mcp_listing_import_budget.py; kept main's ceilings and applied this PR's +1 for mcp-cron, mcp-guide and mcp-mate on top (359 / 353 / 354, mcp-core stays 488), with its reason comment. Security line budget rechecked on the tree: 37,712 against 37,712, row +1137 unchanged. Still one commit.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6a53abc
  • What rule changed: none since acb83c2 (rebase only onto main 10e113c). The only conflict was test/test_mcp_listing_import_budget.py: main's ceilings are kept and this PR's +1 for mcp-cron, mcp-guide and mcp-mate (security.argv_floor_pager) is applied on top (359 / 353 / 354; mcp-core stays at main's 488). The security package line budget still holds on this tree: 37,712 lines against 36,897 + 815 in rows, and this PR's row (+1137) still equals its own delta under src/kiro_crew/security/*.py.
  • Before -> after (what was allowed/blocked, now): unchanged from acb83c2: the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) is allowed, as on origin/main. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): no logic change in this push; the blind adversarial review of the fix diff (verdict CLEAN) still applies. The allow row for the exact script, the deny row for a whole-quoted killing -O, and the unit asserts for literal versus unquoted quoting are unchanged.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, file line cap, comment-history and brand gates, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a248e3b
  • What rule changed: none since acb83c2 (rebase only onto main 10e113c). The only conflict was test/test_mcp_listing_import_budget.py: main's ceilings are kept and this PR's +1 for mcp-cron, mcp-guide and mcp-mate (security.argv_floor_pager) is applied on top (359 / 353 / 354), and mcp-core gets the same +1 (488 to 489) because main no longer leaves it room. The security package line budget still holds on this tree: 37,712 lines against 36,897 + 815 in rows, and this PR's row (+1137) still equals its own delta under src/kiro_crew/security/*.py.
  • Before -> after (what was allowed/blocked, now): unchanged from acb83c2: the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) is allowed, as on origin/main. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): no logic change in this push; the blind adversarial review of the fix diff (verdict CLEAN) still applies. The allow row for the exact script, the deny row for a whole-quoted killing -O, and the unit asserts for literal versus unquoted quoting are unchanged.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, file line cap, comment-history and brand gates, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Head a248e3bf31 fixes this PR's own red on 6a53abc37d: New-test stability failed test_the_package_modules_loaded_before_the_list_stay_under_the_ceiling[mcp-core] with 489 modules against main's ceiling of 488. Main has used up the room mcp-core had, so argv_floor_pager now needs +1 there too (488 to 489), and the reason comment names all four servers. Test-only, still one commit, no logic change.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

GPT 6.1 F4 on a248e3bf31 (argv_floor_self.py:815, echo bash -c "git grep -O'pkill -f kirocrew #' -e Rules -- AGENTS.md" refused): this is main's own reading, not a new one.

The pager check walks payloads with main's shared _shell_payload_walk, which yields a bash -c payload even when bash is an argument of echo. Main's direct kill check reads the same way. Probed with deny_gate.is_denied on main 10e113c8d6:

Command main this head
echo bash -c "pkill -f kirocrew" refused refused
echo bash -c "git grep -O'pkill -f kirocrew #' -e Rules -- AGENTS.md" allowed refused
bash -c "git grep -O'pkill -f kirocrew #' -e Rules -- AGENTS.md" allowed refused (the Goal)
echo git grep -O'pkill -f kirocrew #' -e Rules allowed allowed

So the echo row is refused for the same reason main refuses the echo-wrapped pkill: the pager kill is read exactly as a direct kill is. Skipping print-only verbs in the pager path alone would make it read differently from the kill check beside it. Fixing that walk for both would loosen main's kill check, which is outside this PR's Goal. No code change here; a fix belongs in the shared walk, for both checks at once.

git grep runs a pager over the matching files, taken from -O / --open-files-in-pager, a -c core.pager= / pager.grep= global option, or GIT_PAGER / PAGER in the environment. The self-kill argv floor read pkill/killall only as a command word, so a kill handed to git as a pager was allowed. Parse the pager the way git parses the invocation (skip the value of -e/-f, split on the command boundary) and refuse it when it kills the product. No new or widened regex.

Fixes #34098
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 72f922e
  • What rule changed: none since acb83c2 (rebase only onto main 44769db). Conflicts: src/kiro_crew/security/argv_floor.py (main added the owners argv_floor_ssh_gate and argv_floor_ssh_bodies and widened the type-checker shell_commands import; main's side is kept and this PR's argv_floor_pager owner, docstring mention, _shell_commands alias and MAX_SCANNABLE_COMMAND_CHARS type-checker import are applied on top; main already carried the _argv_rules alias) and test/test_mcp_listing_import_budget.py (main's ceilings and comments are kept and this PR's +1 for security.argv_floor_pager is applied on top: mcp-core 490 to 491, mcp-cron 360 to 361, mcp-guide 354 to 355, mcp-mate 355 to 356). The security package line budget holds on this tree: 38,776 lines against 36,897 + 1,879 in rows, and this PR's row is recounted to +1136 (from +1137), its own delta under src/kiro_crew/security/*.py now that main has the _argv_rules line.
  • Before -> after (what was allowed/blocked, now): unchanged from acb83c2: the over-cap script Security Scope Review confirmed on a5f6d2b (... [ -n "$CT" ] && c=-c; git grep $i $n $w $l $c -E 'core\.pager\s*=' -- src/kiro_crew) is allowed, as on origin/main. A killing -O… / --open-files-in-pager=…, quoted or not, is still refused past the caps, and so is any unquoted or double-quoted word that is not plain.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a literally quoted grep word that git reads as a pager option and the option test misses would be allowed past the caps; the option test is unchanged and still runs on every literal word.
  • Evidence checked (which sandbox result proves it): no logic change in this push; the blind adversarial review of the fix diff (verdict CLEAN) still applies. The allow row for the exact script, the deny row for a whole-quoted killing -O, and the unit asserts for literal versus unquoted quoting are unchanged.
  • No regression:
    • Tools still work (which tools/commands were run, result): black, isort, flake8, file line cap, comment-history and brand gates, docs lint, clean. No local test runs on this host; CI runs the suites.
    • Backward compatible (old config / old data / old callers still work, how checked): yes, the change only narrows a refusal; no other caller of _is_plain changed.
    • Existing tests (which suites passed on this head): CI on this head (pending at the time of this comment).
  • How to undo: revert the commit; the floor returns to reading only argv programs and no data or config changes.

This branch has not been deployed

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

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-kill argv floor does not refuse five git grep pager forms

2 participants