Repository navigation
fix: read a heredoc body nothing runs as data in the self floors - #39757
Conversation
Sensitive Change ReviewSensitive files changed:
|
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The data view only narrows the floor for bodies nothing runs, and any doubtful case falls back to the old read. Notes
[DESIGN-REVIEWED] bb8a13c Description read[DESCRIPTION-READ] aff106ce499a30c16ff98be97d80fe3cefbcfe498fb953351288f05ccc7c3f64 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 Every item is aimed at the reported defect (#39663), so nothing blocks. The one weakness is a third heredoc-body classifier next to two existing ones, which the author already declares. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: let the agent write or print text that mentions a cloud command through a heredoc without being refused as a destructive cloud action. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] bb8a13c Description read[DESCRIPTION-READ] 31d5d1075efbcfd373f888867f8a8989261bdb2555f562d4a8043be4ab33ec72 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: This diff relaxes the rule. It does not tighten it. Before the self-subcommand floors (restart, update, gateway restart, cloud, skills authority-retire) match the text, they now blank out heredoc bodies that nothing runs. The only way the change could newly refuse something is if the new TIGHTENING: Nothing gets stricter. The self-subcommand floor's input view changes. ADJUDICATED: 18 candidates, 0 confirmed newly-refused PLATFORM COVERAGE:
[SCOPE-REVIEWED] bb8a13c |
363c60b to
44f083b
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
Review dispositions for 363c60b, fixed in 44f083b:
|
44f083b to
e6b1005
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
GPT 6.1 dispositions for 44f083b, both fixed in e6b1005:
prove.py PROVEN on e6b1005 (5 data cases). Local gate, 1744 security tests, black, isort, flake8, mypy, file line cap and comment-history gates clean. The Sensitive Change Review template is reposted for the new head and the PR stays flagged |
e6b1005 to
57dbd84
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
Both reviewers' blocking finding on e6b1005 (the regex Python "inert body" allowlist accepts
Any other statement — a bare call, a Tests: prove.py PROVEN on 57dbd84; local gate, 1762 security tests, black, isort, flake8, mypy, file line cap and comment-history gates clean. SCR reposted for the new head; PR stays flagged |
57dbd84 to
2ecbd67
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
Dispositions for 57dbd84, fixed in 2ecbd67. GPT 6.1 (three blocking):
First Principles BLOCK (reuse the rm floor's heredoc classifier instead of a third):
prove.py PROVEN on 2ecbd67; local gate, 1766 security tests (incl. the cost/linearity suite), black, isort, flake8, mypy, file line cap and comment-history gates clean. SCR reposted; PR stays flagged |
2ecbd67 to
8a501a5
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
Dispositions for 2ecbd67, both fixed in 8a501a5. These overlap between the Opus and GPT verdicts.
prove.py PROVEN on 8a501a5; local gate, 1758 security tests, black, isort, flake8, mypy, file line cap and comment-history gates clean. SCR reposted; PR stays flagged Note for the maintainers who hold the security review on this PR: this is the fourth round in which a review lane found a new AST corner ( |
The self-subcommand floors read every heredoc body as commands, so a Python script or cat writing the text of a cloud command into a file was refused as a destructive cloud operation. They now read a view where a body bash expands nothing in, fed to a bare cat, tee or python - whose every statement is provably inert, is blank when that command is the only one in the text and no heredoc tag carries quote, backslash or $ machinery bash resolves before matching. A python body is inert only when ast.parse shows every statement is an import that rebinds no accepted name, an assignment to a bare non-accepted name whose value and annotation run nothing, or a print / Path / open write whose arguments (f-string specs included) are inert; any other call, target or construct keeps the old read. Bodies a shell or interpreter runs, unquoted bodies with expansions, a normalised-only cat word, a decoded closing tag, and lines with a pipe, group, substitution or lone & read as before. The argv_floor mirror facade's TYPE_CHECKING manifest lists the new owner-defined names. Fixes #39663
8a501a5 to
bb8a13c
Compare
Sensitive change review
Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge. |
|
Head bb8a13c: CI-only follow-up, no behaviour change. The two Backend Tests shard failures on the prior head (8a501a5) were |
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 changes 473 lines, more than the 400 it may approve on its own. The PR narrows the five self-subcommand floors so they skip heredoc bodies that nothing can run. A body is blanked only when: (1) the command word is a bare 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 review checked head bb8a13c. The new heredoc data view is called from only one place, _matches_self_subcommand, so only the five self-subcommand floors change. Every doubtful shape falls back to the old read: a pipe, group, substitution, lone &, a second command, a decorated tag, an expansion in an unquoted body, a parse or recursion error, or a tree over the node cap. The +306 line-budget row equals the net src change. The facade manifest lists every new name. The tests are pure is_denied checks, and 4 of the 5 allow cases go red on the merge base. Done well: the gate is tested both ways through the public gate, with more than 20 execution shapes still refused, including | sh, alias cat=sh, $'E\x4fF' tags and from os import system as print.
Security: this relaxes what a denied-command floor reads, but only for heredoc bodies that a bare cat, tee or python [-] reads as data, and the Python bodies must pass an AST allowlist. One input that the floor refuses on main is allowed at this head: a body that writes a module containing a backticked product command and then imports it. That does not open a new path. The same body without backticks, for example os.system('kirocrew cloud launch'), already passes on main, so these text-level floors never stopped a Python body that was set on shelling out. The sandbox, not this floor, is the runtime control.
Optional:
- #39056 binds
_HEREDOC_DATA_PROGRAMSto a different value in anotherargv_floorowner. If both merge,import kiro_crew.securityraises in_facade_mirror.install, whichever lands second. Rename one constant, or share one owner, and name the merge order in the body. docs/system-specs/modules/security.md(the "Self-protection global options" paragraph) still describes the old read. A short paragraph naming_heredoc_data_viewand the cases where a body is blanked would let a later reader see this relaxation is deliberate.- Tighten what an
importmay be (for examplepathlibonly), and pin the guards no test covers yet:python3 tool.py <<'EOF'with an inert body, andcat <<'EOF' >&3. Deleting thepython [-]argument check or the lone-&check today leaves all 58 tests green.
Problem / Motivation
Goal: A shell command that only writes or prints text mentioning a cloud command, through a heredoc, is no longer refused as a destructive cloud operation.
The
self-protection-cloudfloor (componentargv-floor) refusedpython3 - <<'EOF'scripts andcat > note.md <<'EOF'writes whose heredoc body merely contained the textkirocrew cloud launch. Nothing in those commands runs the product CLI.Why it matters
Any docs or spec edit that mentions a cloud command, made through a script, is blocked and the agent stalls waiting for a person. The refusal claims an action the command does not take.
Not a goal
subprocess/os.systemcalls. A Python body that shells out without backticks passes on main today and still does._matches_self_subcommandread the new view.cat > x.sh <<'EOF' ... EOF; bash x.sh). That is the same as writing the file with a file tool and running it.What changed (motivation → approach → change)
_matches_self_subcommandtokenizes the whole text, heredoc bodies included, so each body line read as a command, and a backtick span inside a quoted-tag body was descended as a substitution even though bash expands nothing there.src/kiro_crew/security/argv_floor_self.py): the floor now reads_heredoc_data_view(text), which blanks a heredoc body only when all of these hold:$, backtick or backslash in the body);cat,tee, orpython/python -(the raw word, so$cator/tmp/x/catnever count), andast.parseshows every statement of a Python body is provably inert -- an import, an assignment whose value runs nothing, or aprint/Path(...)/open(...)write on inert arguments; any other call (os.system,pickle.loads,getattr,exec) keeps the old read;alias,hash -p,PATH=or variable can rebind the name first;$, backslash or quote machinery bash resolves before matching the closing line (<<$'E\x4fF'), which can close a body earlier than the literal reader sees;&(each can carry the body to a shell:cat <<'EOF' | sh,bash -c "$(cat <<'EOF' ...)",cat > >(bash),>&3).Every other body keeps its old read:
bash/shbodies,perlbodies,python3 tool.py <<'EOF', unquoted bodies with expansions. The view is taken on the text as typed, before line continuations are joined, so a trailing backslash in a quoted body cannot swallow the tag line.test/security_line_budget/heredoc-data-body.txt: +306 package lines, with the reason.This changes what a security floor allows, so it is flagged for human review.
Backwards compatibility
Compatible: the floor only allows more commands; every command it refused that runs a heredoc body as commands is still refused.
Removes nothing: no rule, pattern, key or function is removed; the floor's view is narrowed only for bodies nothing runs.
Tests
test/test_denied_commands_security_heredoc_data.py(through the publicis_deniedgate):test_data_heredoc_body_is_allowed: the issue's repro, a Pythonprint,cat/teewrites, and an unquoted body with no expansion are allowed.test_executed_heredoc_body_is_still_refused: still refused withself-protection-cloud:bash <<'EOF',sh -s <<'EOF',perlwith a backtick,python3 -withos.system/subprocessrunning a backtick,python3 tool.py <<'EOF',cat <<'EOF' | sh,bash -c "$(cat <<'EOF' ...)",cat > >(bash),{ cat ...; } | bash,cat=bash; $cat,/tmp/x/cat,hash -p /bin/sh cat; cat,alias cat=shwithexpand_aliases, a$'E\x4fF'/"E"OF/E\OFdecoded tag, apickle.loads/getattr/os.systempython body, a body followed bygit add && git status,$(...)in an unquotedcatbody, a backtick in an unquotedpython3 -body, a command after the body, and a quoted body whose last line ends in a backslash.Proof: PROVEN test/test_denied_commands_security_heredoc_data.py::test_data_heredoc_body_is_allowed (head bb8a13c)
Local:
scripts/local-gate.pypassed; the security test filestest_denied_commands_security.py,_cost,_quoting,_mentions,_nesting,_stdin,_mint,_kill,_rows,test_argv_floor_facade.py,test_deny_session_override.py,test_security_gate_liveness.pypass (1758 passed); black, isort, flake8, mypy, file line cap and comment-history gates are clean.Manual verification
N/A — the change is a pure function of the command text, covered through
is_deniedin both directions.Real-machine verification
N/A -- the floor is a pure text check; no host behaviour changes. Run on an aarch64 Linux dev box: before (main c251020) 4 of the 5 allow cases are refused by
self-protection-cloud, after (head bb8a13c) they pass and all 14 refuse cases stay refused.Related Issues
Fixes #39663
Sibling sweep
Swept: git grep -n "_self_token_frames|_shell_payload_walk" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/rm_floor.py -- not affected -- it already cuts heredoc bodies and reads only those a shell runs (
_without_bodies,_heredoc_payloads)Sibling: src/kiro_crew/security/argv_floor_self.py -- not affected -- its credential-mint floor reads Python bodies for product imports on purpose and keeps that read
Sibling: src/kiro_crew/security/argv_floor_ssh.py -- not affected -- the ssh floor reads heredoc spans itself (
heredoc_text_spans)Pattern harvest
Rule candidate: review-prompt
Pattern: three helpers in security/ now classify "which heredoc bodies does a shell run" (this view, rm_floor._without_bodies/_heredoc_payloads, shell_commands._without_quoted_heredoc_text). They are not interchangeable today -- reusing rm_floor's here regressed 18 refuse cases, because its guards differ -- so unifying them safely is a follow-up refactor, not part of this fix.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributed under the project's Apache-2.0 license.