Repository navigation
fix(security): stop the ssh-self and -d @ gates refusing inert lines - #34755
Marsjohn-11 wants to merge 2 commits into
Conversation
|
Hi @Marsjohn-11, a heads-up on overlap. We replayed 132 recorded refusals from 2026-10-28 to 2026-11-12. Six were the We have a structural version of the date fix ready, not opened as a PR. It reads the shared reader's commands (
The existing This PR is yours. Are you still working on it? It currently conflicts with main. You are welcome to take any of the above. If it stays quiet past 2026-11-18, we will open the date part on a branch of this repository, crediting this PR. A branch here also lets Sensitive Change Review run, which a fork cannot. |
The ssh-self floor read every here-document body as argv, so a Python edit script fed on stdin (python3 - <<'EOF' ... a * localhost ...) read as a glob verb naming ssh and its target, and was refused. A body is now cut out only when no program on the line can run it: cat, tee, cd, or Python reading its program from stdin or a file, no heredoc command piped, and no unquoted body holding $ or a backtick. Any other line keeps every body as argv. The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep or echo/printf/cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span, never the matched text.
5c0a379 to
cf66a40
Compare
|
Thanks @Marsjohn-11 for this fix. We took the PR over to get it green, since it had conflicts with main and sat idle:
Your credit stays on the commit. We will drive CI and review from here. |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
cf66a40 to
1f67326
Compare
|
span=4fda723f6f7e
|
|
span=e1ef3b066cec
|
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level blocker: both relaxations are closed allowlists that keep the deny on anything they cannot read, and the added diagnostic line leaves line one byte-identical for every reader. Notes
[DESIGN-REVIEWED] 50ad22b Description read[DESCRIPTION-READ] be2f32df3c64de9f4d4802de167232c72ee94805539604ee12dad2f551540c51 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Both false refusals come from issue #34754 and have tests. The heredoc cut is applied to one of the four consumers of the shared frame walk. The other three are excluded by the Not-a-goal, so that is a note. Notes
What this change shipsInventory (5 items) — 3 justifiedIntent: stop an agent's heredoc edit scripts and chained
[FIRST-PRINCIPLES-REVIEWED] d695c15 Description read[DESCRIPTION-READ] f5eec05d7581b91146def512eea1e77fb6ab62157a9640510a29c4525deda49b That sha256 names the PR description this verdict read. Recompute it with |
Security Scope Review (fork) — ✅ PASSWhich legitimate operations does adjudicated, zero confirmed regressions Scope-Verdict: PASS Reason: This change mostly loosens the deny composite. It adds two carve-outs ( TIGHTENING: None in the refusal set. The only change on a refusal path is the exfil gate's refusal text, which now carries a rule id and span line ( ADJUDICATED: 15 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix (11 rows): heredoc shapes with UNADJUDICATED: The refusal-text change ( [SCOPE-REVIEWED] c026d65Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
1f67326 to
4928263
Compare
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
#36992) The -d @ date carve-out only held for a single plain command, so date -d @n && echo, date -d @n | cat, echo "$(date -d @n)", a TZ= prefix and date --help | grep -- '-d @' were refused as curl uploads. A whole line is now carved out when every command in it starts with date/grep, echo or cat, with no redirection, no live $ or backtick left in a word, and only list or pipe separators. printf is never inert: printf -v 'BASH_CMDS[date]' rebinds the date verb. Each exfil-gate refusal now ends with the refusal diagnostic line: the catalog rule id and the matched span in the command as submitted, never the matched text. The ssh-self heredoc reader from #34755 is left out: review found it misreads arithmetic, substitutions and copied shells, so the ssh-self floor keeps its current reading until a real shell AST. Supersedes #34755. Co-authored-by: John Marshall <74795701+Marsjohn-11@users.noreply.github.com>
|
Thanks @Marsjohn-11 for this fix and the careful review rounds. Here is where each part stands on
To get the last part in, we ported your ssh-self rules into a new PR, #39056 (issue #38979). It keeps your fail-closed rules, adds a fallback so no line main allows becomes refused, and credits you as co-author. Since main or #39056 now covers each part, could you close this PR when you have a moment? Thanks again. |
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 new module argv_floor_ssh_heredoc.py cuts the bodies out when no program on the line can run one: every program is a direct cat, tee or cd, or Python reading its program from stdin or a file. Anything else keeps the bodies: a wrapper, an assignment prefix, a pipe, a second heredoc, a non-plain tag, compound syntax, a backslash-newline, or an unquoted body with a live substitution. The floor allows the line when the cut reading reaches no self host; otherwise it reads the whole line as before, so no line main allows becomes refused. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 new module argv_floor_ssh_heredoc.py cuts the bodies out when no program on the line can run one: every program is a direct cat, tee or cd, or Python reading its program from stdin or a file. Anything else keeps the bodies: a wrapper, an assignment prefix, a pipe, a second heredoc, a non-plain tag, compound syntax, a backslash-newline, or an unquoted body with a live substitution. The floor allows the line when the cut reading reaches no self host; otherwise it reads the whole line as before, so no line main allows becomes refused. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 new module argv_floor_ssh_heredoc.py cuts the bodies out when no program on the line can run one: every program is a direct cat, tee or cd, or Python reading its program from stdin or a file. Anything else keeps the bodies: a wrapper, an assignment prefix, a pipe, a second heredoc, a non-plain tag, compound syntax, a backslash-newline, or an unquoted body with a live substitution. The floor allows the line when the cut reading reaches no self host; otherwise it reads the whole line as before, so no line main allows becomes refused. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 same heredoc view the self-subcommand floor already uses, `_heredoc_data_view`. It allows the line when the view blanked a body and the blanked line reaches no self host; otherwise it reads the whole line as before. The view moves to its own module, argv_floor_heredoc_data.py, and widens by three line shapes: one leading `cd <plain path> &&`, Python reading stdin with -u, -b, -e or -s, and a cat or tee that stores a body followed only by `python <file>`, where each stored body must pass the same data-only Python check. It also turns stricter: a tag must be a plain word used exactly twice, and a backslash-newline outside a quoted-tag body keeps every body. The facade and its manifest list the new owner; argv_floor_self re-exports the names. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 same heredoc view the self-subcommand floor already uses, `_heredoc_data_view`. It allows the line when the view blanked a body and the blanked line reaches no self host; otherwise it reads the whole line as before. The view moves to its own module, argv_floor_heredoc_data.py, and widens by three line shapes: one leading `cd <plain path> &&`, Python reading stdin with -u, -b, -e or -s, and a cat or tee that stores a body followed only by `python <file>`, where each stored body must pass the same data-only Python check. It keeps every body when bash and the lowered reader could close a body on different lines: a backslash-newline inside an unquoted-tag body or at the end of a heredoc opener's line, or a tag whose closing lines outnumber its bodies. The facade and its manifest list the new owner; argv_floor_self re-exports the names. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 same heredoc view the self-subcommand floor already uses, `_heredoc_data_view`. It allows the line when the view blanked a body and the blanked line reaches no self host; otherwise it reads the whole line as before. The view moves to its own module, argv_floor_heredoc_data.py, and widens by three line shapes: one leading `cd <plain path> &&`, Python reading stdin with -u, -b, -e or -s, and a cat or tee that stores a body followed only by `python <file>`, where each stored body must pass the same data-only Python check. Like bash, it joins a backslash-newline that ends a line after its `<<` before it finds the bodies. It keeps every body when bash and the lowered reader could close a body on different lines: a backslash-newline inside an unquoted-tag body, or a tag whose closing lines outnumber its bodies. The facade and its manifest list the new owner; argv_floor_self re-exports the names. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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 same heredoc view the self-subcommand floor already uses, `_heredoc_data_view`. It allows the line when the view blanked a body and the blanked line reaches no self host; otherwise it reads the whole line as before. The view moves to its own module, argv_floor_heredoc_data.py, and widens by three line shapes: one leading `cd <plain path> &&`, Python reading stdin with -u, -b, -e or -s, and a cat or tee that stores a body followed only by `python <file>`, where each stored body must pass the same data-only Python check. It reads the text as typed and keeps every body when a backslash-newline sits inside an unquoted-tag body. The ssh floor reads the whole line, as before, when a line holding `<<` ends in a backslash. The facade and its manifest list the new owner; argv_floor_self re-exports the names. Ported from #34755 by Marsjohn-11. Closes #38979 Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
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. It 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>
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>
Problem / Motivation
Goal: An agent's Python edit script fed on a here-document, and a
date -d @<epoch>conversion chained or piped with programs that run nothing, are no longer refused as an ssh-to-self escape or a curl upload, and every exfil-gate refusal names the rule and the span it matched.Reported in #34754. Two gates refuse commands that run no ssh and send nothing:
sandbox-escape-ssh-selfrefusespython3 - <<'EOF'\nn = a * localhost\nEOF: the floor reads the heredoc body as argv, so a bare*(multiplication) followed by a self-host word reads as a glob verb namingsshand its target. The same happens whencatwrites the script to a file the line then runs.data-exfil-curl-file-body(-d @) refusesdate -u -d @N && echo ok,TZ=UTC date -d @N,date -d @N | cat,echo "$(date -u -d @N)"anddate --help | grep -- '-d @'. fix(security): let inert date/grep pass the curl file-body exfil deny #18392 carved out only a lonedatecommand.Why it matters
A refusal stops the agent's turn and sends it down the exfiltration or sandbox-escape recovery path, which is the wrong guidance for a local file edit or a time conversion. A heredoc-fed edit script is a very common agent shape, so the ssh-self false refusal recurs on ordinary work, and the only escape today is turning the whole rule off.
Not a goal
casearms, a glob verb): that is ssh-self floor: execute-position walk over-blocks globs in bash array literals and spaced/alternated case arms #34364 / fix(security): keep self-host detection when the ssh verb is a glob #34056.-d @to curl or modelling bash evaluation: fix(security): let inert date/grep pass the curl file-body exfil deny #18392 chose not to, and this keeps that stance. The line reading allows only a closed set of programs and refuses anything it cannot read.xargs ssh <<EOF\nlocalhost\nEOF, whichmainalready allows: an existing gap this PR neither opens nor closes.python3 -ctoday.What changed (motivation → approach → change)
Symptom → cause → change.
_self_token_framesputs every heredoc body into the frame's flat tokens, and_is_ssh_to_selfwalks them as argv. Change:argv_floor_ssh._heredoc_bodies_as_dataruns first and cuts the bodies out (rm_floor._without_bodies, read throughread_commands(..., heredocs=True)) only when no program on the line can run one. Every program must be a directly namedcat,tee,cd, or Python reading its program from stdin (python3 -) or a file, with no-c/-m; a wrapper (env,flock,sudo), an assignment prefix or an unresolved program keeps the bodies. The text outside the bodies must hold no arithmetic or compound syntax (a paren, brace, backtick,[[or$[, or a command starting withletor a shell keyword), because there<<can be a shift, as in((cat<<z)). A backslash-newline anywhere in the text keeps the bodies too, because it can change a heredoc's delimiter. Every heredoc tag must be a plain word (letters, digits or underscores, bare or wholly in one pair of quotes); a$'...'or partly quoted tag keeps the bodies. The line must hold exactly one heredoc, and its tag must appear nowhere else in the text in any letter case, since the floor reads lowered text and bash matches the delimiter case-sensitively. No heredoc command may be piped, and no unquoted body may hold a$or backtick, which bash expands even forcat. Any other line keeps the current reading, sobash <<EOF,cat <<EOF | bash,source /dev/stdin,perl -e 'system(<STDIN>)',python3 -c '...os.system(sys.stdin.read())', a script file a shell then runs and an unquoted$(ssh localhost)body all stay refused. This is the same "a body is data unless a shell reads it" ruleargv_rules._commandsandrm_flooralready apply, made stricter.-d @. Cause: the carve-out requiresdenied_rules._exception_eligible, which refuses any separator. Change:exfil_bash._inert_line_allowsis tried when that fails. It reads the shared reader's commands (a double-quoted$(…)'s commands included) and allows the line only when every command starts with a carve-out verb orecho/cat, after an optionalTZ/LANG/LC_*prefix (neverPATHorLD_PRELOAD). There must be no redirection, no live$or backtick left in any word (variables, unquoted substitutions,${ …; }funsubs), and only;&&&|||or newline separators.printfis not inert, becauseprintf -vassigns a variable. With no other program on the line, no HTTP client can run._data_at_carveout_allowsis unchanged, so its parity test still holds.exfil_bash._exfil_denialappends the existingdiagnosticsline (componentexfil-gate, rule id, span, shape, never the matched bytes) to every exfil refusal. When lowercasing changes the text's length (İ), the span is the whole command. Line one is unchanged, sodeny_guidanceand every reader of it see what they saw before.security.mdrecords why this one pattern tier passes a diagnostic.Backwards compatibility
Compatible: the only verdicts that change are refused → allowed for the shapes above; every refusal keeps its first line byte-for-byte and gains a last line, which readers that stop at line one never see.
Removes nothing: no deny pattern, rule id, catalog row or operator toggle is removed or renamed, and every previously pinned denial still holds.
Tests
test/test_denied_commands_security_ssh_self.py::test_heredoc_body_read_as_data_is_not_argv: the four false refusals (stdin program,cd && python3 -u -,catto a script thenpython3runs it,teewith a redirect) are allowed....::test_heredoc_body_that_can_run_stays_argv: 13 shapes where a shell,source, an interpreter running stdin, a pipe, a script a shell runs, an unquoted substitution body, or a real ssh outside the body is involved stay refused.test/test_exfil_carveouts.py::TestCompoundInertLine: the sixdatelines are allowed, and 11 lines carrying a program that can send (| python3,&& curl,PATH=,LD_PRELOAD=, substitution in a prefix, quoted curl substitution, a redirect,$X, a funsub, a quoted'date', a heredoc) stay refused....::TestDenialNamesItsRule: the file-body refusal namesrule=data-exfil-curl-file-body component=exfil-gate span=<a>..<b>with no file name or host in the line, and each other branch names its own row.test/test_security_gate_liveness.py: the package line budget is re-pinned to the re-measured total, with its justification entry.Proof: PROVEN test/test_denied_commands_security_ssh_self.py::TestSandboxEscapeSshSelf::test_heredoc_body_read_as_data_is_not_argv[python3 - <<'EOF'\nn = a * localhost\nEOF], test/test_denied_commands_security_ssh_self.py::TestSandboxEscapeSshSelf::test_heredoc_body_read_as_data_is_not_argv[cd /work && python3 -u - <<'PY'\nfor p in paths: p.write_text(t * 127.0.0.1)\nPY], test/test_denied_commands_security_ssh_self.py::TestSandboxEscapeSshSelf::test_heredoc_body_read_as_data_is_not_argv[cat > /tmp/edit.py <<'EOF'\nn = a * localhost\nEOF\npython3 /tmp/edit.py], test/test_denied_commands_security_ssh_self.py::TestSandboxEscapeSshSelf::test_heredoc_body_read_as_data_is_not_argv[tee /tmp/edit.py <<'EOF' >/dev/null\nn = a * localhost\nEOF], test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[date -u -d @1700000000 && echo ok] (head 5c0a379)
Also run on this head: the 37 security test files (
test_denied_commands_security*,test_exfil*,test_deny_*,test_mcp_cron_security*,test_argv*,test_shell_commands_reader,test_security_gate_liveness), 3443 passed, plustest_flake_pattern_ratchet.py.black,isort,flake8andmypyare clean on the changed files, andscripts/docs-lint.shpasses.Manual verification
N/A — unit coverage sufficient: both gates are pure functions of the command text, called directly by the tests above through the public
is_denied/audit_bash_exfiltrationentry points.Related Issues
Closes #34754
Sibling sweep
Swept: git grep -n "_self_token_frames|_shell_payload_walk|heredocs=True" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/argv_floor_ssh.py -- changed here
Sibling: src/kiro_crew/security/argv_floor_self.py -- tracked in #34754 (the self-kill and mint floors read the same frames; left out of scope)
Sibling: src/kiro_crew/security/argv_rules.py -- not affected -- it already reads a body as commands only when a shell is the program
Sibling: src/kiro_crew/security/rm_floor.py -- not affected -- it already reads only shell-run bodies and unquoted body substitutions
Swept: git grep -n "_data_at_carveout_allows|_exception_eligible" -- src/kiro_crew/security/
Sibling: src/kiro_crew/security/exfil_bash.py -- changed here
Sibling: src/kiro_crew/security/denied_rules.py -- not affected -- its exception gate is left as it is, so the rm deny-exception does not widen
Pattern harvest
Rule candidate: review-prompt
Pattern: a shell-grammar floor that walks a here-document body as argv without asking which program on the line consumes it
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Sensitive change review
This is a fork PR on a sensitive path, which the gate refuses whatever the record says, so this filled template is here for whoever takes it over.
-d @date carve-out also holds for a line of inert commands. Exfil refusals gain a diagnostic line.python3 - <<'EOF'edit scripts anddate -d @Nin a chain, pipe, quoted substitution or locale prefix were refused. Now they are allowed, and every shape where a shell or interpreter can run the body, or another program can send, is still refused.is_deniedandaudit_bash_exfiltrationwere run on the reported commands and on every pinned denial in the security suites, with the expected results.test_deny_guidance.pypassed.Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.