Repository navigation
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change reuses the existing Notes
[DESIGN-REVIEWED] fa59e37 Description read[DESCRIPTION-READ] c880712901e12bef9af737a7d4ac20a126f109ed11a13af4481ca46c6ecc3a0a 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 Nothing blocks. The fix reuses the existing heredoc reader. Its two guards, for Notes
What this change shipsInventory (4 items) — 3 justifiedIntent: let an agent feed a Python or text edit script on a heredoc without a false ssh-to-self refusal (FIX).
[FIRST-PRINCIPLES-REVIEWED] fa59e37 Description read[DESCRIPTION-READ] c6e175516fe1b2fa7977cb9e46820436e87bf7638b5e6ebc2507a21b7613359f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed 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 — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The change only adds an early TIGHTENING: None. This is a loosening of the ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE:
UNADJUDICATED: The documentation hunk describes the [SCOPE-REVIEWED] fa59e37 |
b12f078 to
39f7aec
Compare
39f7aec to
29c4c1f
Compare
Sensitive change review
|
Code change approver recommendation: A person should decideWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. The PR adds a pre-check to the ssh-to-self floor. It cuts out heredoc bodies only when every command on the line is a plain cat, tee or cd, or Python reading stdin or a file. The line must also have exactly one plain-word tag that appears exactly twice ignoring case, no backslash-newline, no compound or arithmetic marks outside the body, no Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
This PR needs one change before it can merge. The head is correct on its own base, but merging it onto current main breaks the security package import.
src/kiro_crew/security/argv_floor_ssh_heredoc.py:27: after #39757 merged, main defines_HEREDOC_DATA_PROGRAMS = frozenset({"cat", "tee"})inargv_floor_self.py:1144. That module is also anargv_floorfacade owner, andargv_floor.pyalready lists the name in its manifest. This PR binds the same name to a different set ({"cat", "tee", "cd"}) in a second owner. The merge has no text conflict. But in the merged tree,import kiro_crew.security.argv_floorraisesRuntimeError: ... names bound to different objects across the family are ['_HEREDOC_DATA_PROGRAMS'], but the facade declares []from_facade_mirror.install. Sokiro_crew.securityfails to import, the gateway cannot start, and every backend test fails at collection. CI passed only because this head's merge-base predates #39757. Smallest fix: rebase onto main, then rename this module's set (for example_SSH_HEREDOC_DATA_PROGRAMS) in the module and in the TYPE_CHECKING manifest line inargv_floor.py. The two sets differ, so they cannot share one object. In a scratch copy of the merged tree, that rename alone made the import work, and the related test files passed. Then let CI run again on the rebased head.
Optional:
- #39757 added a second heredoc-as-data reader for the self floors (
_heredoc_data_viewinargv_floor_self.py). It accepts apython -body only when the body parses as inert. This floor accepts anypython -body, because Python running ssh is already this floor's documented residual. Could thesecurity.mdparagraph state that difference? Also, the body's Sibling sweep and Pattern harvest were written before #39757 landed. Could they be updated to match current main? - Several fail-closed guards stay green when they are deleted one at a time. These are the paren, backtick,
[[and$[marks, the backslash-CRLF check,not docs, and the body-backtick check._runs_no_bodycatches every case, so I found no bypass. The comment on the((cat<<z))row says it pins the left-shift reading, but it actually pins_runs_no_body. The mutation sentence in the Tests section could list these guards.
Good: the pre-pass can only turn a refusal into an allow. It also cuts the << and its tag together with the body, so lines after the closing tag are still read as commands.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for moving both floors onto one heredoc reader. Two problems in the new code need fixing before this can merge.
src/kiro_crew/security/argv_floor_heredoc_data.py:349(_join_opener_continuations, which uses_backslash_newlinesat line 413): the join treats every backslash before a newline on a<<line as a line continuation. It does not check for an escaped backslash or a#comment. Takecat <<'EOF' x\\orcat <<'EOF' # note \, thenEOF, thenssh -p 22 localhost idorkirocrew restart, thenEOF. The join glues the real closingEOFonto the opener, and the reader blanks the next line as body. Bash closes the heredoc at the firstEOFand runs that line. Throughis_denied, main refuses all of these (sandbox-escape-ssh-self, self-protection-restart) and this head allows them. That breaks the goal's rule that every heredoc a shell could run stays refused. Smallest fix: join only the plain<<[-]TAG+ blanks + single\opener form that your continuation rows need. For any other backslash-newline on an opener line, returntext_lowerso every body is kept. Add refuse rows for the escaped and comment forms on both floors.src/kiro_crew/security/argv_floor_heredoc_data.py:274-281: the tag-count check runs.lstrip("\t")on every tag and every line, even when the heredoc is not<<-. Example: acat > scripts/upgrade.sh <<'EOF'body that holds its own tab-indentedcat <<-EOF ... \tEOF, plus akirocrew restartline. The check counts twoeoflines for one tag, keeps the body as argv, and refuses the store. Main allows it, so this is a new false refusal that the Backwards compatibility list does not mention. Removing the lstrip from both lines leaves all 220 rows in the two test files green, so no test pins this behaviour. Smallest fix: strip leading tabs only on lines inside or closing a<<-body. Add allow rows for the nested case and one refuse row where a tabbed tag really closes a<<-body.
Earlier review item: the duplicate _HEREDOC_DATA_PROGRAMS binding is fixed on this head. The set now has one definition in argv_floor_heredoc_data.py, and argv_floor_self re-exports that same object.
Optional:
- The Sensitive Change Review comment and the "0 newly refused" deny_diff claim describe head 29c4c1f and a module that no longer exists. Could you re-post both for the fixed head?
argv_floor_self.py:33-55re-exports 21 names, but only_heredoc_data_viewand_python_body_is_datahave a reader through that path. The other 19 lines could go.- Changing the CRLF join width at line 355 to 2 turns no row red. A CRLF refuse row (
cat <<'EOF' \CRLF| bash...) would pin it.
3d43360 to
c948699
Compare
|
resolution: removed _join_opener_continuations; no line joining
|
|
resolution: removed _join_opener_continuations; no line joining
|
c948699 to
bb96a10
Compare
|
resolution: narrowed; the ssh floor skips the heredoc view on any \r
|
|
The second "Not a goal" bullet is edited, with the Lead's OK: from round 4 on, this PR no longer changes the self-subcommand floor. The ssh floor reuses |
The ssh-to-self floor read every here-document body as command words, so a Python edit script fed on a heredoc (`n = a * localhost`) read as a glob verb naming ssh and its target, and was refused. The ssh floor now reads the line through the heredoc view the self-subcommand floor already uses, `_heredoc_data_view`, unchanged. It allows the line when the view blanked a body and the blanked line reaches no self host. The view reads the words as written, because bash matches a closing line case-sensitively. The floor skips the view and reads the whole line as before when the text holds a carriage return or a line holding `<<` ends in a backslash, two shapes the view reads differently from bash. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
bb96a10 to
fa59e37
Compare
|
resolution: narrowed; the ssh floor finds bodies on the words as written
|
|
This review found no blocking problem on fa59e37. It cannot approve yet, because PR Readiness is red. The Sensitive Change Review check says the template comment names old head 29c4c1f. That comment also describes Earlier review items:
What the review checked: reverting the 18-line hunk turns 54 of 131 rows red, including every allow row. Removing the Optional:
|
Withdrawn: every item in this review is fixed or answered on the current head (see the follow-up comment). Other holds on this PR are listed there.
Problem / Motivation
Goal: An agent's Python edit script fed on a here-document (
python3 - <<'EOF'withn = a * localhostin the body) is no longer refused as an ssh-to-self escape, while every heredoc a shell or another program could run stays refused.sandbox-escape-ssh-selfrefusespython3 - <<'EOF'\nn = a * localhost\nEOFand the same script written withcat > s.py <<'EOF'and then run. Nothing on either line runs ssh. The floor reads the heredoc body as command words, so a bare*(multiplication) reads as a glob verb that could namessh, andlocalhostas its target. Reported in #34754; #34755 by @Marsjohn-11 fixed it together with two parts main already has through #36992, and is now conflicting.Why it matters
A heredoc-fed edit script is a common agent shape, so this false refusal recurs on ordinary work. The refusal sends the agent down the sandbox-escape recovery path, which is the wrong guidance for a local file edit, and the only way past it today is turning the whole rule off.
Not a goal
-d @exfil carve-out and the exfil refusal diagnostic from fix(security): stop the ssh-self and -d @ gates refusing inert lines #34755: main has both through fix(security): stop the file-body exfil gate refusing inert date lines #36992._heredoc_data_viewis reused unchanged. Reading stored scripts, a leadingcd <path> &&and Python options such as-uas data is deferred to security: read stored-script, cd && and Python-flag heredocs as data in the self and ssh floors #40368.python3 -ctoday.#comments: the floor does not model them, on main or here.What changed (motivation → approach → change)
Symptom → cause → change. The ssh floor walked heredoc bodies as argv. Main's self-subcommand floor already has a reader that blanks bodies no program runs,
_heredoc_data_view(argv_floor_self.py). The ssh floor now uses that same reader, unchanged, instead of a second one._judge_ssh_to_self(argv_floor_ssh.py, +18 lines) reads the line through_heredoc_data_view, run on the words as written and only then lowered, because bash matches a closing line case-sensitively (without the words as written, the view is not taken). It allows when the view blanked a body and the blanked line reaches no self host. Otherwise it reads the whole line as before, so the ssh floor only gains allows.\r<<ends in a backslashsecurity.mddescribes the ssh floor's use of the view. The reader, the self floor and the facade are unchanged.cat > s.py <<'EOF'…python3 s.py, a leadingcd <path> &&, and Python options such as-ustay refused, as on main. #40368 tracks them, with the review findings from this PR as design notes.Backwards compatibility
Compatible: the only verdicts that change are refused → allowed on the ssh-to-self floor, for a line whose heredoc bodies the self floor's view already reads as data and whose blanked line reaches no self host. Every other line keeps main's verdict, because the whole line is still read when the view refuses or is skipped.
Removes nothing: no deny pattern, rule id, catalog row, reader rule or operator toggle is removed or renamed.
scripts/deny_diff.pyagainstorigin/main, on every row the Security Scope Review found over this PR's rounds plus the GPT and Opus repros: 0 newly refused (32 posix rows classified).Tests
test/test_denied_commands_security_ssh_self_heredoc.py: 16 allow rows (thepython3 -repro,tee, quoted bodies holding an ssh line, a quoted body with a backslash-newline, tag spellings such as<<'MD'andEOFin a sentence), 12 rows where a program can run the body, 64 rows where the reader could misread the line (a body line that is the tag in another case, CRLF heredocs,<<lines ending in\,x\\or# \, case-mismatched tags, a second heredoc, wrappers, stored scripts,cd, Python options), the common-form matrix (38 rows), andtest_argv_floor_imports_in_a_fresh_interpreter._heredoc_data_view,argv_floor_self,argv_floorordenied_commands_security, plus facade mirror, listing budget and gate liveness): 5,827 passed, 19 skipped. mypy, black, isort, flake8, subprocess encoding, line cap, comment history, brand and the flake ratchet pass.FALLBACK_TIMEOUT_SECS.Proof: PROVEN test/test_denied_commands_security_ssh_self_heredoc.py::test_body_no_program_can_run_is_data[python3 - <<'EOF'\nn = a * localhost\nEOF], test/test_denied_commands_security_ssh_self_heredoc.py::test_body_no_program_can_run_is_data[tee f <<'EOF' >/dev/null\nn = a * localhost\nEOF], test/test_denied_commands_security_ssh_self_heredoc.py::test_body_no_program_can_run_is_data[cat <<'EOF'\ninert\\ntext\nssh -p 22 localhost id\nEOF], test/test_denied_commands_security_ssh_self_heredoc.py::test_body_no_program_can_run_is_data[cat > release.md <<'MD'\nssh -p 22 localhost id\nMD], test/test_denied_commands_security_ssh_self_heredoc.py::test_body_no_program_can_run_is_data[cat > note.md <<'EOF'\nThe file ends at EOF.\nssh -p 22 localhost id\nEOF] (head fa59e37)
Manual verification
N/A — the floors are pure functions of the command text, and the unit rows call them directly.
Real-machine verification
N/A — the diff changes only how the argv floors read command text; it runs nothing on a machine.
Related Issues
Closes #38979
Ports the ssh-self part of #34755 by @Marsjohn-11 (credited as co-author). Reported in #34754.
Merge order: this PR merges first; #34156, which also edits
argv_floor_ssh.py, then rebases onto it.Sibling sweep
Swept: git grep -n "heredocs=True" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/argv_floor_self.py -- not affected -- its
_heredoc_data_viewis reused unchanged by the ssh floorSibling: src/kiro_crew/security/rm_floor.py -- not affected -- it already cuts bodies a shell does not read (_without_bodies)
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 keeps a body out of argv unless a shell reads it
Pattern harvest
Not generalizable: the ssh floor now reuses the self floor's heredoc reader, and the other floors already read heredoc bodies as data unless a shell runs them.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.