Skip to content

fix(security): refuse a git command that opens or configures a pager, a liveness floor (#34098) - #34233

Closed
chenmingwei23 wants to merge 2 commits into
mainfrom
guard-g/gitgrep-pager-main
Closed

chenmingwei23 wants to merge 2 commits into
mainfrom
guard-g/gitgrep-pager-main

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: stop a git command from opening or configuring a pager that would hang a non-interactive agent session, while leaving every real search and every pager-off git command working.

A git pager is a program git runs and pages through. git grep -O/--open-files-in-pager opens the matching files in it, and core.pager/pager.<cmd> set through -c, --config-env, GIT_PAGER, PAGER, GIT_CONFIG_PARAMETERS or a GIT_CONFIG_KEY_n env word all name that program. In a non-interactive session the pager has no terminal to drive, so it blocks waiting for input and the session hangs. Nothing caught these accidental forms today.

Scope: liveness floor, not a security boundary

Liveness floor, not a security boundary. Deliberate evasion (shell redirection, running a pager binary directly, constructed commands) is out of scope. The floor catches the common accidental pager forms so a session does not hang; it does not add machinery to chase a determined operator who wants a pager to run, and it stays linear in the length of the command it reads.

Why it matters

Without the floor, an ordinary git grep -O or a -c core.pager=<prog> left in an agent's command blocks the session until it times out. Catching the accidental forms keeps the session live. Values that run no distinct program (empty, cat, a trusted absolute cat) stay allowed because the product's own git calls and the interactive-liveness advice use them.

Not a goal

  • The wider "a git config key runs a program" class (core.sshCommand, diff.external, GIT_EXTERNAL_DIFF, ...) is NOT handled here; it is tracked in git grep pathspec false positive in the self-kill floor, and a sound-design sketch #34234.
  • No change to which SEARCHES are allowed: ordinary git grep (including lowercase -o) is untouched.
  • Deliberate evasion is out of scope (see Scope above): a shell redirection into a file, running a pager binary directly, and a program name assembled across a command separator (g=git; $g grep -e ';' -O) are not chased. The floor refuses what it clearly reads as a pager route and does not grow quadratic machinery to catch constructed commands.

What changed

Approach: a self-protection-git-pager ungated floor (no catalog row, no opt-out) beside the existing restart/update/kill floors; it reads the argv in ORIGINAL case and descends nested eval/sh -c payloads. The floor matches the OPERATION, not the pager PROGRAM NAME: a name is swappable (a shell alias, a function, a PATH shim, LESS/LESSOPEN), so it is read in git's own grammar and refused whatever the value names, with only the no-op values allowed.

No-op value ruling (department lead): the pager VALUES allowed are the ones that run no distinct program -- the empty string, cat, and a trusted absolute cat (/usr/bin/cat, /bin/cat) for core.pager/GIT_PAGER/PAGER, and a git-false pager.<cmd> (false/no/off/0). An untrusted */cat (/tmp/x/cat) is still refused. cat/empty is allowed because the interactive-liveness advice proposes GIT_PAGER=cat and the product's own git calls use core.pager=cat.

Arg grammar: the argv is read in git's own grammar, not a flat scan. A git-GLOBAL option counts only BEFORE the subcommand (-c k=v, --config-env, the value options -C/--git-dir/--work-tree/--namespace/--super-prefix/--exec-path/--attr-source, and -p/--paginate/-P/--no-pager); after the subcommand its OWN grammar applies, so git grep -c <pat> (count) and git grep -e <pat> (a separate-token pattern) are not mistaken for a git-global pager control, and a subcommand -P does not cancel a real git-global -c core.pager.

Refused (a pager program would run): git grep -O/-nO/-Oless/--open-files-in-pager[=x]; a git-global -c core.pager=<prog> / pager.<cmd>=<prog|true> / a bare -c core.pager; --config-env=<pager key>=<envvar> (value unreadable, refused closed); GIT_PAGER=<prog> / PAGER=<prog> / GIT_CONFIG_PARAMETERS= / a GIT_CONFIG_KEY_n naming a pager key; the persistent writer git config core.pager <prog> (and pager.<cmd> <prog>, git config set --value ...); and any of these reached THROUGH an execution-prefix wrapper (command/env/sudo/nice/timeout/...) or an env pager EXPORTED by an earlier command on the same line (export GIT_PAGER=<prog>; git ...). The cheap can-fire gate was widened so a git hidden behind an empty substitution (gi$()t) still enters the scan.

Allowed (no program runs): lowercase git grep -o and ordinary options/patterns (-O is read case-sensitively; a short-option cluster stops at an operand like -e<pat>); the no-op VALUES above; a git-false pager.<cmd>; a git config read/unset (--get/--list/--unset/a key with no value); a non-pager -c key=val; -O after a -- operand terminator (a pathspec); and --no-pager/-P (which cancels a pager-config/env route but never grep -O).

Backwards compatibility

Rejects (intentional hardening): git commands that open or configure a pager are now refused. This is a new runtime refusal, not a code-contract change -- no field, type, key or public function is renamed or removed.

Removes nothing: no symbol, config key, data row or readable path is deleted; the change only adds a refusal branch, so there is no reader to sweep. The pager floor's helper names are internal (underscore-prefixed) and restated in the facade manifests.

Tests

Red-first pytests in test/test_argv_floor_git_grep_pager.py lock each refused and allowed form: grep -O in every spelling, the config/env/wrapper/same-line-export writers, the git-grammar scope, the no-op cat/empty/trusted-absolute values, and the gi$()t cheap-gate form. A test_the_pager_floor_stays_linear_on_a_long_command perf test pins linear time: a command of 10,000 harmless segments followed by a real pager route is still refused and is read well under a fixed time budget, so the floor cannot regress to a quadratic walk.

Locally green on head 376fbc764 (two commits rebased onto main 9807bdd5d): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_security_gate_liveness.py (the package line budget re-measured on the merged tree, 36,506), test_argv_floor_facade.py, test_host_git_repo_exec_neutralization.py (459 passed), and flake8 / black / isort / mypy.

Manual verification

N/A -- unit coverage is sufficient: the floor is pure argv/text analysis with no I/O or UI, and the allowed/refused matrix above is exercised directly through security.is_denied.

Screenshots / video

N/A -- no user-visible frontend surface is touched (security deny-gate only).

Related Issues

Closes #34098. Supersedes the withdrawn #34097. Wider git-config-program class deferred to #34234.

Sibling sweep

Swept: git grep -nE "core\.(pager|sshCommand|fsmonitor)|diff\.external|GIT_EXTERNAL_DIFF|GIT_PAGER|PAGER=" -- src/kiro_crew/security/
Sibling: core.sshCommand / diff.external / GIT_EXTERNAL_DIFF -- tracked in #34234, out of this PR's goal.
Sibling: the git-publish floor and other self-protection floors -- not affected -- they match different operations and are unchanged.

Pattern harvest

Rule candidate: review-prompt
Pattern: a self-protection floor that decides by the PROGRAM NAME a command names (an allowlist/denylist of values) is bypassable, because the name is swappable via alias/PATH/function/LESS/LESSOPEN; match the OPERATION and refuse it whatever the value, allowing only the forms where no program runs.

Checklist

  • At most two commits (one is the norm), 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

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/__init__.py

  • src/kiro_crew/security/_exports.py

  • src/kiro_crew/security/argv_floor.py

  • src/kiro_crew/security/argv_floor_self.py

  • src/kiro_crew/security/denied_rules_tables.py

  • src/kiro_crew/security/deny_gate.py

  • @chenmingwei23 posted a complete reasoning template for 00448fd.

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

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 00448fd4a0105b6f50541e61e02e711d8022a7ec 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 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

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

Design-Verdict: PASS

The floor is built on a hang that, by this repo's own account, does not happen for most of what it refuses, and it refuses those commands for good with no opt-out.

Blockers

The config/env pager routes it refuses do not hang this tool path
Trigger: the agent runs git config --global core.pager delta(the description says "the persistent writergit config core.pager " is refused), GIT_PAGER=less git log, or git -c core.pager=less diff. These are ordinary operator requests.
Outcome: the description's reason is that "the pager has no terminal to drive, so it blocks". But acp/liveness_interactive.py:42-44already says otherwise: "under the tool the stdout is a pipe, so a pager degrades tocat on its own". git does not start a configured pager when stdout is not a terminal. So these routes cannot hang anything. Yet the new floor has "no catalog row and no opt-out", so a legitimate pager setup is refused permanently and the operator cannot waive it. The deny note then gives a different reason, "a route to run an arbitrary command through git". That is a security claim, and the description rules security out ("not a security boundary"). The wider class it belongs to is deferred to #34234.
Fix: limit the floor to the forms that start a pager whatever stdout is (git grep -O/--open-files-in-pager). Leave the config/env forms to the existing advisory classifier, or give them a catalog row the operator can toggle. Make the note's reason match the description.
Clears when: the config/env routes are dropped or made waivable, or the PR shows a real session on this tool path where -c core.pager/GIT_PAGER hangs with stdout as a pipe.

Notes

  • The refusal note says "Turn the pager off with --no-pager instead", but the description says --no-pager never cancels grep -O. For the one form that really runs a pager, that advice is wrong.
  • Once the floor is cut down to grep -O, most of the roughly 740-line git-grammar parser (global options, --config-env, GIT_CONFIG_KEY_n, writers that export earlier on the same line) has nothing left to do.

[DESIGN-REVIEWED] 00448fd

Description read

[DESCRIPTION-READ] 70516dc7552edc4188cd7e2070fe8f2c109d1ed99c28db5dc0362d0e93025886

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 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🔴 BLOCK

Premise-level review of 00448fd4a0105b6f50541e61e02e711d8022a7ec — 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: BLOCK

The diff refuses git pager forms whose zero option costs nobody: the repo's own liveness classifier records that a pager under the tool degrades to cat. It also rebuilds a shell walk that argv_rules._commands already provides.

Not checked: whether any hang seen in #34098 came from a PTY-backed shell rather than the piped tool path.

Notes

  • Item 9 — oversized: about 740 lines and a budget raised by 778 for an advisory-class risk. Subtraction: this shrinks to whatever survives Blocker 2.

What this change ships

Inventory (10 items) — 2 justified

Intent: keep an agent session from hanging on a git pager. FIX.

  1. git grep -O / --open-files-in-pager is refused — zero consumers of harm (pager degrades to cat)
  2. -c / --config-env core.pager / pager.<cmd> is refused — zero consumers of harm
  3. GIT_PAGER / PAGER / GIT_CONFIG_* env words and same-line export are refused — zero consumers of harm
  4. The persistent git config core.pager <prog> writer is refused — zero consumers of harm
  5. The same refusals through wrappers and sh -c payloads — rides along
  6. The deny note says "a route to run an arbitrary command" — framing contradicted
  7. The cheap gate is widened to shell-machinery text — justified
  8. A new heredoc/comment/segment walk — duplicate of argv_rules._commands
  9. The package line budget goes up by 778 — oversized
  10. The ungated-floor pins carve out non-subcommand floors — justified

Blockers

1. The refusals remove no observed harm — zero option
Trigger: the description says "In a non-interactive session the pager … blocks … and the session hangs". But acp/liveness_interactive.py:42-44 says: "under the tool the stdout is a pipe, so a pager degrades to cat on its own". The deny note also calls the pager "a route to run an arbitrary command", which contradicts "not a security boundary".
Outcome: a permanent ungated refusal of ordinary git usage that prevents no hang.
Subtraction: delete _is_git_pager and its helpers.
Clears when: a reproduction shows a tool-path git pager hanging, or the floor is removed.

2. A second shell walk — duplicate of argv_rules._commands
Trigger: _strip_heredoc_bodies plus passes (a)/(b) re-implement argv_rules._commands/_without_heredoc_bodies (src/kiro_crew/security/argv_rules.py:177-233). That shared walk already returns each (program, args), reads nested -c payloads and keeps heredoc data as data. Grepping def _?\w*heredoc over security/ finds 5 heredoc readers, 1 of them new.
Outcome: two walks that will drift apart.
Subtraction: decide on _commands(raw_text) output.
Clears when: the floor's walk is replaced by argv_rules._commands.

[FIRST-PRINCIPLES-REVIEWED] 00448fd

Description read

[DESCRIPTION-READ] 2ebf3b838275293575e65850058ea2d51abb568de6c4562313432a06bcb422a5

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 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

Reviewed 00448fd4a0105b6f50541e61e02e711d8022a7ec — this comment is updated in place on each push.

BLOCKING: a new test passes or fails depending on wall-clock time, which the blocking tests-are-deterministic rule (D7) forbids.

BLOCKING — test/test_argv_floor_git_grep_pager.py:1545
assert t_large < 5.0, f"10k-segment command took {t_large:.3f}s (expected linear)"
Trigger: test_the_pager_floor_stays_linear_on_a_long_command times _verdict on a 10,000-segment command with time.perf_counter() and checks the best of three runs against a fixed 5.0 s ceiling. The suite runs this under -n auto on loaded Linux, macOS and Windows shards.
Outcome: The result depends on how fast and how busy the host is, not on the code. A slow or contended runner can go red on a PR that never touched this floor. This is the shape D7 names: "an UPPER bound on a measured wall or CPU duration … assert elapsed < 0.5".
Anchor: tests-are-deterministic
Fix: Drop the absolute ceiling. Either assert the work done (spy on _shell_normalizer._self_tokens / _split_push_command_segments and check the call count grows linearly with the segment count), or keep only the ratio against t_small, which D7 allows as "a bound relative to a span the test measured itself".

Notes:

  • docs/system-specs/modules/security.md:2504 lists every member of _SELF_PROTECTION_UNGATED_FLOOR_IDS and leaves out the new self-protection-git-pager. AGENTS.md requires the owning spec to change in the same commit.
  • argv_floor_self.py grows to 1,983 lines, past the 1,600 working target in keep-modules-small. That rule is non-blocking, but AGENTS.md asks for the git-pager floor to move into its own owner module.

[BLOCK-MERGE] 00448fd
[OPUS-REVIEWED] 00448fd

Verdict parsed from the review's SHA-scoped output markers for commit 00448fd4a0105b6f50541e61e02e711d8022a7ec.

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

@github-actions

github-actions Bot commented Nov 10, 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 00448fd4a0105b6f50541e61e02e711d8022a7ec. Adjudication upheld 2 of 4 blocking finding(s); those must be resolved before merging.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/security/argv_floor_self.py:1814 -- Quoted operands become executable command boundaries

if _ends_argv(token):
Trigger: printf '%s\n' ';' git grep -O reaches is_denied → _is_git_pager; pass (b) splits at the semicolon after tokenization removes its quoting.
Outcome: The ungated floor refuses harmless output even though the shell executes only printf.
Anchor: defect
Fix: Carry exported state through the existing quote-aware segments instead of splitting dequoted operands.
Sites: Quoted '#', '(', and 'hello;' operands produce the same refusal; git grep -- ';' git grep -O also misclassifies pathspecs as a command.

BLOCKING -- src/kiro_crew/security/argv_floor_self.py:1886 -- Pager assignments survive explicit environment removal

for token in command[:git_index]:
if _shell_normalizer.ENV_ASSIGNMENT_RE.match(token):
env.append(token)
Trigger: GIT_PAGER=less env -u GIT_PAGER git -c core.pager=cat log reaches is_denied → _git_command_sets_pager, which collects the removed assignment.
Outcome: The floor blocks a pager-neutralized Git read: the child receives no GIT_PAGER and uses the allowed cat setting.
Anchor: defect
Fix: Honor environment removals before evaluating assignments, including removals from carried same-line state.
Sites: Same-line export followed by env --unset=GIT_PAGER, env -i, or unset GIT_PAGER retains the removed assignment and causes the same refusal.

BLOCKING -- src/kiro_crew/security/argv_floor_self.py:1632 -- Unquoted heredocs lose executable substitutions

out.extend(lines[i : end + 1] if keep else lines[end : end + 1])
Trigger: cat <<EOF\n$(git grep -O'sh -c "sleep 60"' -e Rules -- AGENTS.md)\nEOF reaches is_denied → _is_git_pager; _strip_heredoc_bodies removes the substitution before the payload walk.
Outcome: The gate allows the command, but Bash executes the pager substitution and blocks heredoc delivery for 60 seconds.
Anchor: defect
Fix: Preserve and inspect executable substitutions in unquoted heredoc bodies while stripping their literal data; quoted delimiters remain inert.
Sites: Backtick substitutions and unquoted tab-stripping <<-EOF bodies are also removed before inspection.

BLOCKING -- test/test_argv_floor_git_grep_pager.py:643 -- Absolute wall-time assertion makes correctness depend on CI load

assert t_large < 5.0, f"10k-segment command took {t_large:.3f}s (expected linear)"
Trigger: Coverage overhead or worker descheduling pushes all three _elapsed(large) samples above five seconds, so their minimum exceeds the literal ceiling.
Outcome: A correct linear implementation fails CI because of execution load rather than its complexity.
Anchor: tests-are-deterministic
Fix: Remove the absolute wall-time assertion; retain the relative measured-span comparison permitted by the rule.
Sites: none

[BLOCK-MERGE] 00448fd
[GPT-REVIEWED] 00448fd

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

Of the 4 findings, I upheld 2 and downgraded 2. F3 and F4 keep blocking the merge; F1 and F2 don't.

F1 — LOW, downgraded. This is a false refusal, not a missed pager. It only happens when a quoted ;, #, ( or glued; operand sits right before literal git-pager text. Pass (b) splits on the unquoted tokens (src/kiro_crew/security/argv_floor_self.py:1810-1814), and _ends_argv counts a ;/# token as a boundary (shell_normalizer_walk.py:225-240). The agent sees the refusal and can rewrite the command. A real fix would mean making pass (b) quote-aware, but pass (b) works on unquoted tokens on purpose so it can resolve variable-built program names (:1806-1809). That is a bigger redesign than a contrived false refusal justifies.

F2 — LOW, downgraded. Also a false refusal, and only on a contrived input: a GIT_PAGER= assignment followed by env -u GIT_PAGER, env -i or unset. The assignment collection at :1886-1888 doesn't apply removals, and the refusal is visible. Fixing it would mean modelling env -u/-i/unset semantics, including state carried across commands, just for this one path. That costs more than it prevents.

F3 — upheld (harm-warrants-remedy). Here the gate misses a pager rather than over-refusing. The new _strip_heredoc_bodies (:1632, called at :1721) drops unquoted heredoc bodies before the walk, so $(git grep -O…) inside one goes unchecked and the command hangs. The docstring scopes this check to accidental hangs, not a security boundary (:1707-1711), and the trigger is rare. But the fix is cheap: the regex already captures whether the delimiter was quoted (group 2), so unquoted bodies can keep their $(/backtick lines for inspection.

F4 — upheld (autosde-blocking-rule). assert t_large < 5.0 at test/test_argv_floor_git_grep_pager.py:643 is an absolute upper bound on wall time. tests-are-deterministic is blocking: true in the base-branch .review-base-rules/AUTOSDE.yaml:370-371, and its item 5 (D7) forbids exactly that kind of assertion.

[ADJUDICATION] 00448fd4a0105b6f50541e61e02e711d8022a7ec total=4 uphold=2 downgrade=2
DOWNGRADE F1 src/kiro_crew/security/argv_floor_self.py:1814 reason=disproportionate-remedy
DOWNGRADE F2 src/kiro_crew/security/argv_floor_self.py:1886 reason=disproportionate-remedy
UPHOLD F3 src/kiro_crew/security/argv_floor_self.py:1632 reason=harm-warrants-remedy
UPHOLD F4 test/test_argv_floor_git_grep_pager.py:643 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 00448fd4a0105b6f50541e61e02e711d8022a7ec

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

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🔴 BLOCK (blocking)

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

Verdict basis: a script-confirmed newly-refused operation.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 25 classified, 4 newly refused, 21 still allowed.
  • ubuntu-latest (platform posix): 25 classified, 4 newly refused, 21 still allowed.
  • windows-latest (platform windows): 28 classified, 5 newly refused, 23 still allowed.

Newly refused (confirmed by the real classifier at both refs)

  • `git commit -F - <<'END-MSG'
    fix: stop the session hang

GIT_PAGER=less git log hangs a session; use git --no-pager log.
END-MSG` (posix, leg macos-latest)
- Who loses it: An agent writes a commit message through a heredoc with a hyphenated delimiter (valid bash); the body is data on git's stdin, not a command.
- Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF

  • gh pr create --title "Stop bash sessions hanging on git log" --body-file - <<'EOF' GIT_PAGER=less git log hangs a session; use git --no-pager log. EOF (posix, leg macos-latest)
    • Who loses it: An agent opens a PR whose title contains the word bash; the heredoc feeds gh, not a shell, so its body is data.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="$(command -v cat)" log --oneline -5 (posix, leg macos-latest)
    • Who loses it: A script pins the pager to the resolved cat path, the same resolution update_governance applies, without hard-coding a directory.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager=/run/current-system/sw/bin/cat log --oneline -5 (posix, leg macos-latest)
    • Who loses it: On NixOS, which(cat) returns this system-profile path (there is no /usr/bin/cat), so a resolved cat pin spells it this way.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • `git commit -F - <<'END-MSG'
    fix: stop the session hang

GIT_PAGER=less git log hangs a session; use git --no-pager log.
END-MSG` (posix, leg ubuntu-latest)
- Who loses it: An agent writes a commit message through a heredoc with a hyphenated delimiter (valid bash); the body is data on git's stdin, not a command.
- Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF

  • gh pr create --title "Stop bash sessions hanging on git log" --body-file - <<'EOF' GIT_PAGER=less git log hangs a session; use git --no-pager log. EOF (posix, leg ubuntu-latest)
    • Who loses it: An agent opens a PR whose title contains the word bash; the heredoc feeds gh, not a shell, so its body is data.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="$(command -v cat)" log --oneline -5 (posix, leg ubuntu-latest)
    • Who loses it: A script pins the pager to the resolved cat path, the same resolution update_governance applies, without hard-coding a directory.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager=/run/current-system/sw/bin/cat log --oneline -5 (posix, leg ubuntu-latest)
    • Who loses it: On NixOS, which(cat) returns this system-profile path (there is no /usr/bin/cat), so a resolved cat pin spells it this way.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="D:\Program Files\Git\usr\bin\cat.exe" log --oneline -5 (windows, leg windows-latest)
    • Who loses it: A Windows host with Program Files on D: pins Git for Windows' own cat, the same trusted cat the floor allows on C:.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="C:\Users\dev\AppData\Local\Programs\Git\usr\bin\cat.exe" log --oneline -5 (windows, leg windows-latest)
    • Who loses it: Git for Windows installed for the current user only lives under LOCALAPPDATA\Programs; which(cat) there returns this path.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="%ProgramFiles%\Git\usr\bin\cat.exe" log --oneline -5 (windows, leg windows-latest)
    • Who loses it: A cmd.exe batch script pins Git for Windows' cat through the ProgramFiles variable instead of a literal drive.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="/c/Program Files/Git/usr/bin/cat.exe" log --oneline -5 (windows, leg windows-latest)
    • Who loses it: A Git Bash user on Windows pins the same trusted cat in MSYS path spelling.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF
  • git -c core.pager="C:\PROGRA~1\Git\usr\bin\cat.exe" log --oneline -5 (windows, leg windows-latest)
    • Who loses it: A cmd script that avoids quoting spaces uses the 8.3 short name for Program Files to pin Git for Windows' cat.
    • Refused by: deny-rules -- Blocked by security policy: self-protection-git-pager
      Matched structurally on the command's argv: a git command opens or configures a pager, a program git runs on its output (git grep -O / --open-files-in-pager, or core.pager / pager. set through -c, --config-env, GIT_PAGER, PAGER or a GIT_CONF

Each row above is an operation that the base ref ALLOWS and this change REFUSES. Narrow the rule at the tier named. Withdrawing a row is not the way to green: that is its own pull request, on its own merits.

Scope-Verdict: PASS

Reason: No regression has been confirmed by the script, and the harness gave me no confirmed rows for this commit. The new floor is a structural argv predicate in the is_denied self-protection loop, so the classifier can rule on every candidate. The rows aimed hardest at over-refusal are: a heredoc whose delimiter has a hyphen (the opener regex only strips [A-Za-z_][A-Za-z0-9_]* delimiters); a heredoc whose opener line contains a shell name as a word, such as a PR title with "bash" in it, which keeps the body; and trusted-cat paths outside the four hard-coded spellings.

TIGHTENING: new ungated floor self-protection-git-pager (_is_git_pager, wired into deny_gate.is_denied as ("self-protection-git-pager", _argv._is_git_pager) and given the raw text) -- it refuses a git command that runs a program the caller picks as git's pager: "git grep -O / --open-files-in-pager runs the pager on the matching files, and core.pager / pager.<cmd> set through -c, --config-env, GIT_PAGER, PAGER, GIT_CONFIG_PARAMETERS or a GIT_CONFIG_KEY_n env word all name the program git pages through ... a route to run an arbitrary command through git".

ADJUDICATED: 33 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE:

  • any (20 rows): these probe the parts of the floor that don't depend on the host:
    • paging-off spellings: --no-pager, -P, a quoted empty GIT_PAGER='' and core.pager='', and a double-quoted "cat".
    • key-regex neighbours: color.pager, LESS=, and git var GIT_PAGER with the name as an operand.
    • git config reads, unsets, typed writes and the 2.46 config unset grammar.
    • the GIT_CONFIG_* env trio with the pager key at index 1 or an empty value.
    • grep option-cluster edges: a capital O inside a positional pattern, --max-depth -1, and diff -O (orderfile).
  • posix (5 rows): an xargs wrapper, the two heredoc-stripping edges, a resolved $(command -v cat) pin, and the NixOS cat path. These cover the posix absolute-path allowlist (/usr/bin/cat, /bin/cat).
  • windows (8 rows): the diff hard-codes c:\program files[ (x86)]\git\usr\bin\cat[.exe] and cat.exe. The rows probe:
    • another drive letter;
    • a per-user AppData\Local\Programs\Git install;
    • %ProgramFiles% expansion;
    • the Git Bash /c/... MSYS spelling;
    • the 8.3 short name;
    • PowerShell $env:GIT_PAGER, cmd set GIT_PAGER=cat&&, and a drive-letter -C path.
  • Not probed: a Windows git.exe program name. The floor matches program.lower() != "git", so it can only under-refuse there, which is outside this lane.

UNADJUDICATED: Nothing in this tightening is beyond the classifier. One owner-ruled boundary still needs a human decision: a no-op cat pager is trusted only at the exact spellings in _is_noop_pager_value. Any other resolved location of the same system cat is refused, for example another drive, a per-user Git for Windows install, NixOS /run/current-system/sw/bin/cat, or a value resolved at runtime. The rows above submit those spellings. If the legs confirm them, the narrowest fix is to widen the trusted-cat match so that an install-rooted ...\Git\usr\bin\cat[.exe] and a resolved $(command -v cat) count as trusted. The program allowlist should stay as it is.

[SCOPE-REVIEWED] 00448fd

The confirmed rows, in the committed corpus's own shape
{
  "golden_paths": [
    {
      "kind": "shell",
      "command_or_flow": "git commit -F - <<'END-MSG'\nfix: stop the session hang\n\nGIT_PAGER=less git log hangs a session; use git --no-pager log.\nEND-MSG",
      "platform": "posix",
      "reason": "An agent writes a commit message through a heredoc with a hyphenated delimiter (valid bash); the body is data on git's stdin, not a command."
    },
    {
      "kind": "shell",
      "command_or_flow": "gh pr create --title \"Stop bash sessions hanging on git log\" --body-file - <<'EOF'\nGIT_PAGER=less git log hangs a session; use git --no-pager log.\nEOF",
      "platform": "posix",
      "reason": "An agent opens a PR whose title contains the word bash; the heredoc feeds gh, not a shell, so its body is data."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"$(command -v cat)\" log --oneline -5",
      "platform": "posix",
      "reason": "A script pins the pager to the resolved cat path, the same resolution update_governance applies, without hard-coding a directory."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=/run/current-system/sw/bin/cat log --oneline -5",
      "platform": "posix",
      "reason": "On NixOS, which(cat) returns this system-profile path (there is no /usr/bin/cat), so a resolved cat pin spells it this way."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"D:\\Program Files\\Git\\usr\\bin\\cat.exe\" log --oneline -5",
      "platform": "windows",
      "reason": "A Windows host with Program Files on D: pins Git for Windows' own cat, the same trusted cat the floor allows on C:."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"C:\\Users\\dev\\AppData\\Local\\Programs\\Git\\usr\\bin\\cat.exe\" log --oneline -5",
      "platform": "windows",
      "reason": "Git for Windows installed for the current user only lives under LOCALAPPDATA\\Programs; which(cat) there returns this path."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"%ProgramFiles%\\Git\\usr\\bin\\cat.exe\" log --oneline -5",
      "platform": "windows",
      "reason": "A cmd.exe batch script pins Git for Windows' cat through the ProgramFiles variable instead of a literal drive."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"/c/Program Files/Git/usr/bin/cat.exe\" log --oneline -5",
      "platform": "windows",
      "reason": "A Git Bash user on Windows pins the same trusted cat in MSYS path spelling."
    },
    {
      "kind": "shell",
      "command_or_flow": "git -c core.pager=\"C:\\PROGRA~1\\Git\\usr\\bin\\cat.exe\" log --oneline -5",
      "platform": "windows",
      "reason": "A cmd script that avoids quoting spaces uses the 8.3 short name for Program Files to pin Git for Windows' cat."
    }
  ]
}

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This PR and #34166 both close #34098. Both make the self-kill floor refuse the same five git grep pager forms: -O after the pathspec, clustered -nO, -c core.pager=, GIT_PAGER=, and an array expansion. Both add test/test_argv_floor_git_grep_pager.py and change src/kiro_crew/security/shell_normalizer.py and test/test_security_gate_liveness.py.

Please keep one of #34166 and #34233 and close the other, carrying over anything only this one has.

@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 10, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: fbd1cf9
  • What rule changed: the self-kill argv floor now extracts the command a git grep pager would run (-O<cmd>, clustered -nO<cmd>, --open-files-in-pager=<cmd>, -c core.pager=<cmd>, GIT_PAGER=/PAGER=, or one carried through an array) and hands it to the nested-payload walk, so the deny tiers judge it.
  • Before -> after (what was allowed/blocked, now): before, a git grep whose pager runs a process-kill was ALLOWED, because the command lived inside one option token the argv scan never read; after, that kill is REFUSED. Nothing that was allowed and safe becomes blocked: a benign pager (-O less) is judged and allowed, only a pager command that is itself a self-kill is refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a legitimate git grep with an unusual -O/pager value could be refused. Bounded: the extracted value is judged by the same deny tiers as any command, so only a self-kill (or credential mint) value refuses; everything else passes. No new allow path is opened, so it cannot let a kill through.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py. On clean main the seven pager forms are allowed (red); with this change they are refused and a benign -O less stays allowed. The four shadowing/separator bypass classes are pinned and stay refused.
  • No regression:
    • Tools still work (which tools/commands were run, result): a benign git grep and a benign -O less pager are allowed; the pager-refusal, benign and regression tests pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand exemption is added, so main's existing behaviour (including its false positive) is unchanged; only the pager-runs-a-program gap is closed.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py (21 cases) passed locally; the security package line budget was re-measured to 35,228.

@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
@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from fbd1cf9 to c7c9126 Compare November 10, 2026 01:40
@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 10, 2026
@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from c7c9126 to 56d1b26 Compare November 10, 2026 02:02
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 56d1b26
  • What rule changed: the self-kill argv floor now extracts the command a git grep pager would run (-O<cmd>, clustered -nO<cmd>, --open-files-in-pager=<cmd>, -c core.pager=<cmd>, GIT_PAGER=/PAGER=, or one carried through an array) and hands it to the nested-payload walk, so the deny tiers judge it.
  • Before -> after (what was allowed/blocked, now): before, a git grep whose pager runs a process-kill was ALLOWED, because the command lived inside one option token the argv scan never read; after, that kill is REFUSED. Nothing that was allowed and safe becomes blocked: a benign pager (-O less) is judged and allowed, only a pager command that is itself a self-kill is refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a legitimate git grep with an unusual -O/pager value could be refused. Bounded: the extracted value is judged by the same deny tiers as any command, so only a self-kill (or credential mint) value refuses; everything else passes. No new allow path is opened, so it cannot let a kill through.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py. On clean main the seven pager forms are allowed (red); with this change they are refused and a benign -O less stays allowed. The four shadowing/separator bypass classes are pinned and stay refused.
  • No regression:
    • Tools still work (which tools/commands were run, result): a benign git grep and a benign -O less pager are allowed; the pager-refusal, benign and regression tests pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand exemption is added, so main's existing behaviour (including its false positive) is unchanged; only the pager-runs-a-program gap is closed.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py (21 cases) passed locally; the security package line budget was re-measured to 35,242.

@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 10, 2026
@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from 56d1b26 to bddfdb3 Compare November 10, 2026 03:03
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: bddfdb3
  • What rule changed: a new ungated self-protection floor, self-protection-git-pager, refuses any git command that OPENS or CONFIGURES a pager. A git pager is a program git runs on its output and the caller chooses it, so it is a route to run an arbitrary command through git. The operation is refused, not a judged pager value (the pager name is swappable via alias, PATH or a LESSOPEN hook).
  • Before -> after (what was allowed/blocked, now): before, git grep -O<pager> and setting the pager by config were ALLOWED (the pager program hid inside one option/env token the argv scan never read); after, they are REFUSED. Refused forms: git grep -O / --open-files-in-pager in every spelling (clustered, =, or separate arg), and core.pager/pager.<cmd> set through -c, --config-env=, GIT_PAGER=, PAGER=, GIT_CONFIG_PARAMETERS=, or a GIT_CONFIG_KEY_n= env word, including inside an eval/sh -c payload. Still allowed: a plain search, git --no-pager / -P (which name no program), a non-pager -c key=val, and -O after a -- operand terminator (a pathspec, not the option).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a legitimate git grep -O or a legitimate core.pager set is refused. Bounded: git --no-pager is the supported way to control paging and stays allowed, and the floor reads options only before --, so searches and pathspecs are untouched. No new allow path is opened, so it cannot let a kill through.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py. On clean main the -O and config forms are allowed (red); with this floor they are refused with rule id self-protection-git-pager, a plain search and git --no-pager/-P stay allowed, and the self-kill bypass classes stay refused. The ungated-floor invariants in test_denied_commands_security.py were updated for a structural (non-subcommand) floor and verified.
  • No regression:
    • Tools still work (which tools/commands were run, result): git -c user.name=x commit, git log -p, git grep --count, git diff, and non-git grep -O/less -O are all allowed; the pager-refusal, allowed and regression tests pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand exemption is added, so main's existing behaviour is unchanged; only the pager open/config routes are newly refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py (32 cases) passed locally; the security package line budget was re-measured to 35,270; the comment-history and other source-gate scripts pass.

@Zedmor

Zedmor commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Code change approver recommendation: A person should decide

Automated, not a person, and not a review: a maintainer still decides.

decider-v3c@217fe607 · p_defect 0.93 · router R0 (approves only when p_defect <= 0.12, on changes of at most 400 changed lines) · head eb4751e341 · 314 changed lines

Why: the decider flagged 4 possible problems (p_defect 0.93); a person should check them.

I'm requesting changes. The PR is meant to close a self-kill bypass through git grep's pager, but the code doesn't match the description and it breaks ordinary searches.

  • It refuses git grep -o. The check reads lower-cased text, so -o (--only-matching, a plain search) looks the same as -O (the pager option). Any short-option cluster containing an "o", such as git grep -no foo or git grep -efoo, is refused too. The PR's own test asserts that git grep -o less -- x is caught. The new floor has no opt-out.
  • It does something different from what the description says. The description says a harmless pager like -O less is "judged and allowed" and that no searches change. The code refuses every pager on every git command, whatever its value. The function the description names, _git_grep_pager_payloads, doesn't exist in the diff.
  • It blocks the product's own advice. liveness_interactive.py:402 tells the agent to use GIT_PAGER=cat when a pager hangs, and that is now denied.
  • One claimed bypass is still open. The array form (a=('-O<kill> #'); git grep "${a[@]}") is listed as fixed, but it has no test and the code only checks literal tokens, so it

Things to check (the decider's concerns; it is right less than half the time):

  • [regression/high] The text is lower-cased before this check, so -o (--only-matching) looks the same as -O. Any clustered short option or glued -e pattern that contains an 'o' (e.g. git grep -no foo, git grep -efoo) also matches. These are plain read-only searches that main allows, and this PR now refuses (src/kiro_crew/security/argv_floor_self.py)
  • [contradicts_spec_or_description/high] The diff ships a blanket pager refusal on every git subcommand, not the value-judging payload walk the PR describes. It also widens scope past git grep to git log/diff via -c core.pager, GIT_PAGER, PAGER, GIT_CONFIG_PARAMETERS and GIT_CONFIG_KEY_n, none of which the stated goal or refactor: remove dead legacy compatibility shims #3 (src/kiro_crew/security/argv_floor_self.py)
  • [regression/medium] The product's own remedy for an interactive pager hang now gets denied by the new floor. The PR neither updates this sibling reader nor lists it. (src/kiro_crew/acp/liveness_interactive.py)
  • [goal_unmet/medium] One of the five bypass forms the PR claims to close has no test and, as far as the code shows, is not handled. The goal is met on only some paths. (test/test_argv_floor_git_grep_pager.py)

If this recommendation is wrong, reply here; the replies are how the approver is evaluated.

@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from bddfdb3 to cd3ebad Compare November 10, 2026 03:17
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from 1433fea to b708d8b Compare November 11, 2026 06:29
@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 11, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b708d8b
  • What rule changed: the self-protection-git-pager floor is reworked to clear the three decider findings. It still refuses any git command that OPENS or CONFIGURES a pager a program would run, but (1) it now reads the argv in git's own grammar instead of a flat scan, (2) it allows the two no-op pager VALUES (empty and cat) per the department-lead ruling, and (3) it closes the wrapper / same-line-export / git config writer / empty-substitution bypasses.
  • Before -> after (what was allowed/blocked, now):
    • Grammar scope: BEFORE, the flat scan over-refused git grep -c core.pager (grep's count flag plus a pattern) and git grep -e -O (-O is -e's separate-token pattern), and under-refused git -c core.pager=<prog> log -P (the subcommand -P wrongly cancelled the real git-global config). AFTER, git-global options count only before the subcommand and the subcommand's own grammar applies after it, so those three are read correctly (first two allowed, third refused).
    • No-op values: BEFORE, every pager value including cat was refused. AFTER, core.pager/GIT_PAGER/PAGER set to empty or cat, and the git config writer and env trio likewise, are ALLOWED; every other named program stays refused. cat is allowed because the interactive-liveness advice proposes GIT_PAGER=cat and the product's own git calls use core.pager=cat (code_fingerprint.py, gitops.py, workspace_tools.py, update_governance.py).
    • New refusals: AFTER, the same pager routes reached through an execution-prefix wrapper (command/env/sudo/nice/timeout/...), an env pager exported by an earlier command on the same line (export GIT_PAGER=<prog>; git ...), or the persistent writer git config core.pager <prog> are refused; and the cheap can-fire gate was widened so a git hidden behind an empty substitution (gi$()t) still enters the scan.
  • Worst case if wrong (breaks commands / leaks secret / locks user out):
    • The cat exception is the one new residual: a cat shadow on PATH would run that program through git. This is a DELIBERATE, department-lead-ruled exception (the product and its own advice depend on GIT_PAGER=cat), bounded to exactly two values (empty and cat); every other name, and grep -O cat, stays refused. The PR description now records this ruling, so the code and the description agree.
    • The grammar corrections only widen what is ALLOWED for git grep -c/-e, which are ordinary searches and never a kill route (they run no pager); relative to clean main no search changes.
    • The wrapper / export / git config writer changes only ADD refusals, so they cannot open a kill path.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py locks the new matrix red-first (the grammar cases, the cat/empty no-op cases, and the wrapper/export/config-writer/gi$()t refusals); test/test_denied_commands_security.py keeps _is_git_pager on git grep -O/-c core.pager=less/--no-pager. Both pass locally on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): git -c user.name=x commit, git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, and non-git grep -O/less -O are all allowed; the pager-refusal, allowed and regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat/empty no-op values keep the product's own git calls working. Only the pager open/config/writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, the facade/mirror manifest guards, and the package line budget (re-measured to 35,764 after rebasing onto current main) pass locally; flake8/black/isort are clean.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Response to First Principles Review (Opus 5.5) at b708d8bbb9b91c2616589d4f2287623a067548e1

Thanks -- the blocker was right: the description and the code disagreed about cat. Here is how it is resolved, without overriding the lane.

Blocker: cat allowed vs the description saying it is refused -- resolved by amending the description

The code intentionally allows cat (and the empty string) as the only no-op pager values. This is a department-lead ruling, not a drive-by allowlist: the interactive-liveness advice proposes GIT_PAGER=cat, and the product's own git calls use core.pager=cat (code_fingerprint.py, gitops.py, workspace_tools.py, update_governance.py), so refusing cat would break the product. Per your "Clears when ... a human amends the description to record the cat ruling", the PR description has been amended: the old "cat is refused like any other name" framing is removed and a "No-op value ruling (department lead)" paragraph now records that empty and cat are the only allowed values and every other named program stays refused.

Residual, stated plainly: a cat shadow on PATH could run a program through git. That residual is accepted by the ruling and is bounded to exactly two values; grep -O cat and every other name stay refused. The description now matches the code, so a reader is no longer misled.

Item 5 (git config writer) and item 6 (wrappers/export) -- now declared

Both are now described in "What changed": the persistent writer git config core.pager <prog> is refused, and the pager routes reached through an execution-prefix wrapper or a same-line export are refused.

Note (item 6): reuse argv_rules._WRAPPERS instead of a local table -- answered, kept local by design

argv_floor_self.py states, as a module invariant, that it "reads the shell reader, the inline-payload checks and the shared name vocabulary below it, and imports NO OTHER part of the argv floor." argv_rules is part of the argv floor, so importing _WRAPPERS / _program_args from it would break that boundary (the self-protection floors are deliberately kept independent of the general argv rules). Two further reasons it is not a drop-in: _program_args DISCARDS the VAR=value env words, but this floor needs them to catch env GIT_PAGER=<prog> git ... and sudo GIT_PAGER=<prog> git ...; and it returns one program for a frame, whereas this floor walks each command in the frame to carry a same-line export. The local wrapper set is the minimal env-collecting variant scoped to that need. If the team would rather lift a shared wrapper table into the vocabulary layer that both can import, I will do that as a separate change rather than cross the boundary here.

All non-AI checks are green or running on this head; the Dependency License Gate is green. No enqueue, no override, no --auto -- this goes to normal human review.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b708d8b
  • What rule changed: the self-protection-git-pager floor is reworked to clear the three decider findings. It still refuses any git command that OPENS or CONFIGURES a pager a program would run, but now (1) reads the argv in git's own grammar instead of a flat scan, (2) allows the two no-op pager VALUES (empty and cat) per the department-lead ruling, and (3) closes the wrapper, same-line-export, git config writer and empty-substitution bypasses.
  • Before -> after (what was allowed/blocked, now): Grammar scope -- BEFORE, the flat scan over-refused git grep -c core.pager (grep's count flag plus a pattern) and git grep -e -O (-O is -e's separate-token pattern) and under-refused git -c core.pager=p log -P (the subcommand -P wrongly cancelled the real git-global config); AFTER, git-global options count only before the subcommand and the subcommand's own grammar applies after it, so the first two are allowed and the third refused. No-op values -- BEFORE every pager value including cat was refused; AFTER an empty or cat value for core.pager/GIT_PAGER/PAGER, for the git config writer and for the env trio is ALLOWED, every other named program still refused. New refusals -- AFTER the same pager routes reached through an execution-prefix wrapper (command/env/sudo/nice/timeout), through a same-line export GIT_PAGER=prog; git ..., or through the persistent writer git config core.pager prog are refused, and the cheap can-fire gate was widened so a git hidden behind an empty substitution (gi$()t) still enters the scan.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the cat exception is the one new residual -- a cat shadow on PATH could run that program through git; this is a deliberate, department-lead-ruled exception (the product and its own liveness advice depend on GIT_PAGER=cat), bounded to exactly two values (empty and cat) while every other name and grep -O cat stay refused, and the PR description now records the ruling so code and description agree. The grammar corrections only widen what is ALLOWED for ordinary git grep -c/-e searches, which run no pager and are never a kill route; relative to clean main no search is newly refused. The wrapper, export and git config writer changes only ADD refusals, so they cannot open a kill path.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py locks the new matrix red-first -- the git-grammar cases, the cat/empty no-op cases, and the wrapper / same-line-export / git config writer / gi$()t refusals; test/test_denied_commands_security.py keeps _is_git_pager on git grep -O / -c core.pager=less / --no-pager. Both pass locally on this head (340 cases in the two files).
  • No regression:
    • Tools still work (which tools/commands were run, result): git -c user.name=x commit, git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, and non-git grep -O / less -O are all allowed; the pager-refusal, allowed and regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat/empty no-op values keep the product's own git calls (core.pager=cat) working. Only the pager open/config/writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, the facade/mirror manifest guards, and the package line budget (re-measured to 35,764 after rebasing onto current main) pass locally; flake8 / black / isort are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit b708d8bbb and the test commit, or drop the branch). The floor is pure argv/text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; there is no data to unwind and no reader to sweep (only a refusal branch and internal underscore-prefixed helpers were added).

@chenmingwei23 chenmingwei23 reopened this Nov 11, 2026
@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 labels Nov 11, 2026
@chenmingwei23
chenmingwei23 force-pushed the guard-g/gitgrep-pager-main branch from b708d8b to 69f56a9 Compare November 11, 2026 07:29
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 69f56a9
  • What rule changed: the self-protection-git-pager floor still refuses any git command that OPENS or CONFIGURES a pager a program would run, reads git's own grammar (git-global options before the subcommand), and allows the two no-op values (empty and cat) per the department-lead ruling. This revision closes the First Principles review finding: the floor now finds the program by REUSING argv_rules._program_args (the shared execution-prefix wrapper table) instead of its own shorter inline wrapper list, and its git-global value-option set is a local mirror of argv_floor_git._GIT_ARG_FLAGS with the two divergent extras dropped.
  • Before -> after (what was allowed/blocked, now): BEFORE this revision the floor carried an inline wrapper list of 12 names, so doas git grep -Oless (and pkexec / runuser / chroot / flock / xargs forms) slipped past it while the rest of the argv floor already knew those wrappers; AFTER, the floor steps over the program via argv_rules._program_args, which uses the shared 24-wrapper table, so every one of those wrapper-prefixed git grep -O forms is now refused. The git-global value options also BEFORE added --super-prefix / --exec-path that _GIT_ARG_FLAGS does not list; AFTER the local set is exactly its five entries, so the two lists no longer diverge. No allowed form changed: an ordinary search, git --no-pager, and the empty / cat / git-false no-op values are still allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the cat no-op exception remains the one residual (a cat shadow on PATH), bounded to two values and ruled in by the department lead. The wrapper reuse only ADDS refusals (more wrappers caught), so it cannot open a kill path. The git-global set is kept equal to _GIT_ARG_FLAGS, so a value option is skipped the same way the rest of the floor skips it; a stale mirror could at worst over-skip a rare option, never run a program. argv_rules is imported lazily and does not import this module, so no import cycle and no change to any other floor.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py adds red-first cases for doas / pkexec / runuser / chroot / flock / xargs before git grep -O (all now refused) and a test exercising every argv_floor_git._GIT_ARG_FLAGS entry through the floor; test/test_argv_floor_facade.py (the argv-floor layer-order and type-checker-visibility guards) passes, proving the reuse respects the module layer rule. Both pass locally on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): git -c user.name=x commit, git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, sudo git log, doas git status, and non-git grep -O are all allowed; the pager-refusal, allowed and regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat / empty no-op values keep the product's own core.pager=cat git calls working. Only the pager open / config / writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py, the facade / mirror manifest guards, and the package line budget (re-measured to 35,715) pass locally; flake8 / black / isort are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit 69f56a98e and the test commit, or drop the branch). The floor is pure argv / text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; the only cross-module use is a lazy read-only call into argv_rules._program_args, which reverting removes cleanly.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 11, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e50dd5a
  • What rule changed: the self-protection-git-pager floor is hardened for the GPT 6.1 / Opus 5.5 / Security Scope review round, closing argv-parsing gaps while keeping its scope. Same intent: refuse any git command that opens (grep -O) or configures (core.pager / pager. via -c / --config-env / env / git config writer) a pager a program would run; allow the no-op values (empty / cat) and ordinary searches / reads.
  • Before -> after (what was allowed/blocked, now): BEFORE, four bypasses and one over-refusal existed; AFTER they are fixed. Config writer: the git 2.46+ git config set core.pager <prog> and a writer behind a git global (git -C . config ..., git --no-pager config ...) were allowed; now the subcommand is located AFTER git-global parsing and both the legacy and config set grammars are refused. Command boundaries are now taken BEFORE operands are dequoted (reusing the quote-aware segment splitter), so a quoted ; / | / # / ( in a grep -e pattern or a -c value (e.g. git grep -e ';' -O./p) no longer splits the command and hides a later -O; an unquoted subshell body ( git grep -O x ) is still reached. Pagination and config are evaluated LAST-wins: git -P -p -c core.pager=./p log (the -p re-enables) is refused, git -c core.pager=less -c core.pager=cat log (last is the no-op) is allowed, and a superseded env pager (GIT_PAGER=less GIT_PAGER=cat) is allowed. The extra value-taking globals --attr-source / separate-token --config-env are consumed so grep's -O behind them is seen. Over-refusal fixed: a READ git config core.pager with a trailing redirect / || / pipe (2>/dev/null, > file, | cat) now stays allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the only new ALLOW paths are the config-read-with-redirect forms (a read writes no pager) and the last-wins no-op cases (the effective value is empty / cat / git-false, which run no distinct program), so none can let a kill through; everything else is a new REFUSAL of a real bypass. The cat no-op exception remains the one residual, bounded and department-lead-ruled. A mis-parse would at worst over-refuse a rare git global, never run a program.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py adds red-first cases for each fix -- the config set / -C config writer grammars, the quoted-separator and subshell forms, the last-wins pagination / config / env cases, and the allowed config reads with redirects. test/test_argv_floor_facade.py (layer order + type-checker visibility) still passes. All pass locally on this head (378 in the two pager/denied files).
  • No regression:
    • Tools still work (which tools/commands were run, result): git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, git config core.pager (read), git config get core.pager, sudo git log, doas git status are all allowed; the refusal / allowed / regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat / empty no-op values keep the product's own core.pager=cat git calls working. Only pager open / config / writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py, the facade / mirror manifest guards, the kill / quoting / mint suites, and the package line budget (re-measured to 35,809) pass locally; flake8 / black / isort are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit e50dd5ae9 and the test commit, or drop the branch). The floor is pure argv / text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; the only cross-module use is a lazy read-only call into argv_rules._program_args, removed cleanly by the revert.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 2d93f49
  • What rule changed: this head is the prior reviewed commit e50dd5a REBASED onto current main (7f7a473) with no code change -- only the package line-budget renumber from the merge. The self-protection-git-pager floor still refuses any git command that opens (grep -O) or configures (core.pager / pager. via -c / --config-env / env / a git config writer) a pager a program would run, and allows the no-op values (empty / cat) and ordinary searches / reads; it includes the GPT 6.1 / Opus 5.5 / Security Scope review-round fixes.
  • Before -> after (what was allowed/blocked, now): unchanged from e50dd5a. Refused: git grep -O / --open-files-in-pager; a program-naming core.pager / pager. via -c / --config-env / GIT_PAGER / PAGER / the GIT_CONFIG trio; the git config writer in the legacy and git 2.46+ config set grammars, including behind a git global (-C, --no-pager); all through an execution-prefix wrapper too. A quoted ; / # / ( / | in an operand no longer splits the command; -P / -p and repeated -c / env pagers are last-wins. Allowed: ordinary search, git --no-pager, the empty / cat no-op values, a git-false pager.<cmd>, and a git config pager READ (including with a trailing redirect / || / pipe).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): unchanged from e50dd5a. The only standing residual is the department-lead-ruled cat no-op (bounded to two values); every new behaviour on the prior heads only ADDED refusals of real bypasses or fixed over-refusals of legitimate reads. A rebase-only head cannot change floor behaviour.
  • Evidence checked (which sandbox result proves it): on this rebased head test/test_argv_floor_git_grep_pager.py, test/test_denied_commands_security.py, test/test_argv_floor_facade.py (layer order + type-checker visibility) and the package line budget all pass locally (386 across the four files), and a behaviour probe of every fix class (config set, quoted separator, subshell, last-wins, wrapper, config-read redirect) matches. The code is byte-identical to the reviewed e50dd5a.
  • No regression:
    • Tools still work (which tools/commands were run, result): git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, git config core.pager (read), git config get core.pager, sudo git log, doas git status are all allowed; the refusal / allowed / regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat / empty no-op values keep the product's own core.pager=cat git calls working. Only pager open / config / writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py, the facade / mirror manifest guards, and the package line budget (re-measured to 35,872 after the rebase onto current main) pass locally; flake8 / black / isort are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit 2d93f495f and the test commit, or drop the branch). The floor is pure argv / text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; the only cross-module use is a lazy read-only call into argv_rules._program_args, removed cleanly by the revert.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: fa6b338
  • What rule changed: the self-protection-git-pager floor, with the follow-up GPT 6.1 / Security Scope findings fixed on top of the earlier rounds. It refuses any git command that opens (grep -O) or configures (core.pager / pager. via -c / --config-env / env / a git config writer, legacy or the git 2.46+ config set grammar) a pager that runs a program; it allows ordinary searches, reads, and the no-op values.
  • Before -> after (what was allowed/blocked, now): this head fixes three review findings. (1) A quoted & in a grep pattern or a -f value (git grep -e '&' -O...) was split as a background separator and hid the pager; now the quote-aware pass takes no & boundary, so the pager is seen. (2) A program assembled through a variable across a separator (g=git; $g grep -O) was missed by the per-segment pass; a whole-frame resolved-token pass now catches it (and a real background & splitting two commands). (3) core.pager / GIT_PAGER set to a TRUSTED absolute cat (/usr/bin/cat, /bin/cat) -- the value the product's update-governance resolves core.pager=cat to -- was refused; it is now allowed, while an untrusted */cat (e.g. /tmp/x/cat, ./cat) stays refused. All earlier behaviour (config-set grammar, config-behind-a-global, quoted ;/#/(, last-wins, config-read with a redirect) is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the only new ALLOW is the two trusted absolute cat paths (root-owned, no distinct program) plus a value already ruled a no-op; every other change ADDS a refusal of a real bypass GPT found. The standing residual is the department-lead-ruled cat no-op, now including its two trusted absolute spellings. A mis-parse over-refuses a rare form, never runs a program.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py adds red-first cases for the quoted &, the variable-assembled program, a real background & split, the trusted absolute cat (allowed) and an untrusted */cat (refused); the two config false-refuses (git config core.pager cat; git log, ... || true) are pinned allowed. test/test_argv_floor_facade.py (layer order + type-checker visibility) passes; mypy, flake8, black, isort and the comment-history / brand / vendor source gates pass locally. 397 across the pager/denied/gate/facade files pass.
  • No regression:
    • Tools still work (which tools/commands were run, result): git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, git config core.pager (read, with or without a redirect), sudo git log, doas git status are all allowed; the refusal / allowed / regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the cat / empty / trusted-absolute-cat no-op values keep the product's own git calls working. Only pager open / config / writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py, the facade / mirror manifest guards, and the package line budget (re-measured to 35,910) pass locally; flake8 / black / isort / mypy are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit fa6b33864 and the test commit, or drop the branch). The floor is pure argv / text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; the only cross-module use is a lazy read-only call into argv_rules._program_args, removed cleanly by the revert.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 7bd105c
  • What rule changed: the self-protection-git-pager floor, with the latest GPT 6.1 / Security Scope findings fixed. It refuses any git command that opens (grep -O) or configures (core.pager / pager. via -c / --config-env / env / a git config writer, legacy or the git 2.46+ config set grammar) a pager that runs a program; it allows ordinary searches, reads, and the no-op values (empty / cat / a trusted absolute cat / a git-false pager.).
  • Before -> after (what was allowed/blocked, now): this head closes two bypasses and six over-refusals. (1) A program assembled through a variable across a separator while the pager hides behind a quoted separator (g=git; $g grep -e ';' -O./p) escaped both scan passes; the scan now carries the assignment SOURCE across segments and prepends it before tokenising, so $g resolves while the quoted ; stays part of the command -> refused. (2) git config set --value '.*' core.pager ./p consumed the key as the --value operand; --value / --comment are now consumed, so the write is read and refused. (3) The GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n env trio now pairs KEY_n with VALUE_n, so a no-op pin (GIT_CONFIG_VALUE_0=cat / a git-false) that the product's update-governance and git_gateway set is allowed, while a program value and an unpaired pager key are refused. Everything earlier is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the new ALLOWs are all no-op values (empty / cat / trusted absolute cat / git-false), which run no distinct program; the new REFUSALs close real bypasses. The standing residual is the department-lead-ruled cat no-op. A mis-parse over-refuses a rare form, never runs a program.
  • Evidence checked (which sandbox result proves it): test/test_argv_floor_git_grep_pager.py adds red-first cases for the combined variable+quoted-separator bypass, git config set --value, the env-trio no-op pin (allowed) and an env-trio program / unpaired key (refused); test/test_argv_floor_facade.py (layer order + type-checker visibility) passes; mypy / flake8 / black / isort and the comment-history / brand / vendor source gates pass locally. 404 across the pager/denied/gate/facade files pass.
  • No regression:
    • Tools still work (which tools/commands were run, result): git log -p, git grep --count, git grep -c core.pager, git diff, GIT_PAGER=cat git log, git config core.pager (read), GIT_CONFIG_KEY_0=core.pager GIT_CONFIG_VALUE_0=cat git log, sudo git log, doas git status are all allowed; the refusal / allowed / regression suites pass at this head locally.
    • Backward compatible (old config / old data / old callers still work, how checked): no git grep operand data-exemption is added; relative to clean main no search is newly refused, and the no-op values keep the product's own git calls working. Only pager open / config / writer routes to a real program are refused.
    • Existing tests (which suites passed on this head): test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py, the facade / mirror manifest guards, the kill / quoting / mint suites, and the package line budget (re-measured to 35,941) pass locally; flake8 / black / isort / mypy are clean.
  • How to undo: revert the two commits on this branch (git revert the fix commit 7bd105cc2 and the test commit, or drop the branch). The floor is pure argv / text analysis with no I/O, migration or persisted state, so reverting restores main's exact prior behaviour at once; the only cross-module use is a lazy read-only call into argv_rules._program_args, removed cleanly by the revert.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Response to First Principles Review (Opus 5.5) at 7bd105cc22daf0d9c56e5a6d03387e3315ae11f8

On the premise-level BLOCK (the floor is "oversized" because the agent can run a program directly, so refusing a git pager "adds no protection", and it is a launcher-by-launcher chase): this is a deliberate, recorded owner ruling, not an open design question.

  • The floor is a self-protection deny-gate, defense in depth, not an airtight sandbox. Its value is closing one more route by which the agent can run a chosen program through git itself (including a kill of the gateway's own process), not claiming the agent can never run a program. The owner weighed exactly this "the agent runs programs anyway" argument and ruled the floor ships (authorizations.md R63, relayed by the department lead): fix(security): refuse a git command that opens or configures a pager, a liveness floor (#34098) #34233 is NOT overridden on the premise; fix the concrete findings, get the non-AI gates green, then normal human review.
  • The wider "a git config key runs a program" class (core.sshCommand, core.editor, sequence.editor, diff.external, GIT_EDITOR, alias.*='!...', ...) is explicitly OUT OF SCOPE for this PR and tracked in git grep pathspec false positive in the self-kill floor, and a sound-design sketch #34234 -- the PR's "Not a goal" section says so. This PR is the pager slice; the siblings are not an argument to widen or drop it here.

So the premise objection is resolved at the ownership layer, not in code: a repository writer records the human /ai-review override for this lane per R63. The concrete, code-level findings you and the other lanes raised ARE fixed on this head (arg-grammar scope, config-set grammar and writer-behind-a-global, quoted-separator boundaries, variable-assembled program, --value, last-wins, the env-trio no-op pairing, the trusted-cat no-op). No code change is made for the premise point itself.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 61c8fed

  • What rule changed: the self-protection-git-pager liveness floor drops the carry-prefix pass that re-tokenised a growing prefix for every command segment, so each segment is tokenised once on its own.
  • Before -> after: the earlier scan carried an assembled program across a command separator and grew quadratic on a long command; the scan now reads each segment independently, stays linear in the command length, and leaves constructed-command evasion out of scope.
  • Worst case if wrong: a deliberately constructed pager command (a program name assembled across a separator) runs its pager and hangs that one non-interactive session until it times out; there is no privilege change and no effect on any other session.
  • Evidence checked: ran the pager, denied-commands and liveness-budget suites locally plus a 10,000-segment perf test, confirming the accidental forms still refuse and the walk stays linear on a long command.
  • Tools still work: ordinary git grep, git log, git config reads, and empty or cat pager values still pass, verified against the allowed-forms parametrised tests in the pager suite.
  • Backward compatible: yes for every allowed command; the single behaviour removed is catching one constructed cross-separator form, which the scope note now marks out of scope.
  • Existing tests: test_argv_floor_git_grep_pager.py, test_denied_commands_security.py and test_security_gate_liveness.py all pass at this head, with black, isort, flake8 and mypy clean.
  • How to undo: revert the two commits on branch guard-g/gitgrep-pager-main back to the prior head, or restore the dropped carry-prefix pass inside the _is_git_pager two-pass walk.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: e85212e

  • What rule changed: the self-protection-git-pager liveness floor drops the carry-prefix pass so each command segment is tokenised once, and it strips shell hash line comments before reading a git command so an annotated no-op pager command is not read as a pager route.
  • Before -> after: the earlier scan carried an assembled program across a separator (quadratic on a long command) and read a hash comment's text as part of the command; the scan now tokenises each segment independently, stays linear, and drops a hash comment to end of line the way bash does.
  • Worst case if wrong: a deliberately constructed pager command (a program assembled across a separator, or a pager hidden only inside text that parses as a comment) runs its pager and hangs that one non-interactive session until it times out; there is no privilege change and no effect on any other session.
  • Evidence checked: ran the pager, denied-commands, facade and liveness-budget suites plus a 10,000-segment linear perf test and direct timings, confirming the accidental forms refuse, an annotated no-op and a trailing comment are allowed, a quoted or escaped hash still parses, and the walk stays linear.
  • Tools still work: ordinary git grep, git log, git config reads, empty or cat or trusted-absolute cat pager values, and a git command carrying an explanatory comment all pass, verified against the allowed-forms parametrised tests.
  • Backward compatible: yes for every allowed command; this head refuses strictly less than the prior one (two annotated comment forms become allowed) and removes only the out-of-scope constructed cross-separator form.
  • Existing tests: test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_argv_floor_facade.py and test_security_gate_liveness.py pass at this head, with black, isort, flake8 and mypy clean.
  • How to undo: revert the two commits on branch guard-g/gitgrep-pager-main, or remove the _strip_line_comments call and restore the carry-prefix pass inside the _is_git_pager two-pass walk.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Scope note (head e85212e)

This change is a liveness floor, not a security boundary: it catches the common accidental pager forms that would hang a non-interactive session, and it does not try to stop deliberate evasion. The PR body and the module docstring both state this. The blocking lane comments above still reference the earlier head 7bd105c and have not re-run on this head, so this note addresses them by class, once.

  • Premise (First Principles): shipping the floor as a liveness measure is intentional even though an agent can run a program by other means; that is a design decision, not a defect in this head.
  • O(n^2) on a long command (Opus): fixed here. The carry-prefix pass is removed, each command segment is tokenised once, and a new test pins linear time on a 10,000-segment command.
  • Shell redirection before git, and the --name-only --no-name-only config write (GPT): both are deliberate-evasion constructions (a redirection token placed ahead of git; a cancelled display flag used to trick the config classifier). Deliberate evasion is out of scope for a liveness floor by design; neither is an accidental form.
  • Annotated no-op falsely refused (Security Scope): fixed here. A # line comment that named a pager made the floor wrongly refuse a legitimate no-op (# core.pager=less would hang; use cat then git -c core.pager=cat log). The floor now strips # line comments the way bash does, so the annotated no-op and a trailing git grep foo # -O are allowed, while a quoted or escaped # still parses as a real pager route.

Real accidental-form misses and any perf or crash issue are in scope and were fixed; evasion-class findings are out of scope by design and are not chased.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

VERDICT: APPROVE @e85212e3

Non-author review of head e85212e. Read src/kiro_crew/security/argv_floor_self.py (the +581 block) and the three changed test files in full. No blocking findings.

Checked:

  • Refused forms: git grep -O / --open-files-in-pager (also abbreviated), pager via GIT_PAGER / PAGER, -c core.pager=, git config [set], the GIT_CONFIG_KEY_n/VALUE_n trio, same-line export, and env / nice / timeout / doas wrappers. 28 scratch cases, all refused.
  • Allowed forms: empty pager, cat, /usr/bin/cat, /bin/cat, pager.<cmd>=false, git grep -o, --no-pager, reads of core.pager, the annotated no-op (# core.pager=less would hang; use cat then git -c core.pager=cat log), a trailing git grep foo # -O. 20 scratch cases, all allowed.
  • Comment stripping (_strip_line_comments, line 1484): quote-aware, so git -c 'core.pager=less #x' log, echo "#" ; git grep -O foo, echo '#' ; git -c core.pager=less log and echo a#b; git grep -O foo are still refused. A quote opened inside a dropped comment does not leak to the next line (echo hi # c' newline git grep -O foo is refused).
  • Linearity: no nested loop over segments; the carry-prefix pass is gone. Doubling input (segments, comments, quoted #) roughly doubled time (ratios 1.6 to 2.3, up to ~88 KB).
  • Non-git commands: the early git gate in _is_git_pager (line 1515) returns False; ls -la and echo hello world are not refused.
  • Suites run locally: test_argv_floor_git_grep_pager.py 146 passed (includes test_the_pager_floor_stays_linear_on_a_long_command); test_denied_commands_security.py + test_security_gate_liveness.py + test_argv_floor_facade.py 266 passed.

Non-blocking notes:

  • argv_floor_self.py:1234: the git-global value options are mirrored from argv_floor_git._GIT_ARG_FLAGS; a test pins the mirror, so drift is covered.
  • PAGER=false / GIT_PAGER=false as env values are refused (only pager.<cmd> treats git-false as allowed). Conservative and consistent with the stated design; mention in docs if users hit it.

Not checked: the rest of the repo suite, CI state, and constructed cross-separator programs (declared out of scope by the PR).

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 376fbc7

  • What rule changed: nothing in the floor itself; this head rebases the two existing commits of the self-protection-git-pager liveness floor onto current main 9807bdd, which had moved 582 commits.
  • Before -> after: the previous head e85212e conflicted with main in one place, the package line budget comment in test_security_gate_liveness.py; this head keeps main's budget entries, re-measures the package on the merged tree (36,506 lines) and records the floor's growth as one entry.
  • Worst case if wrong: the budget number could be off, which fails only the line-budget test in CI and refuses nothing extra; the floor code and its tests are byte-identical to e85212e apart from that comment block.
  • Evidence checked: git merge-tree showed test_security_gate_liveness.py as the only conflicting file; on the rebased tree the pager, denied-commands, liveness-budget, facade and git-repo-exec suites ran 459 passed, with black, isort, flake8, mypy and the comment-history gate clean.
  • Tools still work: ordinary git grep, git log, git config reads and the empty or cat pager values are still allowed, covered by the same allowed-form tests that passed at e85212e.
  • Backward compatible: yes; the rebase adds no behaviour beyond what e85212e already shipped and keeps every refusal and allowance unchanged.
  • Existing tests: test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_security_gate_liveness.py, test_argv_floor_facade.py and test_host_git_repo_exec_neutralization.py pass at this head.
  • How to undo: revert the two commits on branch guard-g/gitgrep-pager-main, or push e85212e back to the branch if the rebase itself needs undoing before merge.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: ed3eb73

  • What rule changed: the self-protection-git-pager liveness floor stops refusing five legitimate forms the security-scope harness confirmed at 376fbc7: a here-document body fed to a non-shell program, PAGER behind GIT_PAGER or core.pager, a non-pager GIT_CONFIG_PARAMETERS entry, and Git for Windows' own cat.
  • Before -> after: before, any PAGER word, any GIT_CONFIG_PARAMETERS word and the text of any here-document body counted as a pager route; after, PAGER is read only when git would use it, GIT_CONFIG_PARAMETERS is read entry by entry, and a heredoc body is dropped unless a shell consumes it.
  • Worst case if wrong: a pager command placed inside a here-document body fed to a non-shell program, or hidden behind a mis-read precedence rule, runs its pager and hangs one non-interactive session until it times out; no privilege changes and no other session is affected.
  • Evidence checked: nine new allowed-form tests fail on the 376fbc7 source and pass now, ten new refusal controls (bash heredoc, a command after the delimiter, GIT_PAGER over PAGER and core.pager, pager keys in GIT_CONFIG_PARAMETERS, an untrusted cat.exe) pass on both, and 478 tests pass across the pager, denied-commands, liveness, facade and git-repo-exec suites.
  • Tools still work: ordinary git grep, git log, git config reads, commit messages written through a heredoc, and the empty, cat and trusted absolute cat pager values are allowed; black, isort, flake8, mypy and the comment-history gate are clean.
  • Backward compatible: yes; this head refuses strictly less than 376fbc7 and every refusal the controls pin is unchanged.
  • Existing tests: test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_security_gate_liveness.py, test_argv_floor_facade.py and test_host_git_repo_exec_neutralization.py all pass at this head.
  • How to undo: revert the two commits on branch guard-g/gitgrep-pager-main, or push 376fbc7 back to the branch before merge to restore the previous head.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 00448fd

  • What rule changed: the self-protection-git-pager liveness floor stops refusing five more legitimate forms the security-scope harness confirmed at ed3eb73, and the facade manifest now names the new helpers, which fixed the facade mirror guard failure in the backend tests.
  • Before -> after: before, a newline inside a quoted commit message split the command, PAGER counted for every subcommand, pager.=false did not turn that command's paging off, and cat.exe or a Program Files (x86) cat was refused; after, a quoted newline stays in its word, an environment pager is ignored for a subcommand git never pages or whose pager. is off, and those two cat paths are trusted.
  • Worst case if wrong: a pager reached only through a subcommand wrongly listed as never paging runs and hangs that one non-interactive session until it times out; there is no privilege change and no effect on any other session.
  • Evidence checked: six new allowed-form tests fail on the ed3eb73 source and pass now, nine new refusal controls (forced -p, an alias word, pager., export before git log, config pager on rev-parse, an unquoted newline, sh -c payload newline, an untrusted cat.exe) pass on both, and 563 tests pass including the facade mirror guards, after a rebase onto main 1ca713c.
  • Tools still work: ordinary git grep, git log, git config reads, multi-line commit messages, plumbing reads with a PAGER set, and the empty, cat and trusted absolute cat values are allowed; black, isort, flake8, mypy and comment-history are clean.
  • Backward compatible: yes; this head refuses strictly less than ed3eb73 for every pinned refusal, and the rebase only re-measured the package line budget against main's newer entry.
  • Existing tests: test_argv_floor_git_grep_pager.py, test_denied_commands_security.py, test_security_gate_liveness.py, test_argv_floor_facade.py, test_host_git_repo_exec_neutralization.py and test_facade_mirror_guards.py pass at this head.
  • How to undo: revert the two commits on branch guard-g/gitgrep-pager-main, or push ed3eb73 back to the branch before merge to restore the previous head.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #34166, which fixes the same issue #34098 and is still active. Review here also found the pager floor prevents no hang (a pager already degrades to cat). Reopen if #34166 stalls.

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

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge 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

3 participants