Repository navigation
fix(shell-walk): read a heredoc body as commands only when its consumer can run it - #19892
mbriones98 wants to merge 3 commits into
Conversation
86f8116 to
2db1858
Compare
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Before merge, confirm the existing denied-command and argv-floor suites pass unchanged. None of them should expect a [DESIGN-REVIEWED] df249d4 Description read[DESCRIPTION-READ] bcdedf309b1ac1a807a4c48ec3330f173976b16b1895ccee2a54671152e2180c 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) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The data-consumer allow-list sets heredoc bodies aside for 15 programs and 4 subcommands that no reported defect or test calls for. Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: stop the shared shell reader refusing commit messages and heredoc-written files that only name a refused command, and make its descent bound the same on every host. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] df249d4 Description read[DESCRIPTION-READ] 28fdcad5a6b26ffb20d90bfb5feda1e25de104d9c4bcf28ae2a21eac0a6a0fc2 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed Blocking: two easy-to-write shapes of shell text now hide a BLOCKING — src/kiro_crew/security/shell_normalizer.py:3590 BLOCKING — src/kiro_crew/security/shell_normalizer.py:3565 [BLOCK-MERGE] df249d4 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/shell_normalizer.py:3569 -- Quoted literal text deletes subsequent executable commands BLOCKING -- src/kiro_crew/security/shell_normalizer.py:3606 -- Literal runner membership drops heredoc bodies that execute [BLOCK-MERGE] 2db1858 Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — security-class (unbounded). I confirmed the conditions. F2 — security-class (unbounded). I confirmed the conditions. False positive or not applicable? A repository writer can comment: |
…y reads it Read the body as data only when, with it removed, every command of every frame is a listed data consumer, and the opener line ends its command at the newline. git and gh qualify only through a message subcommand right after the program. The frame source drops the body along with its tokens.
|
|
|
|
|
|
Sensitive change review
|
…c-home-19588 # Conflicts: # test/test_security_gate_liveness.py
|
|
Sensitive change review
|
Security Scope Review -- 🔴 could not complete (fails closed)No scope verdict for |
|
|
|
Superseded by #19951 (same change, recut as a single commit on current main). |
Pull request was closed
Problem / Motivation
Goal: Make the shared shell reader treat a heredoc body the way bash does and bound its descent on structure, so every argv floor reads the same, correct command shape.
security/shell_normalizer._shell_payload_walkis the one reader every argv floor goes through. It has two readings that do not match what the shell runs:;, so it cannot tellbash <<EOF(runs the body) fromcat <<EOForgit commit -F - <<EOF(reads it as data). A commit message, PR body or spec bullet that only names a flagged command is then read as that command.$HOMEexpansion is not read. The walk descends a payload only while it is shorter than its parent's text, but$HOMEis expanded per token before that comparison, so on a host with a long home path a payload exceeds the line and is skipped.Why it matters
The first reading produces false refusals of ordinary data (a commit message, a file written through a heredoc). The second makes a correctness bound depend on a value outside the command, so the same command reads differently on two hosts. Both live in the one reader, so every floor inherits them.
Not a goal
What changed (motivation → approach → change)
The reader (
security/shell_normalizer.py) folds a heredoc body into the frame as;-separated commands, which is why a data consumer's body is scanned as if it ran. The fix attributes a body to its consumer with a positive allow-list over the whole command: the body is set aside as data only when, with it removed, every command of every frame is a listed data consumer -- a barecat/tee/head/grep-style program, orgit/ghfollowed directly by a message subcommand (git commit/tag/notes,gh pr/issue/release). Any other program anywhere keeps every body: a shell or evaluator,xargs, a pipe into an unlisted program, a path such as./f, a leading assignment, an operator glued inside a word, a process substitution, orgit/ghwith an option before the subcommand. The opener line must also end its command at the newline: a trailing backslash or an open quote keeps the body. Only the one-heredoc, one-opener-line shape is attributed. The frame's source drops the body together with its tokens, so token readers and source readers see the same command.The descent bound is measured with the home path discounted, so a payload that lives inside one token of its parent stays shorter than the parent whatever the home path's length. The bound stays structural and no longer varies with
$HOME.The module spec entry for the reader is updated to describe both, and states the heredoc attribution as the one reading the reader sets aside, with why it lives in the reader. The package line budget rises for the added helpers.
This unblocks the parked
chmodfloor work in #19563, which can drop its local heredoc workaround and rely on the reader once this lands. #14993 rewrites the same walk for performance and will need a rebase against whichever lands first.Backwards compatibility
Compatible: no command that is refused today becomes allowed unless every command in it is a listed data consumer; the only behaviour that changes is that a provably-inert data body is no longer read as commands, which removes false refusals. The frames the walk returns for every runner shape are the same.
Removes nothing: no reader, record, key or public function is removed; the walk's return type and callers are unchanged.
Tests
test/test_shell_walk_heredoc_and_home_bound.pylocks the walk's behaviour on neutral commands: a data-consumer body is set aside (and absent from the frame source); a body any unlisted program, path, assignment, glued operator, process substitution, unlistedgit/ghsubcommand or-coption could run is read; a backslash-continued opener line and multi-heredoc shapes keep their body; a substitution inside a data body is still its own frame; and a nested payload is descended for both a short and a long home path, with the walk terminating on deep nesting.test/test_security_gate_liveness.pyraises the package line budget to match the added helpers.Manual verification
N/A — unit coverage sufficient; the change is in a pure text reader exercised directly by the new tests and the existing shell-normalizer / argv-floor / denied-command suites.
Related Issues
Closes #19588
Pattern harvest
Rule candidate: review-prompt
Pattern: a text reader that folds a data region into executable structure refuses data that merely names a flagged command; attribute the region to its consumer through a positive allow-list over the whole command, so an unrecognised program keeps the region as commands.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)