Skip to content

fix(security): refuse a command nested past 32 substitutions before the floors walk it - #37875

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/floors-nested-walk-linear
Nov 16, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/floors-nested-walk-linear

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A command nested deeper than 32 substitutions gets a prompt refusal from the deny gate, instead of a gate that works for seconds or tens of seconds before answering.

is_denied does work that grows with nesting depth times command length on a deeply nested command substitution. On the 1,000-deep double-quoted $( ) command from #37792, it takes about 20 s even with the ssh floor stubbed to return False. #37820 bounds only the ssh floor. Counts on main (cProfile, ssh floor stubbed): the shared quote machine _iter_shell_chars takes 120,930 steps at depth 100 and 471,830 at depth 200. Doubling the depth multiplies the work by 3.9.

Why it matters

The deny check runs on every shell tool call. While it works, the turn is stalled and a gate worker is held. A nest of a few hundred levels is a few KB of text, so one generated or hostile command is enough to hold the gate for seconds.

Not a goal

What changed (motivation → approach → change)

Three floors each re-walk the nested text once per level:

  • Payload walk. _shell_payload_walk_uncached re-tokenises each substitution body as its own string and calls _substitution_bodies on it (201 calls at depth 200). Each call's _matching_close_paren walks that body again, so total work is the sum of every body's length.
  • Self-kill floor. _bare_kill_raw_bodies is called 201 times from _self_kill_span and re-walks each body the same way.
  • Git-publish floor. is_denied calls _is_git_publish once per payload frame (201 calls), and each call scans that frame's whole source text.

The bound sits at the gate, not inside each floor, because three in-flight PRs own the files those floors live in. One check at the top of is_denied caps all three floors at about 32 walks of the command today without touching those files. #36437 removes the re-read from offset 0 inside _close_paren_walk, which is the per-call cost. It does not remove the per-level re-walk, so the two changes are complementary.

