Repository navigation
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the heredoc reading goes into the one shared quote walk, which fixes the cause, and every new verdict refuses more rather than allows more. Notes
[DESIGN-REVIEWED] 8e79a24 Description read[DESCRIPTION-READ] 0629a858658176b1c5073b228f0282ceb8a666dc0d0bd1cfb439eb9cd1bef21b 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix sits at the cause: it is one quote walk that every reader inherits. Older heredoc copies that the new reader could replace are still in the tree. Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: stop a quote character inside a heredoc body from hiding the self-protection and ssh-to-self command lines that follow it — FIX.
[FIRST-PRINCIPLES-REVIEWED] 8e79a24 Description read[DESCRIPTION-READ] 323b22f17e39e6a38ae4a9c96d2f4b72152c6aff46fc01a8905de568e24208a1 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed Self-protection regression: the new heredoc logic in the shared quote walk can hide a live BLOCKING — src/kiro_crew/security/shell_normalizer_walk.py:605 Trigger: the agent submits BLOCKING — src/kiro_crew/security/shell_normalizer.py:323 Trigger: the agent submits [BLOCK-MERGE] 8e79a24 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_walk.py:605 -- Non-heredoc
[BLOCK-MERGE] 8e79a24 Adjudication (Opus 5.5) — is blocking on each finding proportionate?The one fenced finding (F1) still blocks. The input had no adjudicable findings. F1 is UNBOUNDED harm: it bypasses a deny floor. The quote walk treats any 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)
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: The change only affects how the shared shell quote walk reads heredocs. Text after a body's closing line now starts unquoted, so a quote character in the body no longer hides the commands that follow it. Every effect of that is a shell command line, so the classifier can rule on all of it; I have no confirmed regression to report. Separately, the diff deletes the allowed test row TIGHTENING: ADJUDICATED: 24 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: 21 posix rows and 3 windows rows; no
The diff assumes nothing about paths, executable names or environment variables beyond bash heredoc grammar. cmd and PowerShell have no [SCOPE-REVIEWED] 8e79a24 The confirmed rows, in the committed corpus's own shape{
"golden_paths": [
{
"kind": "shell",
"command_or_flow": "cat > notes.md <<'EOF'\nit's done\nEOF\nssh deploy@build.example.com uptime",
"platform": "posix",
"reason": "an operator records a note then checks a remote build host's uptime (not this machine)"
}
]
} |
d4de175 to
29d1a2d
Compare
|
resolution: one forward walk; no re-walk from an earlier offset
|
|
resolution: body is its own piece; the command line is read without the body's quote
|
29d1a2d to
d98133e
Compare
…like bash bash reads a heredoc body line by line, up to its closing line, and reads the next line with no quote open, whatever quote characters the body held. It does the same for a heredoc inside a $(...) substitution or a backtick. The shared shell quote walk read the whole text with one quote state, so a lone quote in a body turned the lines after it into quoted text, and inside a substitution it hid the ) that closes the substitution. The quote walk (_iter_shell_chars) now reads heredocs itself: a << outside quotes opens a body on the next line, and the walk starts unquoted where the body's closing line ends. The body's steps are still yielded, so a shell fed the body is judged as before. Every reader built on the walk inherits this, including the $(...) and backtick close-finders, the word and segment splitters, and read_commands, with no change at their call sites. A new module, shell_heredoc_lines, reads the tag after << and each body's closing line from raw lines. It never looks for the close of a substitution. It decodes the escapes of a $'...' tag with the shared ANSI-C decoder, as bash does before it compares lines with the tag. read_commands reads its tags and closing lines from it, which removes its own copies. _self_tokens tokenizes the text in pieces cut around each body, in the same walk (_heredoc_line_pieces), and the ssh floor's separator mask starts fresh after a body's closing line (heredoc_body_spans). Each walk reads each body once, so the cost stays linear in the text.
d98133e to
8e79a24
Compare
|
resolution: the tag is decoded before a closing line is matched
|
Problem / Motivation
Goal: The argv floors read the text after a heredoc's closing line with no quote open, as bash does, so a quote character inside a heredoc body no longer changes how the following command lines are read.
bash ends a heredoc body at its closing line and starts the next line with no open quote, whatever quote characters the body held. The argv floors (
self-protection-*subcommand floors andsandbox-escape-ssh-self) walked the whole command text with one quote state. A lone'or"in a data body therefore turned the following command lines into quoted text, and those lines were not judged as commands.Why it matters
The floors decide whether a self-management command or an ssh to this host is refused. When their reading of a multi-line command differs from bash's, a command line bash runs is judged as text. Agents write heredocs with quotes in the body all the time (Markdown, scripts, prose), so the floors must read those lines the way bash does.
Not a goal
bash <<'EOF'): they stay in the token list and are judged as before.#comments: the floors do not model them, on main or here.What changed (motivation → approach → change)
Symptom → cause → change. The argv floors read a command through one shared quote/escape walk,
shell_normalizer_walk._iter_shell_chars. That walk did not understand heredocs, so a quote character inside a heredoc body carried its quote state past the body's closing line, and the following command lines were read as quoted text. Nesting made it worse: a heredoc inside a$(...)left the substitution close-finder (which runs on the same walk) open, so it swallowed the tail and a later command line was never read as a command._iter_shell_charsnow reads heredocs itself: a<</<<-outside quotes records its tag; at that line's end it finds each body's closing line; and the walk resets to unquoted where the closing line ends. Body characters change no quote state. The body steps are still yielded, so a shell fed a body is judged as before.$(...)and backtick close-finders (_close_paren_walk/_matching_close_paren,_matching_close_backtick),read_commands, the word and segment splitters,_heredoc_line_pieces, and the git, rm, s3 and cron readers.shell_heredoc_lines.py, reads each heredoc's tag and closing line from the raw lines only. It skips a<<<here-string and a<<inside an unclosed((, imports nothing at load time, and never calls a close-finder, so the body search does not depend on the substitution parsing it feeds.read_commandsnow takes its tag and closing line from it, and its own copies are removed. It decodes an ANSI-C$'...'tag with the shared escapes helper before matching a closing line, as bash does.argv_floor.pylists the new facade name;security.mddescribes the reading.Backwards compatibility
Breaking: the argv floors now read the lines after a heredoc's closing line as commands even when the body held an unmatched quote, and read a
$(...)that contains a heredoc to its real). Main read those lines as quoted text, so main allowed four commands this change refuses: an ssh to this host, orkirocrew restart, hidden after a heredoc whose body holds a quote, in a$(...), a backtick, or anx=$(...)assignment. Each is the floor doing its job once the line is read as bash reads it. Writer sweep: no in-tree caller writes these shapes.Removes nothing: no deny pattern, rule id, catalog row or operator toggle is removed or renamed.
heredoc_closing_linesand_heredoc_tagare replaced byshell_heredoc_lines, an internal helper with no caller outsidesecurity/.scripts/deny_diff.py --base origin/mainongolden-paths.jsonplus 23 heredoc rows: 0 newly allowed; 4 newly refused, all self/ssh commands a heredoc body was hiding; 45 golden paths allowed at both refs, no regression.Tests
test/test_denied_commands_security_heredoc_data.py: the quote-after-closing-line rows from the first approach, plus nesting rows where a self-subcommand or an ssh line follows a heredoc inside$(...), a backtick,<( ), and anx=$(...)assignment. The nesting rows fail first: 4 fail on origin/main and 2 on the PR's earlier head._heredoc_data_view,argv_floor_self,argv_floor,denied_commands_security,shell_commandsorshell_normalizer, plus facade mirror, facade mirror guards, split-patch reach, listing budget and gate liveness): 6,869 passed, 1 skipped. mypy, black, isort, flake8, subprocess encoding, line cap, comment history, brand and the flake ratchet pass.test_heredoc_pieces_walk_the_text_oncereads a character-counting string over 400 nested bodies and holds the walk to at most 3x the text length.Proof: PROVEN test/test_denied_commands_security_heredoc_data.py::test_line_after_closing_line_starts_unquoted[cat <<'EOF'\nit's\nEOF\nkirocrew restart\n# '-self-protection-restart], test/test_denied_commands_security_heredoc_data.py::test_line_after_closing_line_starts_unquoted[cat <<EOF\nit's\nEOF\nkirocrew restart\n# '-self-protection-restart], test/test_denied_commands_security_heredoc_data.py::test_line_after_closing_line_starts_unquoted[cat <<-'EOF'\n\tit's\n\tEOF\nkirocrew restart\n# '-self-protection-restart], test/test_denied_commands_security_heredoc_data.py::test_line_after_closing_line_starts_unquoted[tee out.txt <<'EOF'\nit's\nEOF\nkirocrew restart\n# '-self-protection-restart], test/test_denied_commands_security_heredoc_data.py::test_line_after_closing_line_starts_unquoted[cat <<'A'\nit's\nA\ncat <<'B'\nok\nB\nkirocrew restart\n# '-self-protection-restart] (head 8e79a24)
Manual verification
N/A — the floors are pure functions of the command text, and the unit rows call them through
is_denied.Real-machine verification
N/A — the diff changes only how the argv floors read command text; it runs nothing on a machine.
Screenshots / video
N/A — no UI change.
Related Issues
Related: #39056 (the ssh-to-self floor's heredoc data reading).
Sibling sweep
Swept: git grep -n "heredocs=True|_iter_shell_chars" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/shell_normalizer_walk.py -- changed here
Sibling: src/kiro_crew/security/shell_heredoc_lines.py -- changed here
Sibling: src/kiro_crew/security/shell_normalizer.py -- changed here
Sibling: src/kiro_crew/security/shell_commands.py -- changed here
Sibling: src/kiro_crew/security/argv_floor_ssh.py -- changed here
Sibling: src/kiro_crew/security/rm_floor.py -- not affected -- it reads the same walk, so it inherits the fix
Sibling: src/kiro_crew/security/s3_direction.py -- not affected -- it reads bodies only to tell an upload from a download
Sibling: src/kiro_crew/security/argv_rules.py -- not affected -- its command reader already ends a body at its closing line
Pattern harvest
Not generalizable: the other heredoc readers already end a body at its closing line; the argv floors' frame reader was the one that did not.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.