Skip to content

test: check the ssh floor's nesting bound below the gate's depth cap - #37964

Merged
bolichen97 merged 1 commit into
mainfrom
crew/slack/fix-nest-bound-test
Nov 16, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/slack/fix-nest-bound-test

Conversation

@buluoray

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make main's backend tests green again by updating one ssh-floor nesting test that the new substitution-depth cap made stale.

test/test_denied_commands_security_ssh_self.py::TestSshFloorNestingDepth::test_the_gate_refuses_a_nest_past_the_bound_without_an_exception fails on main d2f22f259eb0 (Backend Tests (3.12, 6) and (Windows) (6) on every PR):

AssertionError: assert '<unmapped:Blocked by security policy: substitution nesting deeper t...; flatten it>' == 'sandbox-escape-ssh-self'

Why it matters

Every open PR's backend shard 6 is red until this lands, so nothing that needs a green backend run can merge.

Not a goal

What changed (motivation → approach → change)

  • Symptom: the test sends a 128-level double-quoted $( ) nest through the gate and expects the ssh floor's rule, sandbox-escape-ssh-self.
  • Cause: fix(security): refuse a command nested past 32 substitutions before the floors walk it #37875 landed after fix(security): bound how deep the ssh floor nests its readings #37820 and refuses any command nested past 32 substitutions before a floor reads it. The 128-level nest now gets that cap's own refusal. Both refusals are right; the test's expectation is stale.
  • Change: the test now sends a nest of exactly _MAX_SSH_READING_DEPTH (32) levels. The gate cap lets that depth through, and the floor's reading bound refuses it with sandbox-escape-ssh-self. It also checks that 128 levels get the cap's refusal (substitution nesting deeper than 32). Measured on main: 31 levels are allowed, 32 are refused by the floor, 33 and up by the gate cap.

Backwards compatibility

Compatible: test-only change; no product code moves.

Removes nothing: the test keeps checking the floor's bound through the gate and adds a check on the cap; no product behavior changes.

Tests

  • test_the_gate_refuses_a_nest_past_the_bound_without_an_exception: failed on main before the change, passes after. With _MAX_SSH_READING_DEPTH raised to 64, it fails again, so it still pins the floor's bound.
  • test_denied_commands_security_ssh_self.py and test_denied_commands_security_nesting.py: 415 passed. test_flake_pattern_ratchet.py: 71 passed.

Proof: not provable -- test-only change

Manual verification

N/A — unit coverage sufficient; the change is one test.

Related Issues

Closes #37963

Sibling sweep

Swept: git grep -n "_nested_double_quoted(128\|_nested_double_quoted(1000" -- test/
Siblings: none -- the other deep-nest tests call _reaches_self_over_ssh directly, below the gate cap, and still pass

Pattern harvest

Not generalizable: two correct refusals landed in either order; the stale expectation is a one-off merge race, not a code pattern.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

#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
buluoray requested review from a team and KiroCrewCaptain as code owners November 16, 2026 12:56
@buluoray
buluoray enabled auto-merge (squash) November 16, 2026 12:56
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 5780a43eab98475aeba1aea5474365adc27f9484 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: this only updates one stale test, and the two refusal paths it checks are unchanged.

Notes

  • The test now holds only while the floor's reading bound (_MAX_SSH_READING_DEPTH) is at or below the gate's cap, which the test writes as the literal 32. If either value changes on its own, this test goes red. It does fail loudly rather than silently, so that is acceptable, but naming the gate's constant instead of 32 would make that dependency easy to see.

[DESIGN-REVIEWED] 5780a43

Description read

[DESCRIPTION-READ] f017e76bd0363e7c8583c1e2f1a5fb0afbd183bfe8f5141af74f4c2f8ddc3a0f

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5780a43eab98475aeba1aea5474365adc27f9484 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5780a43

Verdict parsed from the review's SHA-scoped output markers for commit 5780a43eab98475aeba1aea5474365adc27f9484.

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

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5780a43eab98475aeba1aea5474365adc27f9484 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5780a43

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

@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
@bolichen97
bolichen97 merged commit 529da1e into main Nov 16, 2026
95 checks passed
@bolichen97
bolichen97 deleted the crew/slack/fix-nest-bound-test branch November 16, 2026 13:51
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 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 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 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 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: ssh floor nesting-bound test is red on main after the substitution-depth cap

2 participants