Repository navigation
fix(security): stop the file-body exfil gate refusing inert date lines - #36992
Conversation
Sensitive Change ReviewSensitive files changed:
|
4508873 to
d3427b8
Compare
|
Reasoning template for head d3427b8. Sensitive change review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the carve-out widening goes after the cause #34754 names ( What this change shipsInventory (5 items) — 5 justifiedIntent: let an agent convert an epoch with
[FIRST-PRINCIPLES-REVIEWED] 8c4187f Description read[DESCRIPTION-READ] 6e11d2817d28e1c023e65c80bed09874c7e328e1e491241666b200784b2050ce That sha256 names the PR description this verdict read. Recompute it with |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: This diff does not make any check stricter. TIGHTENING: none in the verdict path; the change only adds refusal text -- the one change on a refusal is the appended diagnostic line in ADJUDICATED: 18 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix rows cover the single [SCOPE-REVIEWED] 8c4187f |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: ApproveWhy: 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 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 |
d3427b8 to
d50b4fa
Compare
|
Reasoning template for head d50b4fa. Sensitive change review
|
|
span=4fda723f6f7e
|
|
span=e1ef3b066cec
|
|
span=49f9306ff16b
|
d50b4fa to
87208e6
Compare
|
Reasoning template for head 87208e6. Sensitive change review
|
|
span=e1ef3b066cec
|
87208e6 to
7ca9aae
Compare
|
Reasoning template for head 7ca9aae. Sensitive change review
|
|
span=f28364d8feb2
|
|
Reasoning template for head 67a389c. Sensitive change review
|
67a389c to
16d34ac
Compare
|
Reasoning template for head 16d34ac. Sensitive change review
|
16d34ac to
6b4d80e
Compare
|
Reasoning template for head 6b4d80e. Sensitive change review
|
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>
6b4d80e to
8c4187f
Compare
|
Reasoning template for head 8c4187f. Sensitive change review
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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 #34754will close that issue automatically, but the body says the ssh-self heredoc refusal is still tracked there. ConsiderPart of #34754, or open a follow-up issue for the ssh-self half first.- The budget raise edits
_PACKAGE_LINE_BUDGETdirectly. test/security_line_budget/README.md asks for a row file instead, here a+51row 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.
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 @) 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 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
sandbox-escape-ssh-selffalse refusal of a here-document edit script (python3 - <<'EOF'\n... a * localhost ...\nEOF). fix(security): stop the ssh-self and -d @ gates refusing inert lines #34755 carried a hand-rolled reader that cut such bodies out; five review rounds found four real bypasses in it (arithmetic((1<<2)), a body inside$(…), a copied shell at/tmp/cat, wrappers such asenv -S), so it is dropped and the floor keepsmain's reading. It belongs with a real shell AST, as in the AST-based push-floor work, not another string reader. Tracked in ssh-self and -d @ exfil gates refuse inert commands: heredoc bodies read as argv, date outside a lone command #34754.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.What changed (motivation → approach → change)
Symptom → cause → change.
-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).printfis not in that set:printf -vwrites a variable, andBASH_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_allowsis unchanged, so its parity test still holds.exfil_bash.audit_bash_exfiltrationappends the existingdiagnosticsline (componentexfil-gate, rule id, span, shape, never the matched bytes) to every exfil refusal. 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_exfil_carveouts.py::TestCompoundInertLine: the sixdatelines 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]'andprintf {-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 namesrule=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) plustest_flake_pattern_ratchet.pyandtest_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_exfiltrationentry 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Sensitive change review
-d @date carve-out also holds for a line of inert commands (date/grep,echo,cat; neverprintf). Exfil refusals gain a diagnostic line. The ssh-self floor is unchanged.date -d @Nin 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.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.