deny_gate._nested_past_cap makes one pass over the command and refuses once nesting passes _MAX_SUBSTITUTION_DEPTH = 32, before any floor runs. Bash opens a fresh quoting context inside each $(, so "$(echo "$(… nests even though the quotes alternate. A flat quote state misreads that, so the pass keeps a stack of contexts: command text, double quotes and a backtick body. Only $(, <( and >( count. A bare ( and a backtick span are tracked, so a ) or quote inside them reads right, but neither counts. An unescaped backtick cannot open inside a backtick span: it closes it, even from inside a double-quoted string there, as bash reads it. So at most one backtick level sits between two counted levels, and the floors' work stays within about twice the cap. Not counting them also keeps strings that are not posix shell from tripping the cap. is_denied reads every tool string on every host: PowerShell escapes a quote with a backtick, cmd /c paths end in \", and code or a regex may nest parentheses freely. Single-quoted and ANSI-C text and escaped characters open nothing. A # comment runs to its newline, and between a case in command position and its esac a ) ends a pattern rather than a frame, as the floors' own walk reads them, so neither a quote in a comment nor a case pattern can hide a deep nest from the cap.

The refusal reads:

Blocked by security policy: substitution nesting deeper than 32
a command nested more than 32 substitutions deep is refused; flatten it

It is never waived, because past the cap no floor can read the command in bounded time. Its key is a self-guard key in deny_waiver.deny_key_is_self_guard, like the unverifiable push target, so the dashboard offers no override card for it. A deny event is written for it like every other refusal.

The payload walk's docstring says it takes no numeric depth cap, because a cap that stops reading is a bypass. This cap refuses rather than stops reading, so no command gets past it unread.

Backwards compatibility

Breaking: a command nested more than 32 substitutions deep, which main allowed, is now refused. Writer sweep on origin/main @ 467de02: _nested_past_cap run over every line of src/ and test/ (outside this PR's new test file) returns False for all of them, and commands the suites build at run time are covered by those suites passing unchanged.

Reader: src/kiro_crew/security/deny_gate.py:is_denied -- chat|cron|subagent|app -- every caller already handles a refusal string; this adds one more reason, test_one_past_the_cap_is_refused_with_the_way_out

Tests

test/test_denied_commands_security_nesting.py:

  • test_a_deep_nest_is_refused_without_walking_it[100|200]: at depth 100 and 200 the gate refuses with the depth reason and _iter_shell_chars takes 0 steps (main: 120,930 and 471,830). Counts only, no clock.
  • test_the_cap_itself_reaches_the_floors: depth 32 is allowed and the floors run.
  • test_a_floor_still_refuses_at_the_cap: a protected-branch push 32 deep is still refused by its floor, not by the cap.
  • test_no_card_is_offered_for_the_substitution_depth_cap (test_deny_session_override.py): override_offer_key returns None for the depth refusal, and a call that waives its key still refuses.
  • test_one_past_the_cap_is_refused_with_the_way_out: depth 33 gets the exact two-line refusal.
  • TestStringsThatAreNotPosixShell: the Security Scope Review's two PowerShell JSON writes (one repo value renamed for the brand gate), a generated 40-escape JSON write, a PowerShell status line with $( ), cmd /c paths ending in \" and a drive-letter path are not refused by the cap. Code, prose and a regex nesting parentheses are not refused either, and the issue's 1,000-deep command still is.
  • test_the_depth_scan_reads_the_shell_contexts: a quote in a comment, case patterns inside 40 levels, case as a plain argument in 40 sibling substitutions (allowed), an escaped \$( run, $#, an unclosed backtick run, a backtick closing its span from inside a quote, alternating quotes, a 33-deep subshell (allowed), groups inside substitutions, process substitution, sibling backticks, single-quoted, escaped and ANSI-C text, and two 32-deep siblings.

Proof: PROVEN test/test_denied_commands_security_nesting.py::TestSubstitutionDepthCap::test_a_deep_nest_is_refused_without_walking_it[100], test/test_denied_commands_security_nesting.py::TestSubstitutionDepthCap::test_a_deep_nest_is_refused_without_walking_it[200], test/test_denied_commands_security_nesting.py::TestSubstitutionDepthCap::test_one_past_the_cap_is_refused_with_the_way_out, test/test_denied_commands_security_nesting.py::TestSubstitutionDepthCap::test_the_depth_scan_reads_the_shell_contexts[echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo "$(echo x)")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")"-True], test/test_denied_commands_security_nesting.py::TestSubstitutionDepthCap::test_the_depth_scan_reads_the_shell_contexts[$( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( ($( (true) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )-True] (head e75d3b2)

Local pre-push reviews: a GPT lane on the previous head found a comment quote and a case pattern hiding a deep nest from the scan; both are fixed and pinned here. The local GPT lane runs on the session model rather than the pinned gpt-6.1-sol, so CI's GPT lane is the real pass.

Every existing allow and refuse row in the denied-commands, security, argv, shell_commands and shell_normalizer suites passes unchanged.

Manual verification

N/A — unit coverage sufficient: the change is one pure function and one early return in is_denied, both exercised directly.

Related Issues

Fixes #37874

Related #36437, #37792, #37820

Sibling sweep

Swept: git grep -nE "_matching_close_paren\(|_substitution_bodies\(|_is_git_publish\(" -- src/
Sibling: src/kiro_crew/security/shell_normalizer.py -- not affected -- its per-level walk is capped by the gate check, which runs first
Sibling: src/kiro_crew/security/argv_floor_self.py -- not affected -- its per-level walk is capped by the gate check, which runs first
Sibling: src/kiro_crew/security/argv_floor_ssh.py -- tracked in #37820

Pattern harvest

Rule candidate: review-prompt
Pattern: "a recursive reader that re-extracts each nested body as a new string and walks it again costs depth times length; bound the depth at the entry point or walk by offset"

Checklist

Contribution License Agreement

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

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners November 16, 2026 07:36
@jeeshofone
jeeshofone requested a review from buluoray November 16, 2026 07:36
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of e75d3b28f76b1579d42caee1ef259b3fe7e10753 via the fork AI-review pipeline — 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 answers a reproducible cost from #37792 and sits at the gate on purpose, because the floor files belong to three in-flight PRs. The description says this, and it says what is left.

Notes

  • Item 1 — duplicate of shell_normalizer_walk._iter_shell_chars: _nested_past_cap hand-rolls a second backslash/single/ANSI-C/double/backtick/comment/case scanner, next to a machine whose docstring says "one machine, several consumers, no second opinion to drift from". That machine has 21 call sites in 9 files. It is a note, not a block, because the flat quote state there cannot read per-$( contexts. Subtraction: once fix: make the deny gate's shell walk linear in command length #36437 lands, delete the private scanner and count depth on the shared walk.
  • Item 5 — inherited: "Matches the ssh floor's _MAX_SSH_READING_DEPTH". That constant is not on base, so 32 rests on symmetry with an unmerged twin. Subtraction: when both land, fold the two caps into this one constant.

What this change ships

Inventory (5 items) — 3 justified

Intent: a deeply nested shell command gets an immediate refusal, not a gate stalled for seconds. FIX.

  1. A command nested more than 32 $(/<(/>( levels is refused before any floor runs. — duplicate of shell_normalizer_walk.py _iter_shell_chars (second quote scanner)
  2. New two-line refusal text that says "flatten it". — justified
  3. No override card is offered for the depth refusal, and a waiver for it still refuses. — justified
  4. A deny event is recorded for the depth refusal. — justified
  5. The cap is fixed at 32, copied from an ssh-floor constant that is not on main. — inherited

[FIRST-PRINCIPLES-REVIEWED] e75d3b2

Description read

[DESCRIPTION-READ] 7ae47e7db1590331c2099803fac0593a2f2cf743de2ac6b035d3d8efeb918229

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of e75d3b28f76b1579d42caee1ef259b3fe7e10753 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

The cap refuses instead of stopping its read, so nothing gets past it unread. It runs before every floor, and a real command never nests 32 substitutions deep.

Notes

  • The patch adds a new refusal class and a new self-guard key, but it does not update docs/system-specs/modules/security.md. Add the cap and its never-waived status there in the same commit, as AGENTS.md requires.
  • Once fix(security): bound how deep the ssh floor nests its readings #37820 lands, _MAX_SUBSTITUTION_DEPTH and _MAX_SSH_READING_DEPTH are two copies of one bound. Do the unification follow-up then, or the two will drift.

[DESIGN-REVIEWED] e75d3b2

Description read

[DESCRIPTION-READ] 28826b4903fb7f430371da48a218a00202d18336e850ea4eac662391ea59e99e

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed e75d3b28f76b1579d42caee1ef259b3fe7e10753 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

Notes:

  • Candidates 1–4 are real scanner misreads (then case, \+newline #, $$', an apostrophe in a here-doc), but each one only under-counts the depth. The floors still run and still refuse, so the only cost is the gate falling back to its pre-PR speed.
  • Neither docs/request-for-change/rfc-deny-session-override.md nor the security spec lists the new never-waived depth key yet.

[OPUS-REVIEWED] e75d3b2

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings (all downgraded on adjudication)

Reviewed e75d3b28f76b1579d42caee1ef259b3fe7e10753 via the fork AI-review pipeline; updated in place on each push.

Opus 5.5 adjudication downgraded every blocking finding. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

Review details

BLOCKING -- src/kiro_crew/security/deny_gate.py:706 -- Quoted shell payloads bypass the substitution-depth bound

if _nested_past_cap(tool_name):
Trigger: Submit "bash -c '" + 'echo "$(' * 200 + 'true' + ')"' * 200 + "'" through HookManager → _tier_deny_rules → PolicyAuthority.is_denied. The preflight skips the single-quoted script, but _shell_payload_walk_uncached extracts and recursively scans it.
Outcome: The patched gate returns None and performs 476,477 _iter_shell_chars steps; the same unwrapped script is refused with zero steps. Deeper wrapped commands retain the superlinear work that stalls the synchronous gate and the user's turn.
Anchor: defect
Fix: Enforce a rejecting depth bound on the folded/decoded executable payload hierarchy before the floors recursively walk it, including quoted shell scripts.

[BLOCK-MERGE-DOWNGRADED] e75d3b2
[GPT-REVIEWED] e75d3b2

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

LOW rung. Nothing gets past the deny gate here: the walk still reads every payload (shell_normalizer.py:1666-1674), so the only cost is CPU. The required conditions all hold. The cap check runs only on the raw top-level text (diff deny_gate.py:706). The pre-scan skips single-quoted spans (diff lines 65-71). The walk then recurses into the bash -c payload with no depth cap, bounded only by payloads getting shorter (shell_normalizer.py:1623-1627,1673). Recovery: the walk always ends and returns a verdict, so the slowdown is visible and limited by command length. It is no worse than on main, and the PR's own $(/"$( cases still work.
The real fix is to raise a refusal from inside _shell_payload_walk_uncached, which several floors share (argv_floor_self.py, argv_rules.py, argv_floor). That means a new early-exit contract between those modules. It also chases another spelling of the same input, which AGENTS.md flags as a review smell. That costs more than closing an adversarial-only slowdown that main already has.

[ADJUDICATION] e75d3b28f76b1579d42caee1ef259b3fe7e10753 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/security/deny_gate.py:706 reason=disproportionate-remedy
[GPT-ADJUDICATED] e75d3b28f76b1579d42caee1ef259b3fe7e10753

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — ✅ PASS

Which legitimate operations does e75d3b28f76b1579d42caee1ef259b3fe7e10753 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

adjudicated, zero confirmed regressions

Scope-Verdict: PASS

Reason: The change adds one guard: a depth cap on $(/<(/>( nesting that runs before any floor, and it was checked against 17 posix and windows candidates near its boundary. No candidate has a harness verdict yet. If the harness confirms none of them, this passes. The open question is the scanner's own reading of case/esac and # in shell text it does not otherwise parse (heredoc bodies). That reading can leave a frame open, but no realistic command was shown to reach the cap that way.

TIGHTENING: A new pre-floor refusal in is_denied for _nested_past_cap(tool_name), with the key added to deny_key_is_self_guard, so no waiver can lift it. The one threat it refuses is a command nested deep enough to make the floors' depth-times-length re-walk unbounded: if _nested_past_cap(tool_name): _emit_deny_event(tool_name, _DEPTH_REFUSAL, lower); return _reason(_DEPTH_REFUSAL, _DEPTH_NOTE) with _MAX_SUBSTITUTION_DEPTH = 32.

ADJUDICATED: 17 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix (13 rows):

  • heredoc PR and commit bodies whose lines begin with case/esac
  • process substitution in both directions
  • arithmetic around substitutions
  • >( inside python and awk code
  • jq \( interpolation
  • $#/${#…} next to a real # comment
  • three-deep nested substitution
  • a multi-line case loop

These cover the scanner's posix assumptions: fresh quote contexts, case patterns, comments, escapes and ANSI-C quotes.

windows (4 rows):

  • PowerShell $( ) subexpressions in double quotes
  • $(…).Path member access
  • "$($_.X)" inside a script block
  • cmd /c with a trailing-backslash C:\ path

These cover the diff's stated assumption that PowerShell backtick escapes and \ path separators do not trip the cap. No any rows were written, because every candidate names an executable or a path. No platform the diff assumes is left without a candidate.

UNADJUDICATED: The cap's scanner (_nested_past_cap in src/kiro_crew/security/deny_gate.py, reached from is_denied for every tool string, not only shell commands) does not parse heredocs. It counts case at a line start in a heredoc body as an open case. That makes the frame's closing ) close nothing, so each such $(cat <<'EOF' … EOF\n) leaves one counted level open. Several of these in a row in one command would add up toward the cap with no real nesting. The posix heredoc rows probe one such leak per command. A long multi-step script with many such heredoc substitutions was not submitted, because no existing workflow could be named that runs it. Non-shell tool strings that reach is_denied (file contents, prose arguments) also go through this scan. Only the unrealistic shape of 33+ unclosed $(/<(/>( sequences would trip it, and there is no shell-row verdict for those inputs.

[SCOPE-REVIEWED] e75d3b2

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

@jeeshofone
jeeshofone force-pushed the fix/floors-nested-walk-linear branch from c9f47c9 to 4da4908 Compare November 16, 2026 09:02
@jeeshofone
jeeshofone force-pushed the fix/floors-nested-walk-linear branch from 4da4908 to e75d3b2 Compare November 16, 2026 10:02
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Opus review on 4da4908: fixed in e75d3b2.

The depth refusal's key, substitution nesting deeper than 32, is now a self-guard key in deny_waiver.deny_key_is_self_guard, held the same way as the unverifiable push target. override_offer_key therefore offers no card for it, and the refusal stays flat. The counting is unchanged.

Pinned by test_no_card_is_offered_for_the_substitution_depth_cap in test/test_deny_session_override.py: override_offer_key returns None for the real refusal, and is_denied(..., waived={key}) still returns the same refusal. The test fails without the deny_waiver change.

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

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 27% chance that this change introduces a defect, above the 12% limit for approving on its own.

The PR adds a single linear pre-scan at the top of is_denied. It refuses commands nested more than 32 $(/<(/>( levels deep before any floor runs, and the refusal cannot be overridden. I traced the scanner's quote, escape, comment and case handling; it matches the description and the tests, which count steps rather than time. Placement, the deny event and the self-guard key are correct, and nothing on main gets worse for commands nested 32 deep or less. Remaining gaps are non-blocking: a bash -c '…' wrapper brings back main's slowdown without passing anything unread; a rare multi-line case shape in file contents could cause a refusal that can't be overridden; and the security spec is not updated in the same commit.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit e75d3b28f7 · 274 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 16, 2026 12:15

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. On this head the review checked these points. Deny refusals for nesting of 32 levels or less are unchanged. Depth 33 gets the exact two-line refusal before any floor runs. The refusal key is a self-guard, so no override card is offered and a waiver naming the key still refuses. The new tests pass and are deterministic. Mutation runs showed that removing the early return, removing the self-guard key, or moving the cap by one level each turns tests red. A scan of about 86,800 whole files found no false refusals.

Done well: the tests count _iter_shell_chars steps instead of timing anything. They measure 0 steps at depth 100 and 200, so the cost claim is pinned without a clock.

Security: this PR changes a safety gate, but it only adds a refusal. The cap refuses and does not stop reading, so no command gets past the gate unread. A command the cap does not catch still goes through every floor exactly as it does on main. The new key cannot be waived, which matches how the unverifiable push target is held.

Optional:

  • docs/system-specs/modules/security.md (the Bounded cost bullet and the "no numeric depth cap" wording) and the never-overridable list in docs/request-for-change/rfc-deny-session-override.md do not mention the new refusal yet. AGENTS.md asks for that in the same commit. A short follow-up, or a linked issue, would close the gap.
  • A nest inside a single-quoted payload such as bash -c '...' or eval '...' skips the cap. It is still walked at main's cost, so this is not a regression or a bypass. The body's claim that the cap covers "all three floors" is broader than the code. Naming this residual in _nested_past_cap's docstring and in a follow-up issue would keep the record accurate.
  • #37820 is on main now, so the comment about unifying _MAX_SUBSTITUTION_DEPTH with _MAX_SSH_READING_DEPTH can point to a tracking issue, or the two values can come from one constant.

bolichen97 pushed a commit that referenced this pull request Nov 16, 2026
…37964)

#37875 made the gate refuse any command nested past 32 substitutions
before a floor reads it, so the 128-level nest in #37820's test is now
refused by that cap and the test, which expected the ssh floor's rule,
is red on main. The test now checks the floor's bound at exactly 32
levels, which the cap lets through, and that 128 levels get the cap's
own refusal.

Closes #37963
buluoray pushed a commit that referenced this pull request Nov 19, 2026
buluoray added a commit that referenced this pull request Nov 19, 2026
…37964)

#37875 made the gate refuse any command nested past 32 substitutions
before a floor reads it, so the 128-level nest in #37820's test is now
refused by that cap and the test, which expected the ssh floor's rule,
is red on main. The test now checks the floor's bound at exactly 32
levels, which the cap lets through, and that 128 levels get the cap's
own refusal.

Closes #37963

(cherry picked from commit 529da1e)
buluoray pushed a commit that referenced this pull request Nov 19, 2026
buluoray added a commit that referenced this pull request Nov 19, 2026
…37964)

#37875 made the gate refuse any command nested past 32 substitutions
before a floor reads it, so the 128-level nest in #37820's test is now
refused by that cap and the test, which expected the ssh floor's rule,
is red on main. The test now checks the floor's bound at exactly 32
levels, which the cap lets through, and that 128 levels get the cap's
own refusal.

Closes #37963

(cherry picked from commit 529da1e)
buluoray pushed a commit that referenced this pull request Nov 19, 2026
buluoray added a commit that referenced this pull request Nov 19, 2026
…37964)

#37875 made the gate refuse any command nested past 32 substitutions
before a floor reads it, so the 128-level nest in #37820's test is now
refused by that cap and the test, which expected the ssh floor's rule,
is red on main. The test now checks the floor's bound at exactly 32
levels, which the cap lets through, and that 128 levels get the cap's
own refusal.

Closes #37963

(cherry picked from commit 529da1e)
buluoray pushed a commit that referenced this pull request Nov 19, 2026
buluoray added a commit that referenced this pull request Nov 19, 2026
…37964)

#37875 made the gate refuse any command nested past 32 substitutions
before a floor reads it, so the 128-level nest in #37820's test is now
refused by that cap and the test, which expected the ssh floor's rule,
is red on main. The test now checks the floor's bound at exactly 32
levels, which the cap lets through, and that 128 levels get the cap's
own refusal.

Closes #37963

(cherry picked from commit 529da1e)
bolichen97 added a commit that referenced this pull request Nov 19, 2026
… main (#39387)

Backports to release/0.13.0 the fixes from #39342, squashed into one
commit and brought up to date with release/0.13.0 after the Kiro Memory
preview backport (#39360). Picks, in order; each [pick sha] is the
commit on the #39342 branch, whose body has main's cherry-picked-from line:

- fix(monitor): wake the session once when its watched PR merges or closes (#37776) [pick 84da419]
- fix(security): match deny rules against Windows program suffixes and cmd/PowerShell in-word escapes (#33569) [pick e4941b7]
- fix(mimocode): refuse a chat that would answer from Xiaomi's hosted model unsigned (#37629) [pick 1bfdce3]
- fix(acp): end a quiet agent-started cycle on the shared runtime's stale gate (#37932) [pick fa870a2]
- fix(conductor): re-read goal-conductor after a compaction (#37917) [pick ccdd67c]
- fix(security): refuse a command nested past 32 substitutions before the floors walk it (#37875) [pick 2f9bd67]
- fix(mates): carry a moved Bot's shell toolsSettings entry as execute_bash instead of holding it (#37973) [pick 16022f4]
- fix: hold an app to its own sessions, jobs and runs (#37804) [pick 3dff0c0]
- fix(acp): keep a KAS chat's stored record when its resume fails after the load (#37955) [pick 6ceb7b5]
- fix(gateway): ignore a repeat SIGTERM during graceful shutdown (#38031) [pick b48287d]
- fix(security): keep a quote in a $( ) from hiding a later ssh (#37558) [pick b9fed61]
- fix(agent): rebuild takes a server's disabledTools from the kiro global (#38147) [pick c50bbcc]
- fix(mcp_gateway): keep the backend when a stub leaves an open listen (#38121) [pick 3e9c7f9]
- fix: refresh plan and model list after a kiro-cli sign-in to another account (#38053) [pick 5ad3d36]
- fix(slack): keep a picture sent in a linked thread for the dashboard turn (#38076) [pick 7f8903e]
- fix: keep a resolved tool policy when the gateway is too slow to answer (#36669) [pick 9be5691]
- fix: open owner-only files and prune overlay folders without following links (#36994) [pick 6a1acc9]
- fix: refuse the local token mint to app backends (#38113) [pick d166dab]
- fix(subagent): hold a spawn's first prompt for its MCP servers (#38127) [pick e3e0298]
- fix(security): refuse a headless git --output write with no approver (#36326) [pick 1abee40]
- fix(restore): require an explicit mode, never default to replace (#38094) [pick ca86c06]
- fix: make the deny gate's shell walk linear in command length (#36437) [pick 22c100b]
- fix(chat): let a cancelled background start finish its session teardown (#36664) [pick b1dd34f]
- fix(acp): refuse a start when two differing specs declare the agent's name (#38411) [pick 80ccfff]
- fix: probe a silent turn while its co-tenant keeps the process busy (#38662) [pick 6354490]
- fix(kas): let a reopened chat switch to models its load select omits (#38376) [pick 1640822]
- fix(cloud): install a patched node 22 on run on aws instances (#38732) [pick 059cb90]
- fix: write member record files without following links (#37303) [pick aac9642]
- fix: fail a kas start fast once the host has turned its mcp off (#38677) [pick e147238]
- fix(decisions): fall back to HTTP/1.1 when h2 is missing (#38759) [pick fc16482]
- fix(mcp_gateway): free a spawn permit when its backend exits before initialize (#38793) [pick a084ba2]
- fix(kas): start an app chat whose tool policy hides every kirocrew-cron tool (#38761) [pick ccea5a9]
- fix(acp): give the tool-stall watchdog a margin over native waits (#34117) [pick b5d9e89]
- fix(mcp): bind the working-folder answer to its launch; observe launch changes behind name grants (#38983) [pick a1069be]
- fix(mcp): hide the gateway secret files from the npm install and third-party probe spawns (#39000) [pick 14d8571]
- fix(sandbox): fold env name case on Windows in the agent env scrub (#33997) [pick 9bdce76]
- fix(apps): let app turns follow the Auto approval mode (#38830) [pick e8336df]
- fix: end a dashboard turn stopped while it is still being prepared (#36478) [pick 37fff93]
- fix(acp): cleanup_session deletes the record on the session's own host (#39046) [pick 31b5ec4]
- fix(acp): scan only the new part of a streamed tool result (#38852) [pick e2870db]
- fix(sandbox): make an unscoped session host the OOM victim, not the gateway (#39189) [pick 2be6dde]
- fix(security): read aws s3 downloads piped into tail, with 2>&1, or with an AWS_PROFILE prefix (#38271) [pick bf65d97]
- fix: redact four display and log paths and use a fixed 502 message for session switch refusals (#38982) [pick 55d9ec7]
- fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend (#34339) [pick afd2b14]
- fix(acp): wait for systemd scope admission as its own startup stage (#37008) [pick 3e29c86]
- fix(acp): wait for systemd scope admission on the AcpClient spawn path (#38303) [pick 85f0a25]
- fix(acp): stamp the spawn instance on the AcpClient child (#38810) [pick f36eb5a]
- fix: end the turn when the agent never confirms a stop (#38512) [pick 2665c9d]
- fix(kas): renew a refused crew sign-in instead of failing every start (#38978) [pick 2f48cac]
- fix(security): keep self-host detection when the ssh verb is a glob (#34056) [pick ab53f10]
- fix(security): judge each substitution body for ssh-to-self (#37616) [pick d5b7ac3]
- test: check the ssh floor's nesting bound below the gate's depth cap (#37964) [pick 6c9ae1d]
- fix(mate): apply held Bot limits on shared claude sessions and refuse unnarrowed KAS children (#39212) [pick 721bbbe]
- test(integration): wait out and reset the hidden-chat refresh between boots (#37933) [pick e77586d]
- fix(browser): fall back to Kiro's Chromium under Automatic when Chrome's remote debugging is off (#39265) [pick 31912eb]

Left out of #39342's set (not needed for 0.13.0): the provider_labels
refactor, #34045, #36668, #39120 and #37627.

Merge with release/0.13.0: kept both imports in runtime_session_load,
runtime_spawn_launch and session_provider; session_allocation lists the
memory_policy owner; the keep-record resume path passes kas_memory_mode
as main does; dropped the ACP_BACKENDS_SESSION_EVICTION import that
moved to session_provider_new_conversation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: deny-gate floors re-walk every nested substitution, so a deep $( ) nest stalls is_denied

2 participants