Skip to content

fix(security): fold runtime-synthesized targets in bare-kill bodies - #18849

Open
cruisercohen wants to merge 2 commits into
mainfrom
fix/issue-10279
Open

cruisercohen wants to merge 2 commits into
mainfrom
fix/issue-10279

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A bare kill whose PID lookup builds the protected process name at runtime is denied by the self-protection floor, while an ordinary variable process pattern stays allowed.

The bare-kill window searches each substitution body raw, with parameter defaults resolved, and per word of its tokenized view. All three are static, so a pgrep/pidof target assembled at runtime inside the body, from constant printf/echo substitution output or from a brace expansion, matched none of them and the kill was allowed. The same held after case … esac in the body. Same-line variable concatenation was already denied through the tokenized view, but nothing pinned it.

Why it matters

The floor is what stops an agent shell from terminating its own gateway. Two of the three reported synthesis forms reach that kill today with ordinary shell syntax.

Not a goal

  • Failing closed on an unresolvable lookup operand (a pattern variable bound off the line). Rejected below.
  • Evaluating arbitrary command output ($(cat f), $(rev <<<…)): outside a static floor, documented as the residual.
  • The pkill/killall leg, whose operand view is a separate change.

What changed (motivation → approach → change)

Symptom: a bare kill whose lookup target is built from constant substitution output or a brace expansion is allowed. Root cause: no member of the bare-kill window evaluates constant substitution output or brace expansion. Change (one commit):

  • shell_normalizer._fold_const_output_substitutions replaces each innermost single-literal $(printf …) / $(echo …) / backtick substitution with its output, innermost-first to a bounded fixpoint. The output comes from the existing argv_floor._static_substitution_output resolver, so there is one resolver and no new printf model. shell_normalizer._single_literal_output guards it to one plain-literal operand (no % conversion, no backslash escape) whose output carries no shell syntax, so a format, multiple operands, an escape, or any other command stays unfolded.
  • argv_floor._kill_body_synthesizes_self folds each raw bare-kill body BEFORE tokenizing, so the existing local-assignment resolver carries a folded value to a later reference. It then brace-expands every word with the existing _brace_expansions (identical comma alternatives deduplicated) and searches each alternative bare and through _resolved_word_view.
  • Quoting is read through _iter_shell_chars, the module's one quote/escape state machine, not a second copy: _quote_mask classifies each position from it and spans substitutions with the shared paren reader. Quoted braces and quoted substitutions stay literal, as in bash; a real comment is inert through its newline; an escaped \$(…) is never folded; a parameter expansion's own word is not brace-expanded; and an assignment's value keeps its braces literal. The shared span walk (_matching_close_paren) reads a $( inside double quotes as its own scope, so a quoted ) inside it does not end the kill's window early.
  • Bounds: all expansion work for one body draws on one cumulative character budget (_BRACE_CHAR_CAP), and a same-line assignment chain whose words together would resolve past it is refused on their lengths alone, before anything is built. Brace fan-out is capped before materializing. The budget belongs to this window only; the connection-target brace check keeps its existing word cap. That check now shares this window's _brace_expansions, so identical comma alternatives are deduplicated for it too. This only removes an over-refusal: every distinct word is still checked and a wide distinct fan-out still fails closed, so no connection target that was refused before is allowed now (a before/after classification over the ssh rows shows 0 newly allowed).
  • The hosts-file helpers already live in their own modules on main (the line parser and digest in hosts_file, the per-platform resolution in argv_floor_hosts); this PR does not move or change them.
  • The runtime-synthesis search _kill_body_synthesizes_self moves unchanged into a new sibling module, kill_synthesis, behind a one-call wrapper in argv_floor_self (re-exported through argv_floor) with the same name and signature; the floor's resolver, brace expander and character cap are passed in. The move is mechanical, only to keep argv_floor_self under the package's per-file line limit; no reading changes.
  • The package line budget in test_security_gate_liveness.py is re-pinned to the measured total, with its reason beside it.

Posture decision (the issue's fork). Chosen: deny the forms the floor can compute exactly, and do NOT fail closed on an unresolvable operand. Rejected alternative: fail closed on any unresolvable expansion in the pgrep/pidof target position. A process pattern held in a variable is an ordinary benign shape, so that rule would refuse legitimate scripting broadly to close a residual a static floor cannot read anyway. Also considered and left out of this PR: a broader second change that resolved assignment dataflow across control-flow joins; this PR ships the runtime-synthesis fold only.

Residual, documented in the spec bullet. Output the fold cannot compute exactly stays outside the floor: a printf format, an escaped or multi-word operand, echo -e, any command other than a single-literal printf/echo, and a brace product past the fan-out cap.

Backwards compatibility

Compatible: the change only adds deny verdicts, never removes one. It adds them for bare kills whose lookup target folds or expands to the protected name. Within the bare-kill window it also now fails closed — refuses — when a body exceeds the character budget, the brace fan-out or depth cap, or the resolver bound. A benign unresolvable process pattern is still allowed, as before (the posture decision above), and every command outside the bare-kill window is judged exactly as before.

Removes nothing: the window's existing searches are unchanged and this adds a further member to them; the moved helper keeps its name where callers import it.

Tests

test/test_bare_kill_runtime_synthesis_10279.py drives the floor and is_denied directly; each synthesis row runs both in a plain list and after case … esac:

  • denied: single-literal printf/echo -n/backtick substitutions, nested and to a nine-deep fixpoint; a folded value carried through a same-line assignment; {,} and {c..c} braces, including pidof; an argument shaped like name=value (bash does not assign in argument position, so its braces expand); a brace after a leading command-position assignment; a parameter word nested in a brace group; identical alternatives that collapse rather than overflow the cap; quoting edge cases (a quote inside a comment, a quoted/escaped/unterminated ${, an ANSI-C escaped quote, a double-quoted ) inside a substitution, a subshell's or case pattern's ), $$); and the same-line variable concatenation row (pin).
  • allowed (false-positive controls, deliberate): an unresolvable pattern variable, a different product name (literal, braced, substitution-built), an unrelated constant substitution, a printf format or escape (not modelled), over-cap numeric and letter ranges, a 300-way replica alternation, an over-cap brace product (a residual), quoting that makes braces or a substitution literal, an assignment value's braces, and the name built in a different command than the kill.
  • bounds: doubling, continuation-split and quoted-space assignment chains are refused before they are built, and so are words that each fit the budget but together pass it; a wide comma group is capped before building; many unterminated parameter openers are scanned once; brace work on pathological input is bounded (counted, not timed); the connection-target brace check keeps no character budget.
  • a unit pin that _single_literal_output declines formats and multiple operands while resolving a single literal.

Red without the fix: 56 rows of that file fail with main's security sources and all pass on this head. The security, denied-command (security, governance, hooks), argv-floor scope, inline-payload, process-lookup and gate-liveness suites pass locally (4,294 passed); ten hook and own-host-read tests fail identically on main in the local environment only.

Manual verification

N/A — the floor is a pure function of the command string, and the unit tests call it directly.

Related Issues

Part of #10279 — this PR closes the three reported synthesis forms (substitution output, brace expansion, same-line variable concatenation); the broader runtime command-output class stays a documented residual, so #10279 remains open to track a structural control as its own design drive.

Pattern harvest

