Repository navigation
fix(security): refuse a git command that opens or configures a pager, a liveness floor (#34098) - #34233
fix(security): refuse a git command that opens or configures a pager, a liveness floor (#34098)#34233chenmingwei23 wants to merge 2 commits into
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)Design-level review of 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. BlockersThe config/env pager routes it refuses do not hang this tool path Notes
[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 |
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of 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 Not checked: whether any hang seen in #34098 came from a PTY-backed shell rather than the piped tool path. Notes
What this change shipsInventory (10 items) — 2 justifiedIntent: keep an agent session from hanging on a git pager. FIX.
Blockers1. The refusals remove no observed harm — zero option 2. A second shell walk — duplicate of [FIRST-PRINCIPLES-REVIEWED] 00448fd Description read[DESCRIPTION-READ] 2ebf3b838275293575e65850058ea2d51abb568de6c4562313432a06bcb422a5 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed BLOCKING: a new test passes or fails depending on wall-clock time, which the blocking BLOCKING — test/test_argv_floor_git_grep_pager.py:1545 Notes:
[BLOCK-MERGE] 00448fd Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that 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
BLOCKING -- src/kiro_crew/security/argv_floor_self.py:1886 -- Pager assignments survive explicit environment removal
BLOCKING -- src/kiro_crew/security/argv_floor_self.py:1632 -- Unquoted heredocs lose executable substitutions
BLOCKING -- test/test_argv_floor_git_grep_pager.py:643 -- Absolute wall-time assertion makes correctness depend on CI load
[BLOCK-MERGE] 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 F2 — LOW, downgraded. Also a false refusal, and only on a contrived input: a F3 — upheld (harm-warrants-remedy). Here the gate misses a pager rather than over-refusing. The new F4 — upheld (autosde-blocking-rule). False positive or not applicable? A repository writer can comment: |
Security Scope Review -- 🔴 BLOCK (blocking)Which legitimate operations does Verdict basis: a script-confirmed newly-refused operation. Security scope review -- adjudicated candidates
Newly refused (confirmed by the real classifier at both refs)
GIT_PAGER=less git log hangs a session; use git --no-pager log.
GIT_PAGER=less git log hangs a session; use git --no-pager log.
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 TIGHTENING: new ungated floor ADJUDICATED: 33 candidates, 0 confirmed newly-refused PLATFORM COVERAGE:
UNADJUDICATED: Nothing in this tightening is beyond the classifier. One owner-ruled boundary still needs a human decision: a no-op [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."
}
]
} |
|
This PR and #34166 both close #34098. Both make the self-kill floor refuse the same five Please keep one of #34166 and #34233 and close the other, carrying over anything only this one has. |
Sensitive change review
|
fbd1cf9 to
c7c9126
Compare
c7c9126 to
56d1b26
Compare
Sensitive change review
|
56d1b26 to
bddfdb3
Compare
Sensitive change review
|
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
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
Things to check (the decider's concerns; it is right less than half the time):
If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
bddfdb3 to
cd3ebad
Compare
1433fea to
b708d8b
Compare
Sensitive change review
|
Response to First Principles Review (Opus 5.5) at
|
Sensitive change review
|
b708d8b to
69f56a9
Compare
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Response to First Principles Review (Opus 5.5) at
|
Sensitive change reviewHead: 61c8fed
|
Sensitive change reviewHead: e85212e
|
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.
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. |
|
VERDICT: APPROVE @e85212e3 Non-author review of head e85212e. Read Checked:
Non-blocking notes:
Not checked: the rest of the repo suite, CI state, and constructed cross-separator programs (declared out of scope by the PR). |
Sensitive change reviewHead: 376fbc7
|
Sensitive change reviewHead: ed3eb73
|
Sensitive change reviewHead: 00448fd
|
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-pageropens the matching files in it, andcore.pager/pager.<cmd>set through-c,--config-env,GIT_PAGER,PAGER,GIT_CONFIG_PARAMETERSor aGIT_CONFIG_KEY_nenv 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 -Oor 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 absolutecat) stay allowed because the product's own git calls and the interactive-liveness advice use them.Not a goal
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.git grep(including lowercase-o) is untouched.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-pagerungated floor (no catalog row, no opt-out) beside the existing restart/update/kill floors; it reads the argv in ORIGINAL case and descends nestedeval/sh -cpayloads. The floor matches the OPERATION, not the pager PROGRAM NAME: a name is swappable (a shell alias, a function, aPATHshim,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 absolutecat(/usr/bin/cat,/bin/cat) forcore.pager/GIT_PAGER/PAGER, and a git-falsepager.<cmd>(false/no/off/0). An untrusted*/cat(/tmp/x/cat) is still refused.cat/empty is allowed because the interactive-liveness advice proposesGIT_PAGER=catand the product's own git calls usecore.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, sogit grep -c <pat>(count) andgit grep -e <pat>(a separate-token pattern) are not mistaken for a git-global pager control, and a subcommand-Pdoes 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=/ aGIT_CONFIG_KEY_nnaming a pager key; the persistent writergit config core.pager <prog>(andpager.<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 agithidden behind an empty substitution (gi$()t) still enters the scan.Allowed (no program runs): lowercase
git grep -oand ordinary options/patterns (-Ois read case-sensitively; a short-option cluster stops at an operand like-e<pat>); the no-op VALUES above; a git-falsepager.<cmd>; agit configread/unset (--get/--list/--unset/a key with no value); a non-pager-c key=val;-Oafter a--operand terminator (a pathspec); and--no-pager/-P(which cancels a pager-config/env route but nevergrep -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.pylock each refused and allowed form:grep -Oin every spelling, the config/env/wrapper/same-line-export writers, the git-grammar scope, the no-opcat/empty/trusted-absolute values, and thegi$()tcheap-gate form. Atest_the_pager_floor_stays_linear_on_a_long_commandperf 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 main9807bdd5d):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), andflake8/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