Skip to content

fix: read a heredoc body nothing runs as data in the self floors - #39757

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/39663-heredoc-data-body
Nov 20, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/39663-heredoc-data-body

Conversation

@JLargent42

@JLargent42 JLargent42 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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-cloud floor (component argv-floor) refused python3 - <<'EOF' scripts and cat > note.md <<'EOF' writes whose heredoc body merely contained the text kirocrew 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

  • Teaching the floor to read Python subprocess / os.system calls. A Python body that shells out without backticks passes on main today and still does.
  • Changing the credential-mint, self-kill or ssh floors. Only the five self-subcommand floors that share _matches_self_subcommand read the new view.
  • Catching a file written by a heredoc and run by a later command (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)

  • Symptom: a heredoc body that is only data was refused.
  • Root cause: _matches_self_subcommand tokenizes 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.
  • Change (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:
    • bash expands nothing in it (quoted tag, or no $, backtick or backslash in the body);
    • its command is spelled as the bare word cat, tee, or python/python - (the raw word, so $cat or /tmp/x/cat never count), and ast.parse shows every statement of a Python body is provably inert -- an import, an assignment whose value runs nothing, or a print / Path(...) / open(...) write on inert arguments; any other call (os.system, pickle.loads, getattr, exec) keeps the old read;
    • it is the only command in the text, so no alias, hash -p, PATH= or variable can rebind the name first;
    • no heredoc tag carries $, backslash or quote machinery bash resolves before matching the closing line (<<$'E\x4fF'), which can close a body earlier than the literal reader sees;
    • the command is not piped, and the text outside every body has no pipe, group, substitution or lone & (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/sh bodies, perl bodies, 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 public is_denied gate):

  • test_data_heredoc_body_is_allowed: the issue's repro, a Python print, cat/tee writes, and an unquoted body with no expansion are allowed.
  • test_executed_heredoc_body_is_still_refused: still refused with self-protection-cloud: bash <<'EOF', sh -s <<'EOF', perl with a backtick, python3 - with os.system / subprocess running 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=sh with expand_aliases, a $'E\x4fF'/"E"OF/E\OF decoded tag, a pickle.loads/getattr/os.system python body, a body followed by git add && git status, $(...) in an unquoted cat body, a backtick in an unquoted python3 - 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.py passed; the security test files test_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.py pass (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_denied in 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

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners November 20, 2026 04:03
@JLargent42 JLargent42 self-assigned this Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/argv_floor.py

  • src/kiro_crew/security/argv_floor_self.py

  • @JLargent42 posted a complete reasoning template for bb8a13c.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 363c60b
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is cat, tee or a bare python [-] whose body names no spawn word (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 6 data cases allowed (5 refused on main c251020, so prove.py reports PROVEN) and 14 executed or expanded cases still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1733 passed.
  • How to undo: Revert commit 363c60b, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision bb8a13c2180927df9a27a8d07e29f56d4aa6877e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@JLargent42 JLargent42 added the needs-human-security-review Security scan flagged — needs manual review label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of bb8a13c2180927df9a27a8d07e29f56d4aa6877e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • This PR makes security/ the home of a third "which heredoc bodies does a shell run" classifier, next to rm_floor._without_bodies/_heredoc_payloads and shell_commands._without_quoted_heredoc_text. The guards already differ between them, so the floors will keep drifting apart. The pattern-harvest follow-up that merges them into one owner should get an issue number now.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of bb8a13c2180927df9a27a8d07e29f56d4aa6877e — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 1 — duplicate of src/kiro_crew/security/shell_commands.py:532 (_without_quoted_heredoc_text): it already blanks "the text of each quoted-tag heredoc that a bare cat prints". It has 2 consumers (shell_commands.py:529, argv_floor_ssh_bodies.py:141). rm_floor._without_bodies / _heredoc_payloads is a second sibling. The description admits "three helpers in security/ now classify 'which heredoc bodies does a shell run'". Subtraction: let the new view absorb the bare-cat case and delete _without_quoted_heredoc_text once that is safe. Deferring that is acceptable, since the author reports that reusing rm_floor's helper "regressed 18 refuse cases".

What this change ships

Inventory (5 items) — 4 justified

Intent: 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.

  1. A quoted or non-expanding heredoc body given to a bare cat/tee no longer trips the five self-subcommand floors — duplicate of shell_commands._without_quoted_heredoc_text, partial
  2. A python [-] heredoc body whose statements are all proven inert by an AST check is read as data — justified
  3. The data view is skipped for pipes, groups, substitutions, a lone &, more than one command, or decorated tags — justified
  4. The argv_floor facade's TYPE_CHECKING manifest lists the new private names — justified
  5. A security line-budget entry (+306) with its reason — justified

[FIRST-PRINCIPLES-REVIEWED] bb8a13c

Description read

[DESCRIPTION-READ] 31d5d1075efbcfd373f888867f8a8989261bdb2555f562d4a8043be4ab33ec72

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed bb8a13c2180927df9a27a8d07e29f56d4aa6877e — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] bb8a13c

Verdict parsed from the review's SHA-scoped output markers for commit bb8a13c2180927df9a27a8d07e29f56d4aa6877e.

False positive or not applicable? A repository writer can comment:
/ai-review override fable bb8a13c2180927df9a27a8d07e29f56d4aa6877e false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of bb8a13c2180927df9a27a8d07e29f56d4aa6877e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bb8a13c

False positive or not applicable? A repository writer can comment:
/ai-review override gpt bb8a13c2180927df9a27a8d07e29f56d4aa6877e false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does bb8a13c2180927df9a27a8d07e29f56d4aa6877e newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 16 classified, 0 newly refused, 16 still allowed.
  • ubuntu-latest (platform posix): 16 classified, 0 newly refused, 16 still allowed.
  • windows-latest (platform windows): 2 classified, 0 newly refused, 2 still allowed.

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 read_commands/ast pass raised an error or changed the token frames for text containing <<. My 18 candidates test that, and the harness gave me no confirmed regressions.

TIGHTENING: Nothing gets stricter. The self-subcommand floor's input view changes. _matches_self_subcommand now reads view = _shell_join_continuations(_heredoc_data_view(text_lower)). That view blanks a body fed to bare cat/tee/python [-] only when the body is inert. When the shape is unsafe it falls back to the old read: a pipe, group, substitution or lone &; more than one command; a decorated tag; an unquoted body with $, backtick or backslash; or a python body that is not proven inert ("Every other body is kept, so bash <<'EOF', perl <<'EOF' and python3 script.py <<'EOF' are read as before"). The threat it keeps refusing is a heredoc body that a shell or interpreter actually runs, for example cat <<'EOF' | sh.

ADJUDICATED: 18 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE:

  • posix: Rows cover the shapes that reach the new code path. Data bodies under cat, tee and python3 -, with quoted, unquoted, <<- and double-quoted tags. Bodies that fall back to the old read: a pipe, two commands, a non-inert python body, git commit -F - and gh pr create --body-file -. Text that contains << without being a heredoc: the <<< here-string and the $((1 << 4)) arithmetic shift.
  • windows: The diff assumes the interpreter name through _PYTHON_PROGRAM_RE (python.exe, py). It also matches the raw argv[0] against the bare names cat/tee. I wrote python.exe - and py - rows in Git Bash spelling. The diff assumes no cmd.exe or PowerShell spelling, because heredocs are posix-shell syntax. So I wrote no %VAR% or .cmd row.
  • any: Unused. Every row names an executable.

[SCOPE-REVIEWED] bb8a13c

@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from 363c60b to 44f083b Compare November 20, 2026 04:17
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 44f083b
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, a Python body names no spawn word (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and 19 executed, expanded or rebound cases still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1737 passed.
  • How to undo: Revert commit 44f083b, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Review dispositions for 363c60b, fixed in 44f083b:

  • Opus BLOCK (program word normalised by _program_basename): fixed. The data check now reads the raw argv word: only the bare words cat, tee or python… count, so $cat and /tmp/x/cat keep the old read. A body is also blanked only when its command is the only one in the text, so alias cat=sh, hash -p /bin/sh cat or PATH=... in the same call cannot rebind the name first. Tests added for cat=bash; $cat, /tmp/x/cat, hash -p, alias with expand_aliases, and cat ... && git status. Residual: a cat already shadowed on the agent's PATH by an earlier call; the floor reads one command line and cannot see that.
  • First Principles item 1 (third data-body helper): kept separate for now. _without_quoted_heredoc_text serves the double-quoted substitution walk for every floor, and folding it into this view widens what all floors allow; that is a separate change for a maintainer to scope.
  • First Principles item 3 / Design note (_PYTHON_SPAWN_WORDS is a name list): kept. Dropping the python - branch leaves the issue's own repro refused. The still-refused tests for os.system and subprocess.run pin the list's purpose; a Python body that shells out without backticks passes on main too, as the PR body says.
  • GPT 6.1 refused to review the diff: needs a repository writer to adjudicate; I have not posted an override.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 20, 2026
@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from 44f083b to e6b1005 Compare November 20, 2026 04:35
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e6b1005
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, every statement of a Python body only stores or prints (an allowlist, not a denylist) (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and 24 executed, expanded, rebound, decoded-tag or unproven-call cases still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, a $'E\x4fF' decoded tag, a pickle.loads/getattr python body, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1744 passed.
  • How to undo: Revert commit e6b1005, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

GPT 6.1 dispositions for 44f083b, both fixed in e6b1005:

  • F1 (src/kiro_crew/security/argv_floor_self.py:1213, misread $'E\x4fF' tag): fixed. The data view now bails to the full read whenever any heredoc tag carries $, a backslash, or quote machinery that bash resolves before matching the closing line (_any_decorated_heredoc_tag). So cat <<$'E\x4fF' ... EOF; kirocrew restart, <<"E"OF and <<E\OF keep the old read and the trailing command is still seen. Only a plain <<EOF or <<'EOF' the reader and bash read identically is eligible for blanking. Tests added for all three decoded-tag spellings.
  • F2 (:1164, pickle/opaque call exempted by a name denylist): fixed. _python_body_is_data is now an allowlist: a body is inert only when every logical line is a recognized data statement (an assignment, an import, or a print / open(...) / Path(...) write). Any other statement — pickle.loads, getattr, exec, a bare call — keeps the floor's old read. Tests added for pickle.loads(... os.system ... \kirocrew cloud launch`), a getattr(builtins, 'ev'+'al')body, and anos.system` body.

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 needs-human-security-review.

@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from e6b1005 to 57dbd84 Compare November 20, 2026 04:52
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 57dbd84
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, ast.parse shows every statement of a Python body is provably inert (import, inert-value assignment, or a print/Path/open write on inert args) (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and executed, expanded, rebound, decoded-tag and unproven-call cases, plus a direct unit test of the ast allowlist still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, a $'E\x4fF' decoded tag, a pickle.loads/getattr python body, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1762 passed.
  • How to undo: Revert commit 57dbd84, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Both reviewers' blocking finding on e6b1005 (the regex Python "inert body" allowlist accepts x = os.system(...), nested calls inside print(...), and miscounts brackets inside string literals) is real. Fixed in 57dbd84.

_python_body_is_data no longer uses regex or bracket counting. It parses the body with ast.parse and accepts a body only when every top-level statement is one of:

  • Import / ImportFrom / Pass;
  • an assignment (Assign / AnnAssign / AugAssign) whose value is proven inert by _ast_expr_is_inert — a literal, a name, an attribute read, a Path(...) / open(...) constructor, or a print / write call, all the way down. A method call that is not a write (os.system(...), x.decode()) or any bare-name call is not inert, so it cannot ride on the right-hand side;
  • an Expr that is a bare literal, or a call to exactly print / open / <inert>.write* whose every argument is itself inert (so print(__import__('os').system(...)) and write_text(f"{os.popen(x).read()}") are rejected).

Any other statement — a bare call, a def/class/for/with/try, an opaque Call, or a SyntaxError — returns False and keeps the floor's old read. A print('(') line can no longer fold later lines into itself, because there is no line/bracket heuristic any more.

Tests: test_python_body_is_data_rejects_executable locks in all the bypass strings both reviewers named (result = os.system(...), print(__import__('os').system(...)), print('(') then os.system, write_text(f"{os.popen...}"), pickle.loads, getattr, exec, eval, a def, a for, and a parse error), and test_python_body_is_data_accepts_inert pins print, imports, assignments, and Path(...).write_text / open(...).write on constants.

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 needs-human-security-review.

@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from 57dbd84 to 2ecbd67 Compare November 20, 2026 05:11
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 2ecbd67
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, ast.parse shows every statement of a Python body is provably inert (import, inert-value assignment, or a print/Path/open write on inert args) (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and executed, expanded, rebound, decoded-tag and unproven-call cases, plus a direct unit test of the ast allowlist still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, a $'E\x4fF' decoded tag, a pickle.loads/getattr python body, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1766 passed.
  • How to undo: Revert commit 2ecbd67, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Dispositions for 57dbd84, fixed in 2ecbd67.

GPT 6.1 (three blocking):

  • F1 — from os import system as print rebinds an accepted call name: fixed. Before classifying statements, the body is rejected if any import aliases onto, or any assignment binds, one of print / open / path / pathlib (_import_rebinds_accepted_name, _assign_binds_accepted_name). from pathlib import Path is the one plain import allowed, because it binds the real inert type the allowlist assumes. Tests: from os import system as print, import os as open, print = __import__('os').system.
  • F2 — deep expression raises RecursionError: fixed. ast.parse and the whole classification run under one try that also catches RecursionError and returns "not data", and the tree is capped at 2000 nodes (_PYTHON_BODY_NODE_CAP) before the recursive walk, so an oversized or deep body keeps the old read instead of crashing the gate. Test: a 1,100-term x = 1 + 1 + ....
  • F3 — nested calls make classification exponential: fixed. _ast_expr_is_inert no longer re-walks a print/write call's arguments after _ast_call_is_inert already validated them; it returns that result directly. Only the Path(...)/open(...) constructor branch walks its own args, once. The 28-nested-print case now visits each level a constant number of times.

First Principles BLOCK (reuse the rm floor's heredoc classifier instead of a third):

  • Addressed with evidence, not absorbed. I prototyped reading the self floors through rm_floor._without_bodies + _heredoc_payloads. It regressed 18 of this PR's refuse cases, because that helper is tuned for rm-target detection and does not carry the guards this view needs: it re-allowed cat=bash; $cat <<'EOF' ... kirocrew cloud launch (the shell-rebind bypass Opus flagged on an earlier head), bash -c "$(cat <<'EOF' ...)", cat > >(bash), { cat ...; } | bash, and the $'E\x4fF' decoded-tag case. So the two classifiers are not interchangeable: folding them would re-open closed bypasses. The shared data-versus-shell split is the same idea; the guards (pipe/group/substitution, single-command, decorated-tag, raw program word) are specific to a floor that must refuse an evasion, not find an rm target. Unifying them safely is a larger refactor than this fix and I have flagged it rather than widen the blast radius here.

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 needs-human-security-review.

@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from 2ecbd67 to 8a501a5 Compare November 20, 2026 05:25
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8a501a5
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, ast.parse shows every statement of a Python body is provably inert (import, inert-value assignment, or a print/Path/open write on inert args) (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and executed, expanded, rebound, decoded-tag and unproven-call cases, plus a direct unit test of the ast allowlist still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, a $'E\x4fF' decoded tag, a pickle.loads/getattr python body, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1758 passed.
  • How to undo: Revert commit 8a501a5, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Dispositions for 2ecbd67, both fixed in 8a501a5. These overlap between the Opus and GPT verdicts.

  • Assignment target can rebind an accepted name or mutate an untracked object (print, _ = os.system, 0; builtins.print = os.system; d['f'] = os.system): fixed. _assign_target_rebinds now rejects a statement unless every target is a bare local ast.Name that is not an accepted name. A tuple/list/starred target is walked recursively; an Attribute or Subscript target is never provably safe, so the body keeps the old read. Tests added for all three shapes.
  • f-string format spec hides a call (print(f"{1:{os.system('x')}}")): fixed. The JoinedStr branch of _ast_arg_is_constant now requires each FormattedValue's format_spec to be None or itself constant, not just its value. Test added.
  • AnnAssign annotation runs at import (x: os.system('y') = 1): fixed. An assignment's annotation, when present, must pass _ast_expr_is_inert before the body is treated as data. Test added.

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 needs-human-security-review.

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 (as-rebind, RecursionError, exponential re-walk, now tuple/attribute targets, f-string specs, annotations) through which a python3 - heredoc body could shell out. Each has been a small, real fix. The underlying reason is that statically proving an arbitrary Python program is inert is an open-ended surface, and a shell-syntax floor cannot see what an interpreter builds at run time. Two scope options worth a maintainer's call, if the hardening loop continues: (a) keep the current AST allowlist, which is now strict (bare-name targets, constant args incl. f-string specs and annotations, no rebinds); or (b) narrow the python branch to blank a body only for a single-statement shape (one print(<constant>) or one Path(<constant>).write_text(<constant>)), which covers the issue's repro and removes almost all of the attack surface. I have kept (a) for now because it is the least-scope change that satisfies the issue; I am not able to escalate (b) from this host, so I have recorded it for the conductor.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 20, 2026
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
@JLargent42
JLargent42 force-pushed the fix/39663-heredoc-data-body branch from 8a501a5 to bb8a13c Compare November 20, 2026 06:11
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: bb8a13c
  • What rule changed: The five self-subcommand argv floors (restart, update, gateway restart, cloud, skills authority-retire) now read a view of the command where a heredoc body that nothing runs is blanked (_heredoc_data_view in src/kiro_crew/security/argv_floor_self.py). No catalog row, pattern or other floor changed.
  • Before -> after (what was allowed/blocked, now): Before, any heredoc body naming kirocrew cloud launch was refused, even cat > note.md <<'EOF' or a python3 - script writing the text to a file. Now a body is data only if bash expands nothing in it, its command is the raw bare word cat, tee or python [-] (not $cat or a path) and is the only command in the text, ast.parse shows every statement of a Python body is provably inert (import, inert-value assignment, or a print/Path/open write on inert args) (os, subprocess, pty, exec, eval, ...), the command is not piped, and the text outside the bodies has no pipe, group, substitution or lone &. Bodies fed to bash/sh/perl/python3 script.py, unquoted bodies with $(...) or backticks, and piped or substituted forms are refused as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A body that does reach a shell is read as data, so a destructive self command (for example kirocrew cloud destroy) runs without the floor refusing it. Known residuals, all also open on main: a Python body that shells out by a spelling not on the spawn-word list, and a file written by a heredoc then run by a later command (same as writing it with the file tool).
  • Evidence checked (which sandbox result proves it): No sandbox involved; the floor is a pure text check. test/test_denied_commands_security_heredoc_data.py drives the public is_denied gate: 5 data cases allowed (4 refused on main c251020, so prove.py reports PROVEN) and executed, expanded, rebound, decoded-tag and unproven-call cases, plus a direct unit test of the ast allowlist still refused with self-protection-cloud, including bash, sh -s, perl backticks, python os.system and subprocess, | sh, bash -c "$(cat <<'EOF' ...)", cat > >(bash), a brace group piped to bash, cat=bash; $cat, /tmp/x/cat, hash -p /bin/sh cat, alias cat=sh with expand_aliases, a $'E\x4fF' decoded tag, a pickle.loads/getattr python body, and a quoted body ending in a backslash.
  • No regression:
    • Tools still work (which tools/commands were run, result): scripts/local-gate.py passed on this head; black, isort, flake8, mypy, the file line cap and the comment-history gate are clean on the touched files.
    • Backward compatible (old config / old data / old callers still work, how checked): The change only allows more commands and touches no config, data format or caller signature; every existing deny test in the denied-commands suites still passes unchanged.
    • Existing tests (which suites passed on this head): test_denied_commands_security.py plus its _cost, _quoting, _mentions, _nesting, _stdin, _mint, _kill and _rows modules, test_argv_floor_facade.py, test_deny_session_override.py and test_security_gate_liveness.py: 1758 passed.
  • How to undo: Revert commit bb8a13c, or make _matches_self_subcommand read _shell_join_continuations(text_lower) again instead of the data view.

Flagged for human review: this relaxes a security floor, so a maintainer should check the conditions above before merge.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Head bb8a13c: CI-only follow-up, no behaviour change. The two Backend Tests shard failures on the prior head (8a501a5) were test_facade_mirror_guards.py::test_every_mirrored_facade_manifest_names_what_it_forwards -- argv_floor.py is a mirror facade, and its TYPE_CHECKING manifest must list every owner-defined name argv_floor_self forwards. The new helpers (_heredoc_data_view, the ast* / _python_body_is_data classifier and its constants) were missing from it; added in sorted order. All AI lanes were already green on 8a501a5; this push only turns the facade-manifest guard green. SCR reposted for the new head.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 20, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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 cat, tee or python [-] exactly as typed, and assignment prefixes stay in argv so PATH=x cat doesn't count; (2) it is the only command in the text; (3) the text outside the bodies has no pipe, group, substitution or lone &; (4) no heredoc tag uses $, backslash or mixed quoting; (5) an unquoted body has nothing for bash to expand; and (6) a Python body passes a strict AST allowlist. Fail-closed cases are pinned through is_denied and allow cases are tested. The line-budget row equals the net lines added under security/ (+306). CI is green. The one gap found (star imports) has no concrete path to running the body and doesn't regress main, because main already lets Python bodies call os.system.

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 bb8a13c218 · 473 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 20, 2026 08:32

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PROGRAMS to a different value in another argv_floor owner. If both merge, import kiro_crew.security raises 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_view and the cases where a body is blanked would let a later reader see this relaxation is deliberate.
  • Tighten what an import may be (for example pathlib only), and pin the guards no test covers yet: python3 tool.py <<'EOF' with an inert body, and cat <<'EOF' >&3. Deleting the python [-] argument check or the lone-& check today leaves all 58 tests green.

@KiroCrewCaptain
KiroCrewCaptain merged commit c4877dc into main Nov 20, 2026
166 of 176 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/39663-heredoc-data-body branch November 20, 2026 08:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human-security-review Security scan flagged — needs manual review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

self-protection-cloud refuses a heredoc whose body only mentions a cloud command

2 participants