Rule candidate: review-prompt
Pattern: a deny gate whose searches are all static should list, per operand position it guards, which runtime-synthesis forms it resolves and which it pins as residuals.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

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

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 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

  • src/kiro_crew/security/argv_floor_ssh.py

  • src/kiro_crew/security/kill_synthesis.py

  • src/kiro_crew/security/shell_normalizer.py

  • src/kiro_crew/security/shell_normalizer_walk.py

  • @cruisercohen posted a complete reasoning template for 52e8f70.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9 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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9 — 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 fix traces to issue #10279 and its tests fail on base. The open pkill leg is the larger residual, and the description defers it explicitly.

Notes

  • Items 1–2 — symptom-level: this is the spelling-chase AGENTS.md warns about. Two spellings are closed, but the pkill/killall operand loop (argv_floor_self.py:863-872) runs no fold. I counted 1 unfixed sibling: pkill -f "$(printf kiro)crew" stays allowed while the longer kill $(pgrep …) form is denied. A %s format ($(printf %s kiro)crew) also stays open, by the PR's own residual list. The description defers the pkill leg ("The pkill/killall leg … a separate change"), so this is accepted-and-deferred.
  • Items 1–3 — oversized: this ships about 410 lines of new quote-mask, brace-mask and fold code in shell_normalizer.py (1590 → 1999 lines, one under the hard cap) to close two spellings while the shortest ones stay open. Subtraction: move the fold/mask block (_quote_mask through _single_literal_output) out of shell_normalizer.py into the already-added kill_synthesis.py, its only consumer, so the shared normalizer gets smaller instead of reaching the cap.

What this change ships

Inventory (9 items) — 6 justified

Intent: stop an agent shell from killing its own gateway through a PID lookup whose process name is assembled at runtime. FIX.

  1. A bare kill whose pgrep/pidof target comes from literal printf/echo output is now refused — justified
  2. A bare kill whose target is built by brace expansion (kiro{,}crew) is now refused — justified
  3. A bare-kill body past the character budget, the nesting depth or the resolver bound is now refused (fail closed) — justified
  4. A variable process pattern bound off the line is still allowed — justified
  5. Connection-target brace check now dedupes identical alternatives, so fewer ssh commands are wrongly refused — rides along
  6. Shared paren-span walk now treats $( inside double quotes as its own scope, for every caller — rides along
  7. Brace expander moved out of the ssh module, and the synthesis search split into a new kill_synthesis module — justified
  8. Package line budget in the liveness test re-pinned — justified
  9. Security spec documents the fold, its bounds and its residual — rides along

[FIRST-PRINCIPLES-REVIEWED] 52e8f70

Description read

[DESCRIPTION-READ] a3b488f55e16c1e9f8e12939602a0a92951a63190f300ead19f7e3dae8c433c2

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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change only adds denials inside the bare-kill window, the moved brace helpers are still re-exported through argv_floor, and the PR names its residuals.

Notes

  • This is the shape AGENTS.md calls a spelling chase: each newly modelled form (printf, echo -n, backticks, {,}, {c..c}) closes one spelling and leaves $(rev <<<…), printf formats and echo -e open. It cost about 520 lines of package budget. If this floor needs another round, look for a check that runs where the kill actually happens (resolve the PID being signalled, not the command text) instead of adding more folds.

[DESIGN-REVIEWED] 52e8f70

Description read

[DESCRIPTION-READ] c2f8517e0ae662a644dadf1c90122a2bc3b0ab02657b89d6ac8b3c62db7033a3

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.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6823d87
  • What rule changed: The self-protection kill floor's bare-kill window now also folds constant printf/echo substitution output and brace-expands each body word before searching for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from nested printf output or brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names and unrelated substitutions stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup folds to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control. 28 of 37 cases fail with the source change reverted.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny and shell-normalizer suites ran locally on this head: 11,730 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; the existing window searches are untouched and this is an added union member, checked by the unchanged existing floor tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason.
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9 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): 19 classified, 0 newly refused, 17 still allowed.
  • ubuntu-latest (platform posix): 19 classified, 0 newly refused, 17 still allowed.
  • windows-latest (platform windows): 4 classified, 0 newly refused, 4 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The change folds and brace-expands the target of a bare kill $(...) lookup and searches it for the protected name. It does this only for the body of a substitution in a bare kill's own argv, so ordinary port, PID-file, pgrep and ps|awk kills should be unaffected; 23 candidates probe that boundary, and no regression is confirmed. Two parts can't be adjudicated by a single command line: the new fail-closed exits (the 262,144-char size bound, the depth-8 fold cap, and an unproven quote-mask span) and the shared _matching_close_paren change that all its extractors now use. These are named below.

TIGHTENING: Bare-kill window in _is_self_kill (sensitive-bash tier, argv floor) -- it refuses a kill whose pgrep/pidof target builds the protected name at runtime, from constant printf/echo output or brace expansion: + # Runtime synthesis the static views cannot see (folded output, braces). / + if _kill_body_synthesizes_self(body): / + return True. It also refuses (fails closed) when _synthesis_words returns None or the body's character budget runs out (if words is None: return True).

