Skip to content

fix(security): stop the file-body exfil gate refusing inert date lines - #36992

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
takeover/34755-inert-lines
Nov 14, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
takeover/34755-inert-lines

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A date -d @<epoch> conversion chained or piped with programs that run nothing is no longer refused as a curl upload, and every exfil-gate refusal names the rule and the span it matched.

Narrowed by maintainer decision after review: the ssh-self heredoc part of #34755 is out of this PR (see Not a goal).

Reported in #34754. The exfil gate refuses commands that send nothing:

  • data-exfil-curl-file-body (-d @) refuses date -u -d @N && echo ok, TZ=UTC date -d @N, date -d @N | cat, echo "$(date -u -d @N)" and date --help | grep -- '-d @'. fix(security): let inert date/grep pass the curl file-body exfil deny #18392 carved out only a lone date command.
  • The exfil-gate refusal is one line naming a substring, with no rule id and no position, so a false match cannot be reported precisely.

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 time conversion. date -d @<epoch> inside a loop or chain recurs on ordinary work, and the only escape today is turning the whole rule off.

Not a goal

What changed (motivation → approach → change)

Symptom → cause → change.

  • -d @. Cause: the carve-out requires denied_rules._exception_eligible, which refuses any separator. Change: exfil_bash._inert_line_allows is 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 or echo/cat, after an optional TZ/LANG/LC_* prefix (never PATH or LD_PRELOAD). printf is not in that set: printf -v writes a variable, and BASH_CMDS[date] rebinds the verb. A line holding a backslash or a # keeps the deny, because the shared reader can misplace a word end at an escape (echo \ #x; curl ... reads as a comment). A line over 2,000 characters or with more than four $( keeps the deny before the reader runs, so a deeply nested line cannot tie up the shared gate workers. There must be no redirection, no live $ or backtick left in any word (variables, unquoted substitutions, ${ …; } funsubs), and only ; & && || | or newline separators. With no other program on the line, no HTTP client can run. _data_at_carveout_allows is unchanged, so its parity test still holds.
  • Diagnostics. exfil_bash.audit_bash_exfiltration appends the existing diagnostics line (component exfil-gate, rule id, span, shape, never the matched bytes) to every exfil refusal. Line one is unchanged, so deny_guidance and every reader of it see what they saw before. security.md records 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_exfil_carveouts.py::TestCompoundInertLine: the six date lines are allowed, and 19 lines carrying a program that can send (an escaped space or tab before #, also inside a quoted $(…), printf, printf -v 'BASH_CMDS[date]' and printf {-v,} among them, | python3, && curl, PATH=, LD_PRELOAD=, substitution in a prefix, quoted curl substitution, a redirect, $X, a funsub, a quoted 'date', a heredoc) stay refused, and a long or deeply nested line is refused without running the shared reader.
  • ...::TestDenialNamesItsRule: the file-body refusal names rule=data-exfil-curl-file-body component=exfil-gate span=<a>..<b> with no file name or host in the line, the span counts in the command as submitted even when lowercasing changes its length, 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 (36,840 on main, 36,891 here), with its justification entry.

Proof: PROVEN test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[date -u -d @1700000000 && echo ok], test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[TZ=UTC date -d @1700000000 +%F], test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[date -u -d @1700000000 | cat], test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[echo "converted: $(date -u -d @1700000000)"], test/test_exfil_carveouts.py::TestCompoundInertLine::test_inert_compound_line_allowed[date --help | grep -- '-d @'] (head 8c4187f)

Also run on this head, rebased on main: the 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) plus test_flake_pattern_ratchet.py and test_facade_mirror_guards.py, 4017 passed, 1 skipped.

Gate proof: tree 72c387390ad6; ran 24; skipped none

Manual verification

N/A — unit coverage sufficient: the gate is a pure function of the command text, called directly by the tests above through the public is_denied / audit_bash_exfiltration entry points.

Related Issues

Closes #34754

Supersedes #34755 (by @Marsjohn-11, carried onto a branch of this repository because a fork PR cannot pass Sensitive Change Review; the commit keeps @Marsjohn-11 as author with a Co-authored-by: trailer).

Sibling sweep

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 hand-rolled shell reader in a security floor that guesses where a here-document ends; each review round finds another spelling, so it needs a real shell AST

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

Sensitive change review

  • What rule changed: the -d @ date carve-out also holds for a line of inert commands (date/grep, echo, cat; never printf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.
  • Before -> after (what was allowed/blocked, now): before, date -d @N in a chain, pipe, quoted substitution or locale prefix was refused. Now it is allowed, and every line where another program can send (printf -v 'BASH_CMDS[date]' included) is still refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the reader misjudges as inert could run a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 19 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (4017 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/exfil.py

  • src/kiro_crew/security/exfil_bash.py

  • @iamwhatever posted a complete reasoning template for 8c4187f.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from 4508873 to d3427b8 Compare November 14, 2026 01:54
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head d3427b8.

Sensitive change review

  • What rule changed: the ssh-self floor no longer walks a here-document body as argv when no program on the line can run it, and the -d @ date carve-out also holds for a line of inert commands. Exfil refusals gain a diagnostic line.
  • Before -> after (what was allowed/blocked, now): before, python3 - <<'EOF' edit scripts and date -d @N in 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.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the readers misjudge as inert could run ssh to this host or a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 13 runnable-body shapes and 11 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (3818 passed), plus the flake-pattern ratchet, all on this head.
  • How to undo: revert this single commit. No data, config or format migrates.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The new line reader only lets through a closed set of programs that send nothing, refuses anything it cannot read, and the deny itself is unchanged.

Notes

  • Every exfil refusal now has a second line, and three callers embed the whole reason string: mcp_cron_vet.py:447, computer_use/policy.py:268 and gate_tiers.py:643. A newline inside the computer-use REFUSAL_TEXT_SENSITIVE text is harmless, but a test pinning its rendered shape would catch future drift.

[DESIGN-REVIEWED] 8c4187f

Description read

[DESCRIPTION-READ] f4266835e9ecd30dec3ec93f9da227b4900c7bf8a61347454f3ea5a5a07f88b0

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 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8c4187f461edb078261a5faaa7060051d8bf6e6f — 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

Nothing blocks: the carve-out widening goes after the cause #34754 names (_exception_eligible refuses any separator), and the diagnostic line is in the frozen Goal.

What this change ships

Inventory (5 items) — 5 justified

Intent: let an agent convert an epoch with date -d @N inside a chain, pipe, quoted substitution or locale prefix without being refused as a curl upload, and make every exfil refusal name the rule and span that matched. FIX.

  1. A date -d @N line whose other commands are only echo/cat/grep, joined by ; && || | or a newline, or preceded by TZ=/LANG=/LC_*, is no longer refused — justified
  2. Every exfil-gate refusal gains a last line giving the rule id, component=exfil-gate and the span offsets, never the matched text — justified
  3. The security spec now names the exfil gate as the one pattern tier that adds a diagnostic line, and says why — justified
  4. The exfil facade's type-checking list names the new helper (_inert_line_allows), which _EXPORTS requires — justified
  5. The package line budget goes from 36,840 to 36,891, with its justification entry — justified

[FIRST-PRINCIPLES-REVIEWED] 8c4187f

Description read

[DESCRIPTION-READ] 6e11d2817d28e1c023e65c80bed09874c7e328e1e491241666b200784b2050ce

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 8c4187f461edb078261a5faaa7060051d8bf6e6f 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): 14 classified, 0 newly refused, 8 still allowed.
  • ubuntu-latest (platform posix): 14 classified, 0 newly refused, 8 still allowed.
  • windows-latest (platform windows): 4 classified, 0 newly refused, 2 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: This diff does not make any check stricter. _inert_line_allows is only joined with or onto the existing -d @ carve-out, so it can only turn a refusal into an allow. _exfil_denial adds a last line to refusals the gate had already decided, and the first line stays byte-identical. annotate_refusal returns an empty reason unchanged, so the added line cannot turn an allow into a refusal. 18 boundary candidates were submitted. The script reports confirmed rows after this review is captured.

TIGHTENING: none in the verdict path; the change only adds refusal text -- the one change on a refusal is the appended diagnostic line in audit_bash_exfiltration: return _exfil_denial(reason, rule_id, command, m.span() if m else None), which calls annotate_refusal(reason, refusal_diagnostic(rule_id, "exfil-gate", command, span)). The only verdict change goes the other way: carveout_allows = _data_at_carveout_allows(command) or _inert_line_allows(command), which allows more and refuses nothing new.

ADJUDICATED: 18 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix rows cover the single date -d @ carve-out and the shapes the new helper reads: TZ=/LC_ALL= prefix, && chain, | cat pipe, quoted $(…), date --help | grep. They also cover the search-verb neighbours grep/rg, and exfil-tier neighbours whose refusal text changed (curl GET, wget -O-, nc -zv). Windows rows cover a quoted drive-letter date.exe path with \ separators (the helper fails closed on \, so this probes that fence), curl.exe under PowerShell, a Git Bash chained conversion, and a backslash pytest path. The diff assumes no interpreter, environment variable or executable name beyond the bare date/echo/cat words. No platform it assumes was left without a candidate.

[SCOPE-REVIEWED] 8c4187f

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8c4187f

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

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8c4187f

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

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

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The new _inert_line_allows carve-out fails closed. It allows only the exact first words date, grep, egrep, fgrep, echo and cat, after an optional TZ, LANG or LC_* prefix with safe characters. Any backslash or '#', any '$' or backtick left in a word, any redirection, and any separator other than ; & && || | or newline keep the deny. Parens, unquoted backticks and heredocs show up as refused separators. The shared reader lists the commands inside a double-quoted substitution separately, so each is checked too. It is tried only after the existing single-command check fails, so the old carve-out is unchanged. Size and nesting limits are checked before the reader runs. The diagnostic line is added through the existing annotate_refusal, so line one of every refusal is byte-for-byte unchanged and deny_guidance keeps classifying correctly. The hooks gate, cron vetting and computer-use callers already handle multi-line reasons from other tiers. Tests cover the allowed shapes, the send-capable shapes that stay refused, the size limits, the span offsets and the rule id per branch. I found no concrete bypass and no regression.

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

@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from d3427b8 to d50b4fa Compare November 14, 2026 02:32
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head d50b4fa.

Sensitive change review

  • What rule changed: the ssh-self floor no longer walks a here-document body as argv when no program on the line can run it, and the -d @ date carve-out also holds for a line of inert commands. Exfil refusals gain a diagnostic line.
  • Before -> after (what was allowed/blocked, now): before, python3 - <<'EOF' edit scripts and date -d @N in 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.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the readers misjudge as inert could run ssh to this host or a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 13 runnable-body shapes and 11 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (3826 passed), plus the flake-pattern ratchet, all on this head.
  • How to undo: revert this single commit. No data, config or format migrates.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

span=4fda723f6f7e

fixed in d50b4fa: _heredoc_bodies_as_data now keeps every body as argv unless each command's program is in command position. parsed is None (a wrapper naming no program, e.g. env -Sbash) returns the text whole, and so does any wrapper or keyword in front of the program, since its basename then differs from the first non-assignment word. Pinned refused: env -Sbash <<'EOF'\nssh -p 22 localhost id\nEOF in test_heredoc_body_that_can_run_stays_argv.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

span=e1ef3b066cec

fixed in d50b4fa: _inert_line_allows refuses a printf whose first argument is an option (quotes stripped first), so printf -v 'BASH_CMDS[date]' ... keeps the deny. Bash's printf reads options only there. Pinned refused in test_line_with_a_program_that_can_send_denied: printf -v, printf '-v' and printf -- -v spellings.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

span=49f9306ff16b

fixed in d50b4fa: same root cause as the GPT wrapper finding, fixed once. parsed is None now fails closed, and a command is skipped only when it has no words. A wrapper or keyword before the program also keeps the text. Pinned refused: unshare <<'EOF'\nenv ssh localhost id\nEOF, unshare <<'EOF'\ncommand ssh 127.0.0.1 id\nEOF, sudo -s <<'EOF'..., sudo cat <<'EOF'.... The Notes item (span offsets from command.lower() when lowercasing changes length) affects only the diagnostic offsets, never the verdict; left as is.

@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from d50b4fa to 87208e6 Compare November 14, 2026 03:06
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 87208e6.

Sensitive change review

  • What rule changed: the ssh-self floor no longer walks a here-document body as argv when no program on the line can run it, and the -d @ date carve-out also holds for a line of inert commands. Exfil refusals gain a diagnostic line.
  • Before -> after (what was allowed/blocked, now): before, python3 - <<'EOF' edit scripts and date -d @N in 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.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the readers misjudge as inert could run ssh to this host or a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 13 runnable-body shapes and 11 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (3829 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

span=e1ef3b066cec

fixed in 87208e6: printf is out of _INERT_LINE_PROGRAMS entirely, so no spelling of its options (-v, '-v', {-v,}, --) can reach the carve-out, and a plain printf beside date keeps the deny. The diagnostic span for the file-body row is now taken from a case-insensitive search of the command as submitted, not of command.lower(), so a character that lowercases to two (İ) no longer shifts it. Both review points on this head share this span id (same path and lane); each has its own pinned test: printf {-v,} 'BASH_CMDS[date]' ... and printf '%s\n' ok; date ... in test_line_with_a_program_that_can_send_denied, and test_span_counts_in_the_command_as_submitted.

@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from 87208e6 to 7ca9aae Compare November 14, 2026 03:34
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 7ca9aae.

Sensitive change review

  • What rule changed: the ssh-self floor no longer walks a here-document body as argv when no program on the line can run it, and the -d @ date carve-out also holds for a line of inert commands. Exfil refusals gain a diagnostic line.
  • Before -> after (what was allowed/blocked, now): before, python3 - <<'EOF' edit scripts and date -d @N in 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.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the readers misjudge as inert could run ssh to this host or a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 13 runnable-body shapes and 11 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (3829 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

span=f28364d8feb2

fixed in 7ca9aae: the exfil_bash.py entry in security.md now reads "a carve-out verb or echo/cat" and states that printf is excluded on purpose, because printf -v 'BASH_CMDS[date]' … rebinds the date verb in any spelling of the option. Spec and _INERT_LINE_PROGRAMS now agree; no code changed in this push.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 14, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 67a389c.

Sensitive change review

  • What rule changed: the -d @ date carve-out also holds for a line of inert commands (date/grep, echo, cat; never printf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.
  • Before -> after (what was allowed/blocked, now): before, date -d @N in a chain, pipe, quoted substitution or locale prefix was refused. Now it is allowed, and every line where another program can send (printf -v 'BASH_CMDS[date]' included) is still refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the reader misjudges as inert could run a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 19 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (4077 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from 67a389c to 16d34ac Compare November 14, 2026 19:20
@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 14, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 16d34ac.

Sensitive change review

  • What rule changed: the -d @ date carve-out also holds for a line of inert commands (date/grep, echo, cat; never printf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.
  • Before -> after (what was allowed/blocked, now): before, date -d @N in a chain, pipe, quoted substitution or locale prefix was refused. Now it is allowed, and every line where another program can send (printf -v 'BASH_CMDS[date]' included) is still refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the reader misjudges as inert could run a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 19 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (4153 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from 16d34ac to 6b4d80e Compare November 14, 2026 20:22
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 6b4d80e.

Sensitive change review

  • What rule changed: the -d @ date carve-out also holds for a line of inert commands (date/grep, echo, cat; never printf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.
  • Before -> after (what was allowed/blocked, now): before, date -d @N in a chain, pipe, quoted substitution or locale prefix was refused. Now it is allowed, and every line where another program can send (printf -v 'BASH_CMDS[date]' included) is still refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the reader misjudges as inert could run a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 19 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (4166 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 14, 2026
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>
@iamwhatever
iamwhatever force-pushed the takeover/34755-inert-lines branch from 6b4d80e to 8c4187f Compare November 14, 2026 21:44
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Reasoning template for head 8c4187f.

Sensitive change review

  • What rule changed: the -d @ date carve-out also holds for a line of inert commands (date/grep, echo, cat; never printf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.
  • Before -> after (what was allowed/blocked, now): before, date -d @N in a chain, pipe, quoted substitution or locale prefix was refused. Now it is allowed, and every line where another program can send (printf -v 'BASH_CMDS[date]' included) is still refused.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a line the reader misjudges as inert could run a curl upload. The allow sets are closed, any unread construct keeps the deny, and the OS sandbox and network fence still apply.
  • Evidence checked (which sandbox result proves it): gate-level only, no sandbox change. The 19 sending lines are pinned as refused on this head.
  • No regression:
    • Tools still work (which tools/commands were run, result): is_denied and audit_bash_exfiltration were run on the reported commands and on every pinned denial in the security suites, with the expected results.
    • Backward compatible (old config / old data / old callers still work, how checked): no rule, pattern or toggle changed, and line one of every refusal is unchanged; test_deny_guidance.py passed.
    • Existing tests (which suites passed on this head): the security test files listed above (4017 passed), plus the flake-pattern ratchet.
  • How to undo: revert this single commit. No data, config or format migrates.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 14, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 14, 2026 23:16

@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.

Approving. On head 8c4187f the review read the full diff and the shared command reader it relies on. test/test_exfil_carveouts.py passes 65 of 65. On main plus this PR, the exfil carve-out, gate liveness, denied-commands and facade-mirror tests pass 505 of 505, and the merged security package measures 37,121 lines, which equals the new budget. Removing the _inert_line_allows call fails exactly the 6 new allowed-line tests, and deleting any of nine guards fails at least one test.
One thing done well: when the ssh-self heredoc reader kept failing review, the PR dropped that reader instead of patching another spelling.

Security: this PR widens the data-exfil-curl-file-body carve-out, so some lines that main refuses are now allowed. The new allow path accepts only a closed set of programs that send nothing (date, grep, egrep, fgrep, echo, cat; printf is left out on purpose), matched on the exact first word. The only accepted prefixes are TZ, LANG or LC_* assignments. The whole line is refused if it has any backslash, #, live $ or backtick, any redirection or other separator, more than 2,000 characters, or more than four $(. The review ran 19 adversarial lines against this head, including pipes into curl, exec curl, quoted curl inside $(...), backticks hiding curl and find -exec, and every one was refused. The first line of every refusal is unchanged, and the added diagnostic line holds only offsets and counts, never the matched bytes.

Optional:

  • Closes #34754 will close that issue automatically, but the body says the ssh-self heredoc refusal is still tracked there. Consider Part of #34754, or open a follow-up issue for the ssh-self half first.
  • The budget raise edits _PACKAGE_LINE_BUDGET directly. test/security_line_budget/README.md asks for a row file instead, here a +51 row with the reason, so that concurrent PRs do not conflict on the constant.
  • The current tests do not catch deleting the $( depth bound or the # half of the escape guard. A line under 2,000 characters with five $(, plus a # case with no backslash, would pin both.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9215c33 into main Nov 14, 2026
105 of 106 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the takeover/34755-inert-lines branch November 14, 2026 23:16
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssh-self and -d @ exfil gates refuse inert commands: heredoc bodies read as argv, date outside a lone command

3 participants