ADJUDICATED: 23 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix (19 rows): the bare-kill shapes maintainers actually run: lsof port kills, PID files, backticks, quoted pgrep patterns, ps|grep|awk with quoted awk braces, a nested "$(dirname "$0")" (which uses the changed nested-double-quote walk in _matching_close_paren), $$ next to a closer (the new _opens_dollar parity rule), arithmetic $((, in-cap brace ranges, a kiro-{cli,chat} near-miss, an inline assignment, case/esac after the kill, docker kill, and the relocated ssh/rsync brace expander. windows (4 rows): Git Bash/MSYS spellings: a single-quoted C:\Users\… backslash path, "$USERPROFILE\…", a forward-slash drive path, and kill -f against a node.exe WINPID. These cover the diff's one platform-sensitive assumption, that the quote mask, fold and $HOME-expanding _self_command_tokens read backslashes and drive letters the way POSIX bash quoting does. No any rows: every candidate carries a path or a program spelling. PowerShell Stop-Process/taskkill were not written because they never reach the bare-kill window.

UNADJUDICATED: (1) The fail-closed exits in kill_synthesis._kill_body_synthesizes_self → shell_normalizer._synthesis_words. The path is is_denied → _is_self_kill → _bare_kill_raw_bodies(source) → _kill_body_synthesizes_self(body) → _fold_const_output_substitutions (None when _MASK_UNPROVEN is set or depth > _FOLD_DEPTH_CAP=8) / size total > _BRACE_CHAR_CAP / resolver exception → deny. Classifying one legitimate command line can't show where those thresholds sit for real kill bodies. The inputs I would have submitted are a generated stop script whose kill $(...) body inlines a long heredoc or many $VAR references that resolve to a large total size, and a body whose inner substitution the quote mask can't prove (a backtick inside a double-quoted grep pattern, such as kill $(pgrep -f "build \x")). (2) _matching_close_parennow recurses into every$(inside double quotes, for all its extractor call sites, not only the kill window. A quoted span like"$( echo ')' )"that used to be proven may now be unproven, so its extractor takes the whole remainder as the body. That widens what the extractor scans and can surface a product name from a later, unrelated command. The candidate I would have submitted isecho "$(printf ')')" ; ls /tmp/kirocrew-logs`, through any extractor that scans the remainder for the name.

[SCOPE-REVIEWED] 52e8f70

@cruisercohen
cruisercohen marked this pull request as ready for review October 10, 2026 12:52
@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners October 10, 2026 12:52
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/security/argv_floor_self.py:765 -- Deduplicate comma alternatives before applying the cap

return parts if len(parts) <= cap else [""] * (cap + 1)
Trigger: kill $(pidof -x kiro{c,c,...,c}rew), with exactly 257 comma-separated c alternatives, reaches is_denied → _is_self_kill → _kill_body_synthesizes_self → _brace_expansions → this check.
Outcome: The gate allows the command because overflow skips the name search. Bash produces 257 identical kirocrew operands, so pidof -x selects the gateway and kill terminates it; the sandbox permits targeted signals.
Anchor: residual/security
Fix: Deduplicate the comma alternatives before checking their count against cap, preserving the existing limit on distinct expansions.

[BLOCK-MERGE] 52e8f70
[GPT-REVIEWED] 52e8f70

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

I confirmed F1 in the code. It stays blocking and I did not FLAG it, because the evasion is easy for an agent to produce and the fix is small.

F1: src/kiro_crew/security/argv_floor_self.py:765 checks the raw count of comma alternatives against the cap before removing duplicates. With 257 alternatives the cap is 256, so the function returns an overflow list. _brace_expansions then returns None at :788-789, before the duplicate removal at :790 ever runs. The caller in src/kiro_crew/security/kill_synthesis.py:47-48 treats overflow as a residual and continues, so it allows the command instead of denying it. The comment at argv_floor_self.py:721 says the caller denies on overflow; it does not.

The residual is justified at kill_synthesis.py:34 by "a wider product cannot name a single live process". That is false for 257 identical alternatives, which bash expands to the protected name over and over. There is no fallback: the name search is skipped and nothing else catches it. An agent under prompt injection can write this input, so it is not an extreme case. The fix is to remove duplicates before the count check, which needs no new state.

[ADJUDICATION] 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9

[ADJUDICATION-FENCED] 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9 fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/security/argv_floor_self.py:765 -- The cap counts duplicate alternatives before deduping, and overflow is allowed as a residual at kill_synthesis.py:47-48, so 257 copies of one alternative let an agent-written `kill $(pidof -x kiro{c,...}rew)` through.
[GPT-ADJUDICATED-FENCED] 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

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

The bare-kill window still lets two easy forms through: an escaped \${ in a word, and a brace product over the cap. Both build the gateway's name at runtime, the floor allows them, and the kill terminates the gateway.

BLOCKING — src/kiro_crew/security/shell_normalizer.py:1261
if depth == 0 and word.startswith("${", i): / out.append("$" + _QUOTED_BRACE_OPEN)
Trigger: kill $(ps -eo pid,args | grep x\${\\\|kiro{c..c}rew | awk '{print $1}') reaches _is_self_kill → _kill_body_synthesizes_self → _mask_param_word_braces. _mask_param_word_braces reads the de-quoted x${\|kiro{c..c}rew. The ${ was escaped in the source, but this function opens a parameter word there anyway. No } closes it, so {c..c} gets masked and never expands. Without the \${ the same command is denied.
Outcome: bash runs grep 'x${\|kirocrew', which is a BRE alternation, so it matches the gateway's process line and the kill terminates it. _is_self_kill returns False and is_denied returns None.
Anchor: residual/security
Fix: decide whether ${ opens a parameter word from the quoting before de-quoting (_mask_quoted_braces already sees \$ as escaped), or treat an unterminated ${ as plain text and re-read from that point, the way _mask_quoted_braces does.

BLOCKING — src/kiro_crew/security/kill_synthesis.py:48
continue # over-cap fan-out: a residual, not failed closed
Trigger: add {,{1..257}} to any form this PR denies, e.g. kill $(pidof kiro{c..c}rew{,{1..257}}). _brace_alternatives returns its overflow list, _brace_expansions returns None, the caller hits continue, and no other view sees the name.
Outcome: bash produces kirocrew kirocrew1 … kirocrew257. pidof accepts many names and returns the PID of the process named exactly kirocrew, which the kill then terminates. Checked live: pidof kirocrew kirocrew1 kirocrew2 returned the PID. The docstring says a product this wide "cannot name a single live process"; that is false for pidof. The floor allows the command.
Anchor: residual/security
Fix: on overflow, fail closed when the word's shortest or empty branches can still spell the name. Otherwise fail closed on overflow for multi-name lookups like pidof. The reverted ssh floor behaved this way, and the _BRACE_EXPANSION_CAP comment still says it does.

[BLOCK-MERGE] 52e8f70
[OPUS-REVIEWED] 52e8f70

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 52e8f703a3474ae1f86ddf677109ed01f0d5c9b9: <one-sentence reason>

@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 Oct 10, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e06afc6
  • What rule changed: The self-protection kill floor's bare-kill window now also folds constant printf/echo substitution output and brace-expands each body word before searching for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from nested printf output or brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names, unrelated substitutions, output words bash keeps apart and unrelated large numeric brace ranges stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup folds to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control. The printf model, the unknown-escape case (no crash) and the brace overflow rule each have pinned cases.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny and shell-normalizer suites ran locally on this head: 11,756 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; the existing window searches are untouched and this is an added union member, checked by the unchanged existing floor tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason.
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6aa3f41
  • What rule changed: The self-protection kill floor's bare-kill window now also folds constant printf/echo substitution output and brace-expands each body word before searching for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from nested printf output or brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names, unrelated substitutions, output words bash keeps apart and over-cap brace products that cannot spell the name (numeric ranges are collapsed first) stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup folds to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control. The printf model, the unknown-escape case (no crash) and the brace overflow rule each have pinned cases.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny and shell-normalizer suites ran locally on this head: 11,758 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; the existing window searches are untouched and this is an added union member, checked by the unchanged existing floor tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason.
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 55994d4
  • What rule changed: The self-protection kill floor's bare-kill window now also folds constant printf/echo substitution output (through the existing static substitution resolver) and brace-expands each body word before searching for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from nested printf output or brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names, unrelated substitutions, output words bash keeps apart and over-cap brace products that cannot spell the name (numeric ranges are collapsed first) stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup folds to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control. The %s-only printf fill, the unknown-escape case (no crash) and the brace overflow rule each have pinned cases.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny and shell-normalizer suites ran locally on this head: 11,849 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; the existing window searches are untouched and this is an added union member, checked by the unchanged existing floor tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason.
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5f35904
  • What rule changed: The self-protection kill floor's bare-kill window now also folds constant printf/echo substitution output (through the existing static substitution resolver) and brace-expands each body word before searching for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from nested printf output or brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names, unrelated substitutions, output words bash keeps apart and over-cap brace products with no window that could spell the name (numeric ranges collapsed, letter ranges read as one letter) stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup folds to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control. The %s-only printf fill, the unknown-escape case (no crash) and the brace overflow rule each have pinned cases.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny and shell-normalizer suites ran locally on this head: 11,851 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; the existing window searches are untouched and this is an added union member, checked by the unchanged existing floor tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason.
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@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 Oct 10, 2026
@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 Oct 10, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8f03ee0
  • What rule changed: The self-protection kill floor's bare-kill window now also folds a single-literal printf/echo substitution output (through the existing static substitution resolver) and matches an over-cap brace product exactly, before searching the body for the protected name.
  • Before -> after (what was allowed/blocked, now): Before, a bare kill whose pgrep/pidof target was built from a single-literal substitution or a brace expansion was allowed; now those are blocked. Unresolvable pattern variables, other product names, formats/escapes the fold cannot compute, and large unrelated brace ranges and alternations stay allowed, unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A benign kill whose lookup provably resolves to the protected name is refused (over-blocking, fail-closed direction); no secret path, no auth, and no allowance is widened. The brace-overflow decision is now exact, so it neither over- nor under-approximates.
  • Evidence checked (which sandbox result proves it): The floor is a pure string predicate; the new test file asserts the floor verdict and is_denied for every denied row in a plain list and after case/esac, and asserts allow for each false-positive control, including the service-replica alternations the scope review flagged and the printf-format/escape residuals the GPT lane flagged.
  • No regression:
    • Tools still work (which tools/commands were run, result): The full security, floor, kill, deny, shell-normalizer and ssh suites ran locally on this head: 11,839 passed; the only failures reproduce on the base commit and are host-environment skill-root tests.
    • Backward compatible (old config / old data / old callers still work, how checked): No config, data or public signature changes; _static_substitution_output keeps its signature and behaviour for every existing caller (the single-literal guard is a separate wrapper), checked by the unchanged existing floor and ssh-self tests passing.
    • Existing tests (which suites passed on this head): The CI suites on this head plus the local security subset above, including the package line-budget ratchet re-pinned with its reason and the per-module cap (argv_floor stays under 4500).
  • How to undo: Revert this single commit; the floor returns to its previous static searches with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Rebased onto main 370b190 after #17540; liveness budget re-pinned, no code change.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ce908ab
  • This head is a rebase of 0b26295f2c352988fd16fe9f0529e81b004b07ae onto current main (d2cc1eab03) with no code change: git range-diff shows both commits identical to the previous head apart from the package line budget, re-pinned for each commit to main's pin plus this PR's measured lines (main's pin moved from 29,175 to 29,181). The floor module stays at 4,498 lines, under the per-module cap, with or without the second commit. The notes below are carried over from the template for the previous head, which was itself a rebase of 917ff462c90f6a53d96a3c271cb50f857c298086, before that of 1e5031396b8c71a8d9253070b8b16042da3c3bb7, before that of 858fa0777e459549c3ad77240a5f108f7068c6a8, before that of 11995c52dae3186733fda7a23754aea1799a86e5, and before that of a3b49713669d2e3dbdf2053f4c3223e7ae62e52a onto de2d143dcf. After main's merges the floor module would have sat 8 lines over the security package's per-module line cap, so one pure helper (the platform hosts-file path seam, _hosts_file_paths) moves unchanged from argv_floor.py into its existing sibling hosts_file.py, where the other hosts-file seams already live; argv_floor re-imports it in the same import block the tests monkeypatch through, so every caller and every patch site resolve unchanged. The move is folded into the first commit, so the floor module is under the cap with or without the second commit (4,498 lines either way). The package line budget is re-pinned to the measured total on the new base for each commit. git range-diff shows both commits identical to the previous head apart from the budget pins, so the rule, the before/after and the worst case below are unchanged from the template for that head.
  • What rule changed: The self-protection resolver evaluates TWO deny paths and ORs them, so it can only ADD denials and never suppress one. (1) The eager last-write resolver (restored byte-for-byte from the base, with a per-value cap so a x=$x$x doubling bomb cannot hang the gate) resolves each $VAR to the literal last assigned, catching assembled/recomputed/appended/indirect kills and mints exactly as the base does. (2) The window resolver adds the branch-UNION reach (a value live through an if/case/loop/&&/||/subshell), fanning out a multi-valued name only inside a kill/mint window. The floor scans both frames (deduplicated), so head-denied is a SUPERSET of base-denied by construction.
  • Before -> after (what was allowed/blocked, now): The structural OR closes the whole class where the rewritten resolver denied LESS than base. Every row the base denies (assembly, recompute, a non-command word after an assignment, a spaced redirection, an array-element prefix, the two-variable kill, a prefix exported to a child) stays denied on head. The PR ADDS the branch-union-reachable kill that base allows. Still allowed: the reused-variable rows, the build script, and echo of branch-set names — base allows those too, so the OR does not regress them.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A command whose resolved line names a kill or mint is refused (over-blocking, fail-closed). The OR only adds refusals; the error direction is a spurious refusal, never a missed kill. No secret path, no auth, no allowance widened. Residual: a value a command must RUN to produce stays unresolved — the documented class the regex tier and the OS sandbox cover. The helper move changes no behaviour: the function body is byte-identical and is reached through the same name.
  • Evidence checked (which sandbox result proves it): the base-superset test pins every base-denied row denied on head; the structural-superset test pins base's eager frame always among the scanned frames; reverting the two resolver source files reds eleven of those rows (red-without-fix). The deny/benign tables and the counted fan-out/perf tests pass. The doubling bomb that hung base resolves well under the cap. The hosts-file seam tests (which patch the path helper through the floor module) pass unchanged.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill runtime-synthesis, gate-liveness, denied-commands (security and governance), security, security facade and brace-scope suites pass: 3307 passed, 2 skipped; 2 gateway-startup rows could not import a markdown dependency that is missing from the local environment and touch no security code. The gate-liveness and bare-kill suites also pass on the first commit alone (105 passed).
    • Backward compatible (old config / old data / old callers): no config, data or wire changes; the moved helper is re-imported into the floor module, so every consumer and the package facade resolve unchanged.
    • Existing tests (which suites passed on this head): the suites above pass locally.
  • How to undo: revert this PR's commits; the resolver returns to its prior behaviour and the helper returns to the floor module, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Rebased onto main d2cc1ea after #20160; liveness budget re-pinned, no code change.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ae44d6c
  • This head is a rebase of ce908ab79784b9ceeac2fc7bb48b919dec9ef740 onto current main (3d09514228) with no code change: git range-diff shows both commits identical to the previous head apart from the package line budget, re-pinned for each commit to main's pin plus this PR's measured lines (main's pin moved from 29,181 to 29,205). This PR touches no file the credential pre-filter change on main touched. The floor module stays at 4,498 lines, under the per-module cap, with or without the second commit. The notes below are carried over from the template for the previous head, which was itself a rebase of 0b26295f2c352988fd16fe9f0529e81b004b07ae, before that of 917ff462c90f6a53d96a3c271cb50f857c298086, before that of 1e5031396b8c71a8d9253070b8b16042da3c3bb7, before that of 858fa0777e459549c3ad77240a5f108f7068c6a8, before that of 11995c52dae3186733fda7a23754aea1799a86e5, and before that of a3b49713669d2e3dbdf2053f4c3223e7ae62e52a onto de2d143dcf. After main's merges the floor module would have sat 8 lines over the security package's per-module line cap, so one pure helper (the platform hosts-file path seam, _hosts_file_paths) moves unchanged from argv_floor.py into its existing sibling hosts_file.py, where the other hosts-file seams already live; argv_floor re-imports it in the same import block the tests monkeypatch through, so every caller and every patch site resolve unchanged. The move is folded into the first commit, so the floor module is under the cap with or without the second commit (4,498 lines either way). The package line budget is re-pinned to the measured total on the new base for each commit. git range-diff shows both commits identical to the previous head apart from the budget pins, so the rule, the before/after and the worst case below are unchanged from the template for that head.
  • What rule changed: The self-protection resolver evaluates TWO deny paths and ORs them, so it can only ADD denials and never suppress one. (1) The eager last-write resolver (restored byte-for-byte from the base, with a per-value cap so a x=$x$x doubling bomb cannot hang the gate) resolves each $VAR to the literal last assigned, catching assembled/recomputed/appended/indirect kills and mints exactly as the base does. (2) The window resolver adds the branch-UNION reach (a value live through an if/case/loop/&&/||/subshell), fanning out a multi-valued name only inside a kill/mint window. The floor scans both frames (deduplicated), so head-denied is a SUPERSET of base-denied by construction.
  • Before -> after (what was allowed/blocked, now): The structural OR closes the whole class where the rewritten resolver denied LESS than base. Every row the base denies (assembly, recompute, a non-command word after an assignment, a spaced redirection, an array-element prefix, the two-variable kill, a prefix exported to a child) stays denied on head. The PR ADDS the branch-union-reachable kill that base allows. Still allowed: the reused-variable rows, the build script, and echo of branch-set names — base allows those too, so the OR does not regress them.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A command whose resolved line names a kill or mint is refused (over-blocking, fail-closed). The OR only adds refusals; the error direction is a spurious refusal, never a missed kill. No secret path, no auth, no allowance widened. Residual: a value a command must RUN to produce stays unresolved — the documented class the regex tier and the OS sandbox cover. The helper move changes no behaviour: the function body is byte-identical and is reached through the same name.
  • Evidence checked (which sandbox result proves it): the base-superset test pins every base-denied row denied on head; the structural-superset test pins base's eager frame always among the scanned frames; reverting the two resolver source files reds eleven of those rows (red-without-fix). The deny/benign tables and the counted fan-out/perf tests pass. The doubling bomb that hung base resolves well under the cap. The hosts-file seam tests (which patch the path helper through the floor module) pass unchanged.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill runtime-synthesis, gate-liveness, denied-commands (security and governance), security, security facade, regex linearity, credential pre-filter anchor and brace-scope suites pass: 3,340 passed, 2 skipped, 0 failed. The gate-liveness, bare-kill, security and denied-commands security suites also pass on the first commit alone (2,880 passed, 2 skipped).
    • Backward compatible (old config / old data / old callers): no config, data or wire changes; the moved helper is re-imported into the floor module, so every consumer and the package facade resolve unchanged.
    • Existing tests (which suites passed on this head): the suites above pass locally.
  • How to undo: revert this PR's commits; the resolver returns to its prior behaviour and the helper returns to the floor module, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Rebased onto main 3d09514 after #20492; liveness budget re-pinned, no code change.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9ee6b6d
  • This head folds a review-round fix into the SECOND commit (it is not a pure rebase). The first commit is unchanged; git range-diff against the previous head shows only the second commit's resolver fix plus the package line-budget re-pin. The floor module stays at 4,498 lines, under the per-module cap, with or without the second commit, so dropping the second commit is still a clean removal.
  • What rule changed: The self-protection resolver evaluates TWO deny paths and ORs them, so it can only ADD denials and never suppress one. (1) The eager last-write resolver resolves each $VAR to the literal last assigned, catching assembled/recomputed/appended/indirect kills and mints exactly as the base does; a per-value cap bounds a doubling bomb. This head changes that cap to FAIL CLOSED: a tracked value longer than the cap is unverifiable, so the name binds to the protected-name sentinel rather than keeping a truncated prefix, and any later use inside a kill/mint window is denied. (2) The window resolver adds the branch-UNION reach (a value live through an if/case/loop/&&/||/subshell), fanning out a multi-valued name only inside a kill/mint window. The floor scans both frames (deduplicated), so head-denied is a SUPERSET of base-denied by construction.
  • Before -> after (what was allowed/blocked, now): On the previous head an over-cap tracked value whose dangerous tail sat past the cap resolved to its benign prefix and a later kill/mint window ran it; the baseline resolver (no cap) denied the same input. This head denies it: the over-cap value fails closed. A benign over-cap value used OUTSIDE any kill/mint window (an ordinary command) is NOT refused, so the over-approximation adds no false denial to normal scripts. Every row the base denies stays denied; nothing previously blocked is now allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A command whose over-cap value reaches a kill/mint window is refused (over-blocking, fail-closed). The error direction is a spurious refusal of a pathological >16 KB value, never a missed kill or mint. No secret path, no auth, no allowance widened.
  • Evidence checked (which sandbox result proves it): a regression test reproduces the finding as a real test — allowed on the pre-fix head, denied here — and a benign-control test pins an over-cap value outside a window still allowed; reverting the one-line resolver change reds them (red-without-fix). The base-superset test still pins every base-denied row denied on head. On fresh main the same inputs are denied, and on the first commit alone they are denied too (the first commit has no cap), so the second commit is a clean drop either way.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the security, denied-commands (security and governance), bare-kill runtime-synthesis and gate-liveness suites pass: 3,064 passed, 2 skipped, 0 failed. The gate-liveness suite and the overflow rows also pass on the first commit alone.
    • Backward compatible (old config / old data / old callers): no config, data or wire changes; the change is one line in the eager resolver's value store.
    • Existing tests (which suites passed on this head): the suites above pass locally.
  • How to undo: revert this PR's commits; the resolver returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Review dispositions — head 9ee6b6d

  • GPT 6.1 — _assign.py:407: fixed in 9ee6b6d5848341a25d30654bff2305cfb4a28823. The eager last-write resolver now fails closed when a tracked value exceeds its per-value cap — an over-cap value is unverifiable, so the name binds to the protected-name sentinel and any later use inside a kill/mint window is denied, rather than keeping a truncated prefix as if it were the whole value. A benign over-cap value outside any such window stays allowed. Regression test test_overflowing_padded_name_fails_closed (with test_eager_resolver_binds_an_overflowed_name_to_the_sentinel and the benign control test_a_benign_over_cap_value_outside_a_window_stays_allowed) in test_bare_kill_runtime_synthesis_10279.py; red without the fix.

The fix is folded into the second commit, so the PR stays two commits and dropping the second commit remains a clean removal. The floor module stays at 4,498 lines (under the per-module cap) with or without the second commit, and the package line budget is re-pinned to the measured total for each commit.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ac51189
  • This head is the FIRST commit alone, rebased onto current main; the second commit is dropped and none of its code, tests or docs come back. git range-diff against the earlier first commit shows only the package line-budget re-pin and two comment words. The floor module is 4,498 lines, under the per-module cap.
  • What rule changed: inside a bare-kill substitution body, the process-lookup operand is now folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver, so there is no second printf model), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. The hosts-file path helper moves unchanged into its own module so the floor module stays under its cap.
  • Before -> after (what was allowed/blocked, now): on main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion was allowed, in a plain list and after a case ... esac. This head refuses those. A same-line variable concatenation was already refused on main and still is. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, or a pathological body past the expansion budget, is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test/test_bare_kill_runtime_synthesis_10279.py drives the floor and is_denied directly: 56 of its rows fail with main's security sources and all pass on this head. The three reported forms in both spellings (six rows): four are allowed on main, all six are refused here.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the security, denied-commands (security, governance, hooks), argv-floor scope, inline-payload, process-lookup and gate-liveness suites: 4,294 passed, 2 skipped. Ten hook and own-host-read tests fail identically with main's sources in this local environment and pass in CI; the diff does not touch them.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; the import path of the moved helper is kept for callers, and the suites above import through it.
    • Existing tests (which suites passed on this head): the suites above, plus the black, isort, flake8, mypy (security package), comment-history, brand-name and file-line-cap gates.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

This PR is narrowed to its first change, as the maintainer asked: the branch is rebased onto current main and now carries only the first commit (head ac511897f4a144059a563c2889fde07d3f3d03da). The second change, the assignment dataflow resolution, is dropped from this PR along with its tests and docs. The description is rewritten to cover only what this commit ships; the Goal line is unchanged, and the problem text now describes the forms in prose. The package line budget is re-pinned to the measured total on this base.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6e14657
  • This head is still the FIRST commit alone, now on current main (e492fda), amended once to address the two blocking review findings on the previous head ac51189. The second commit stays dropped. The package line budget is re-pinned to 29,759 (main's 29,296 plus this change's 463, measured exactly); the floor module is 4,498 lines and the shell normalizer 4,225, both under the per-module cap.
  • What rule changed: inside a bare-kill substitution body, the process-lookup operand is folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver, so there is no second printf model), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. Two tightenings in this amend: (1) the same-line assignment-chain sizing now measures the resolver's own de-quoted, operator-split tokens, so a chain held inside one quoted word is sized as it would be built, and any error while resolving is a refusal rather than an empty word list; (2) a body whose substitution nesting is deeper than a small fixed depth is refused before the first fold pass, so the fold's work stays linear in the body. The hosts-file path helper moves unchanged into its own module so the floor module stays under its cap.
  • Before -> after (what was allowed/blocked, now): on main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion was allowed, in a plain list and after a case ... esac. This head refuses those. A same-line variable concatenation was already refused on main and still is. Relative to ac51189, a quoted-word assignment chain and a deeply nested substitution body that were allowed (or slow to check) are now refused promptly. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, a body past the expansion budget, or a body nested past the depth cap is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test/test_bare_kill_runtime_synthesis_10279.py drives the floor and is_denied directly. Four new tests (a quoted-word assignment chain, a resolver failure, nesting past the depth cap with zero fold passes, and nesting at the cap still folding) fail on ac51189 and pass here. An end-to-end check of the deep-nesting command refuses it in about 7 s on this head; main allows it. The three reported forms in both spellings (six rows): four are allowed on main, all six are refused here.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill synthesis and gate-liveness suites pass (109 passed), and the wider security suites show only the same local-environment failures that main's sources show here and that pass in CI; the diff does not touch them.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; the import path of the moved helper is kept for callers, and the suites above import through it. The token-stream helper is factored out of the existing tokenizer with no behaviour change.
    • Existing tests (which suites passed on this head): the suites above, plus the black, isort, flake8, mypy (security package), comment-history, brand-name and file-line-cap gates.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Updated to 6e14657 (still a single commit, on current main). Both blocking review points on ac51189 are fixed at the root:

  • Assignment-chain sizing inside a quoted word: the chain sizing now measures the resolver's own de-quoted, operator-split tokens, so a chain held inside one quoted word is sized as it would be built, and an error while resolving now refuses the command instead of reading as no words. New tests: test_quoted_word_holding_an_assignment_chain_fails_closed_before_building_it and test_a_resolver_failure_is_a_deny.
  • Slow fold on deeply nested substitutions: a body nested deeper than a small fixed depth is now refused before the first fold pass, so the fold's work stays linear in the body. New tests: test_deep_substitution_nesting_fails_closed_before_any_fold_pass and test_nesting_at_the_depth_cap_still_folds.

All four tests fail on ac51189 and pass on this head. The non-blocking note about a very wide brace group is the documented over-cap case and is unchanged. The line-budget pin is updated for the new base.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ea23655
  • This head is still the FIRST commit alone, rebased onto current main (c6d6106) and amended once more to address the one blocking review finding on the previous head 6e14657. The second commit stays dropped. The package line budget is re-pinned to 29,762 (main's 29,296 plus this change's 466, measured exactly); the floor module is 4,498 lines and the shell normalizer 4,228, both under the per-module cap.
  • What rule changed: inside a bare-kill substitution body, the process-lookup operand is folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver, so there is no second printf model), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. A same-line assignment chain is sized on the resolver's own tokens before it is built, a resolver error is a refusal, and a body nested past a small fixed depth is refused before the first fold pass. The tightening in this amend: the check that decides whether a $ opens a substitution now counts the whole run of backslashes before it, and treats the $ as escaped only when that run is odd, as the shell reads it (previously a run of two read as escaped). The hosts-file path helper moves unchanged into its own module so the floor module stays under its cap.
  • Before -> after (what was allowed/blocked, now): on main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion was allowed, in a plain list and after a case ... esac. This head refuses those. A same-line variable concatenation was already refused on main and still is. Relative to 6e14657, a quoted substitution preceded by an even run of backslashes now keeps the lookup after it inside the window, so it is refused. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, a body past the expansion budget, or a body nested past the depth cap is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test/test_bare_kill_runtime_synthesis_10279.py drives the floor and is_denied directly. The new test test_even_backslash_run_before_a_quoted_substitution_keeps_it_open (two and four backslashes, with a literal and a folded target) fails on 6e14657's code and passes here. The three reported forms in both spellings (six rows): four are allowed on main, all six are refused here.
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill synthesis and gate-liveness suites pass (111 passed). The wider security-related suites (about 25,000 tests) show only local-environment failures; every one of them also fails with main's sources here, and the diff does not touch them.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; the import path of the moved helper is kept for callers, and the suites above import through it.
    • Existing tests (which suites passed on this head): the suites above, plus the black, isort, flake8, mypy (security package), comment-history, brand-name and file-line-cap gates.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Updated to ea23655 (still a single commit, rebased onto current main). The blocking review point on 6e14657 is fixed at the root:

  • Backslash run before a $: the check that decides whether a $ opens a substitution now counts the whole run of backslashes before it and treats the $ as escaped only when the run is odd, as the shell does. A run of two (or four) was read as escaping the $, which ended the substitution body early. New test: test_even_backslash_run_before_a_quoted_substitution_keeps_it_open (two and four backslashes, literal and folded target); it fails on 6e14657's code and passes on this head.

The rebase also picks up the main fix for the lazy-import count test that was failing on the previous head. The line-budget pin is updated for the new base.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt ea23655: both findings are over-refusals that fail closed: the head refuses a harmless lookup that main allows and never allows anything main refuses; each needs a leading-space assignment or a substitution spliced into a brace endpoint next to the protected name, and is left for a follow-up.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@cruisercohen marked the gpt AI finding as false positive, not applicable, or explicitly accepted for ea2365576414a3150dcaa3e085ddb4748b8d3d5a.

both findings are over-refusals that fail closed: the head refuses a harmless lookup that main allows and never allows anything main refuses; each needs a leading-space assignment or a substitution spliced into a brace endpoint next to the protected name, and is left for a follow-up.

This decision applies only to this commit. A new push requires a new judgment.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b5903af
  • This head is ea23655 rebased onto current main (5d899b0), with one mechanical move folded into the single commit: the runtime-synthesis search _kill_body_synthesizes_self moves into its own sibling module, kill_synthesis.py, and the floor module keeps a one-call wrapper with the same signature. The floor's constant-output resolver, brace expander and character cap are passed in, so the new module imports only the shell normalizer and the shared vocabulary; the search body is otherwise unchanged. Main's hosts-file cache-key change put the rebased floor module at 4,517 lines, past the 4,500-line per-module cap; with the move it measures 4,493 (the shell normalizer stays 4,228). The package line budget is re-pinned to 29,908 (main's 29,411 plus this change's 497, measured exactly).
  • What rule changed: nothing relative to ea23655. Inside a bare-kill substitution body, the process-lookup operand is folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. A same-line assignment chain is sized on the resolver's own tokens before it is built, a resolver error is a refusal, a body nested past a small fixed depth is refused before the first fold pass, and a backslash run escapes the $ after it only when the run is odd.
  • Before -> after (what was allowed/blocked, now): against ea23655 nothing changes. On main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion is allowed, in a plain list and after a case ... esac; this head refuses those. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, a body past the expansion budget, or a body nested past the depth cap is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test/test_bare_kill_runtime_synthesis_10279.py drives the floor and is_denied directly and is unchanged by the move. A deny_diff against main 5d899b0 shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified, 0 regressions, 0 loosenings).
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill synthesis, gate-liveness, security facade, single-storage, denied-commands (security and governance), pkill alternation and inline/brace-scope suites pass: 4,583 passed, 1 skipped.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; _kill_body_synthesizes_self keeps its name and one-argument signature in the floor module, and the suites above call it there.
    • Existing tests (which suites passed on this head): the suites above, plus the black, isort, flake8, mypy (security package), comment-history and file-line-cap gates.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Rebased onto main 5d899b0. _kill_body_synthesizes_self moves unchanged into kill_synthesis.py behind a one-call wrapper in argv_floor.py, so argv_floor.py stays under the per-file line limit; no behaviour change.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9ea08b2
  • This head is b5903af (same base, main 5d899b0) amended with one fix for the review finding on _synthesis_words: the length bound on the local-assignment resolution now applies to the running total of all the body's words, not only to each word, so words that each fit the body's character budget but together pass it are refused before anything is resolved. The kill_synthesis.py move is unchanged. The floor module is 4,493 lines and the shell normalizer 4,232, both under the per-module cap. The package line budget is re-pinned to 29,912 (main's 29,411 plus this change's 501, measured exactly).
  • What rule changed: inside a bare-kill substitution body, the process-lookup operand is folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. A same-line assignment chain is sized on the resolver's own tokens, as a total over all its words, before it is built; a resolver error is a refusal, a body nested past a small fixed depth is refused before the first fold pass, and a backslash run escapes the $ after it only when the run is odd.
  • Before -> after (what was allowed/blocked, now): relative to b5903af, a body whose words each fit the budget but together resolve past it is refused instead of resolved. On main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion is allowed, in a plain list and after a case ... esac; this head refuses those. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, a body past the expansion budget, or a body nested past the depth cap is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test_references_that_add_up_past_the_cap_fail_closed_before_building_them and test_the_resolved_size_limit_is_on_the_total_of_the_words fail on b5903af's code and pass here (the under-limit case passes on both). A deny_diff against main 5d899b0 shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified, 0 regressions, 0 loosenings).
  • No regression:
    • Tools still work (which tools/commands were run, result): on this head the bare-kill synthesis, gate-liveness, security facade, single-storage, denied-commands (security and governance), pkill alternation and inline/brace-scope suites pass: 4,586 passed, 1 skipped.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; _kill_body_synthesizes_self keeps its name and one-argument signature in the floor module.
    • Existing tests (which suites passed on this head): the suites above, plus the black, isort, flake8, mypy (security package), comment-history and file-line-cap gates.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

On the GPT 6.1 finding for b5903af (shell_normalizer.py, _synthesis_words): fixed in 9ea08b2. The local-assignment resolution now has a total size limit: the resolved lengths of all the body's words are summed before anything is resolved, and a body whose total passes the character budget is refused, the same as a single word past it. test_references_that_add_up_past_the_cap_fail_closed_before_building_them and test_the_resolved_size_limit_is_on_the_total_of_the_words cover it; both fail on b5903af and pass on 9ea08b2.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 9ea08b2: the provider declined to review this head's content and posted no finding (the only GPT comment names the superseded head b5903af). This head is that head plus a fail-closed total-size cap on the assignment resolver and the pure kill_synthesis move; deny_diff vs base 5d899b0 is 0 newly refused and 0 loosenings (posix 45, windows 44). Override of a declined review, not a false allow.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@cruisercohen marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 9ea08b2321e70b9f37c728d6479f893504692a51.

the provider declined to review this head's content and posted no finding (the only GPT comment names the superseded head b5903af). This head is that head plus a fail-closed total-size cap on the assignment resolver and the pure kill_synthesis move; deny_diff vs base 5d899b0 is 0 newly refused and 0 loosenings (posix 45, windows 44). Override of a declined review, not a false allow.

This decision applies only to this commit. A new push requires a new judgment.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

@iamwhatever this is ready for another look when you have a moment: every check is green except the scope aggregator, and the one AI lane that stayed red was a provider decline the owner has overridden on this head. The change is the narrowed bare-kill runtime-synthesis fix with the resolver's total-size cap. Thanks!

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Rebased onto main; main split argv_floor.py and shell_normalizer.py into owner modules, so the same change now lives there; no behaviour change. The wrapper, the _is_self_kill hook and the brace expander are in argv_floor_self.py, the _matching_close_paren change and _opens_dollar are in shell_normalizer_walk.py, and the fold / mask / synthesis block and _self_command_tokens are in shell_normalizer.py. The brace expander moves down from argv_floor_ssh.py because the bare-kill wrapper in argv_floor_self.py needs it, and an owner may import only owners listed before it. The hosts-file path helper stays in argv_floor_hosts.py, where main now keeps it.

Sensitive change review

  • Head commit: 2a1403f
  • This head is 9ea08b2 rebased onto main 4d5cb47's owner split. Each of the 34 definitions this change adds or edits is byte-identical to its text on 9ea08b2, and kill_synthesis.py and the test file are byte-identical. The package line budget is re-pinned to 32,013 (main's 31,509 plus this change's 504, measured exactly). Every module is under the per-module cap; the largest touched is shell_normalizer.py at 1,979 lines.
  • What rule changed: unchanged from 9ea08b2. Inside a bare-kill substitution body, the process-lookup operand is folded before the protected-name search: a single plain-literal printf/echo substitution is replaced by its output (through the existing static-substitution resolver), and each word is brace-expanded, with identical alternatives deduplicated. All expansion work in one body shares one character budget; a body that would exceed it is refused. A same-line assignment chain is sized on the resolver's own tokens, as a total over all its words, before it is built. A resolver error is a refusal, a body nested past a small fixed depth is refused before the first fold pass, and a backslash run escapes the $ after it only when the run is odd.
  • Before -> after (what was allowed/blocked, now): on main, a bare kill whose lookup target is assembled from constant printf/echo output or from a brace expansion is allowed, in a plain list and after a case ... esac; this head refuses those. An unresolvable pattern variable, a lookup naming a different product, and a brace product past the fan-out cap stay allowed, pinned by tests as deliberate.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose lookup operand folds or expands to the protected name, a body past the expansion budget, or a body nested past the depth cap is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): test/test_bare_kill_runtime_synthesis_10279.py run on main 4d5cb47 fails 65 and passes 39. 48 of its 52 deny rows fail there; the other 4 are already refused on main and on this change's original base 5d899b0. All 104 pass on this head. A verdict-parity deny_diff over those 52 deny rows plus the 32 allow controls finds no verdict changed between 9ea08b2 and this head. Against main the same corpus has 48 newly refused and 0 loosenings, the same as 5d899b0 to 9ea08b2. A golden-path deny_diff against main 4d5cb47 shows 45 classified on posix, 0 newly refused and 0 loosenings.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 45 golden-path shell rows are allowed on main and on this head alike. On this head the bare-kill synthesis, argv-floor facade (owner layer order, type-checker manifest, patch seams) and gate-liveness suites pass, and so does the wider denied-commands / security / shell-normalizer / facade / file-line-cap set: 7,910 passed, 2 skipped across 46 files.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; _kill_body_synthesizes_self keeps its name and one-argument signature behind the argv_floor facade, and every moved brace-expander name is still served from the facade.
    • Existing tests (which suites passed on this head): the suites above, plus flake8 and isort on the security package.
  • How to undo: revert this single commit; the window returns to its prior behaviour, with no data migration.

@cruisercohen

cruisercohen commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main c2cedd8 (the only conflict was the package line budget pin in test/test_security_gate_liveness.py), with one change folded into the second commit: the bare-kill constant-output fold now folds only a real substitution span. (This comment was first posted for 6ad7b33 and is updated in place for the new head.)

Sensitive change review

  • Head commit: 52e8f70
  • This head is 140e5a3 rebased onto main c2cedd8, plus one change in its second commit: _fold_const_output_substitutions (shell_normalizer.py) folds a constant printf/echo substitution only where the quote mask recorded a substitution opener and only up to that span's own end, and fails closed (refuses) when the quote mask cannot prove a span -- an unbalanced opener, or nesting past its own cap. It also adds four test rows (the case-folded delimiter rows and a deep-nesting fail-closed row) and one allowed control, and re-pins the package line budget to main's 32,125 plus this PR's growth, 32,647. No other definition changed. Every module is under the per-module cap.
  • What rule changed: inside a bare-kill substitution body, the fold no longer pairs one substitution's closing backtick with the next opener (so a constant-output substitution after an earlier one is folded like any other), and a body nested past the quote mask's cap is refused rather than searched unfolded. Nothing else changed from 140e5a3.
  • Before -> after (what was allowed/blocked, now): a body whose synthesized name was left unfolded because of an earlier substitution is now refused, as the same body without that earlier substitution already was. A body of the same shape naming another product stays allowed (pinned by a test).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a bare kill whose body folds to the protected name is refused. The error direction is a spurious refusal, never a new allowance; no rule is loosened, and no secret path or auth code is touched.
  • Evidence checked (which sandbox result proves it): on fd46673 (140e5a3 rebased, before this fold change) the six new test cases fail and the new control passes; on this head all pass. deny_diff from fd46673 finds only the new rows newly refused and 0 loosenings; from a512a2d and f245659 to this head, 0 changes on every corpus. Against main c2cedd8 the golden paths show 0 newly refused and 0 loosenings (posix 45 classified, windows 44), and the 84-row parity corpus refuses the same 48 rows as before with 0 loosenings.
  • No regression:
    • Tools still work (which tools/commands were run, result): the golden-path shell rows are allowed on main and on this head alike.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or wire change; no signature changed; the fold's only caller is the bare-kill window.
    • Existing tests (which suites passed on this head): 57 security, denied-command (including the self-kill floor), argv-floor, facade-mirror, file line cap, bare-kill and shell-normalizer test files, 8,901 passed; black, isort, flake8 and mypy on the changed files are clean.
  • How to undo: revert the second commit's fold change to return to 140e5a3's behaviour, or revert both commits to return to main's; no data migration.

@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for human review. This PR changes the self-protection kill floor, which decides which shell commands are refused as killing the gateway, and the shared brace expander that the ssh connection-target check also uses. Under the review policy that kind of change is reserved for a maintainer, even though every lane is PASS, Security Scope found 0 newly refused commands, and every check is green at 140e5a31fdbafd49b4bc9fdcc8ba7c49571eff45.

I found no definite defect. The points below are open on this head and would help the human reviewer:

  • _brace_expansions now dedupes words for the ssh connection-target caller too, so a repeated identical product that used to overflow and fail closed now resolves to one word. My read is that this only removes an over-refusal, because every distinct word is still checked. But the description says the connection-target check "keeps its existing word cap". Please declare the change (First Principles item 5) or limit the dedupe to the kill window.
  • The description still says the hosts-file helper moves into hosts_file and the wrapper lives in argv_floor. Neither is true on this head. The Compatible: line also leaves out the new fail-closed denies (budget, depth cap, resolver error) that the Design lane named.
  • The Design lane asks for a structural control (sandbox or a PID fence) because $(rev <<<...), echo -e and printf formats still reach the kill. If that is planned, link an issue.
  • The First Principles note on inlining kill_synthesis.py and the Opus note on shell_normalizer.py at 1,982 lines have no reply.

Reviewed head: 140e5a31fdbafd49b4bc9fdcc8ba7c49571eff45.

— crew-pr-reviewer (r117)

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Thanks — updated the description on this head (140e5a31fdbafd49b4bc9fdcc8ba7c49571eff45) and answering the open points:

Brace dedupe on the connection-target check. Declared in the description now. The shared _brace_expansions deduplicates identical comma alternatives for the connection-target check as well, and this only removes an over-refusal: dict.fromkeys drops exact duplicates only, every distinct word is still checked, and a wide distinct fan-out still returns over-cap (fails closed). A before/after classification over the ssh rows shows 0 newly allowed and 0 newly refused, so the fail-closed posture is preserved — no connection target that was refused before is allowed now.

Stale description claims. Corrected. main already split the owner modules, so on this head the hosts-file helpers live in hosts_file (line parser + digest) and argv_floor_hosts (per-platform resolution) and this PR does not touch them; _kill_body_synthesizes_self lives in kill_synthesis with a one-call wrapper in argv_floor_self (re-exported through argv_floor), not in argv_floor. The Compatible: line now names the new fail-closed denies — the character budget, the brace fan-out/depth cap, and the resolver bound inside the bare-kill window.

Structural control / residual. The forms a static floor cannot compute exactly stay a documented residual (a printf format, an escaped or multi-word operand, echo -e, any command other than a single-literal printf/echo, and a brace product past the fan-out cap). I changed the link to Part of #10279 so the issue stays open to track a structural control as its own design drive rather than riding on this PR.

The two unanswered notes.

  • Inlining kill_synthesis: the move to a sibling module is mechanical, only to keep argv_floor_self/argv_floor under the per-file line cap; the wrapper re-exports it with the same name and signature, so no reading or logic changed.
  • shell_normalizer.py at 1,982 lines: it is under the package's per-module cap (4,500) and the 2,000-line split target, and this PR adds the fold while staying within the cap.

This stays held for your human review.

A bare `kill` whose PID comes from a substitution could hide the protected
name from every static search by assembling it at runtime: a single-literal
`printf`/`echo` substitution, a brace expansion, or a same-line variable
concatenation. The bare-kill window now folds constant `printf`/`echo` output
(reusing the existing static-substitution resolver, guarded to one plain
literal) to a bounded fixpoint and brace-expands each word before the name
search, deduping identical alternatives so an identical-alternative explosion
is one word rather than an over-cap residual.

The quote reading that keeps a quoted substitution, brace, comment or escape
inert comes from `_iter_shell_chars` -- the module's one quote/escape state
machine -- not a second copy. `name=value` is masked as an assignment only in
command position, so a `pgrep` argument's braces still expand. The synthesis
budget sizes the resolver's own de-quoted, continuation-folded, operator-split
tokens, so a chain split across a `\<newline>`, a quoted space or held inside
one quoted word is bounded before the eager resolver builds it, and a resolver
failure is a deny rather than an empty word list. A body nested deeper than a
small substitution depth fails closed before the first fold pass, so the fold
stays linear in the body. Brace fan-out is capped before materializing. A
parameter word nested in a brace group is masked before expansion (only when
its substitution span proves closed) so the enclosing group still expands,
matching bash's brace-before-parameter order.

Posture: an unresolvable operand and a brace product past the fan-out cap are
documented residuals, not failed closed; a nesting or chain that would exceed
the fold/character budget fails closed. The reported forms all fit
within the cap, and a wider product names no one live process.

Fixes #10279
…ize bound

The bare-kill synthesis size bound now covers every parameter reference form the resolver expands, so a body is sized in full before anything is built.

Fold only a real substitution span the quote mask recorded, ending at that
span's own end, so a closing backtick is never read as the opener of the
next substitution; and fail the fold closed when the quote mask cannot prove
a span, so a body nested past the mask's own cap is refused rather than
searched unfolded.
@bolichen97

Copy link
Copy Markdown
Contributor

Thanks for this PR. It now conflicts with main. Could you rebase onto the latest main and resolve the conflicts? We will review it again once it is rebased and CI is green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants