Skip to content

fix(security): 0.13 backport, bound how deep the ssh floor nests its readings (#37820) - #37940

Merged
buluoray merged 1 commit into
release/0.13.0from
crew/slack/backport-0.13.0-37820
Nov 16, 2026
Merged

buluoray merged 1 commit into
release/0.13.0from
crew/slack/backport-0.13.0-37820

Conversation

@buluoray

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Ship in 0.13 the fix that stops a deeply nested double-quoted $( ) from crashing the ssh floor.

Backport onto release/0.13.0 (head 2fae50aae751, 0.13.0-rc.2). One commit, made with git cherry-pick -x. It applied with no conflict; nothing was hand-resolved.

Pick Main commit What 0.13 users get
#37820 75051817195c _is_ssh_to_self counts the readings open at once and refuses past 32, so a command nested about 1,000 levels deep gets a refusal instead of a RecursionError that aborts the turn. Only text that names an ssh-family verb recurses, so a deep nest without one is still allowed. Brings its own line-budget row (ssh-self-reading-depth.txt).

No prerequisite is needed: rc.2 already carries #37443, the change this bounds.

Why it matters

rc.2 carries #37443, so one crafted command aborts a 0.13 turn before its permission request is answered (#37792).

Not a goal

What changed (motivation → approach → change)

Cherry-pick only. No hunk was hand-resolved and no line is new.

Backwards compatibility

Compatible. A command nested past 32 readings that names an ssh-family verb is refused; before this it crashed the turn. Every other command is judged as before. Nothing is removed.

Tests

Test changes come from the pick (test/test_denied_commands_security_ssh_self.py).

Locally on this head: that file, test_security_gate_liveness.py and every test file that imports argv_floor or argv_floor_ssh: 2,271 passed, 0 failed. The 1,000-level command from #37792 now returns a refusal (True) from _reaches_self_over_ssh, where rc.2 raised RecursionError. flake8 and black on every Python file in the diff: clean.

Manual verification

N/A. Unit coverage above; the same change is on main.

Screenshots / video

N/A: no frontend change.

Related Issues

Part of #37792. Backport of #37820.

Sibling sweep

Siblings: none -- the backport touches the same sites #37820 changed on main

Pattern harvest

Not generalizable: backport of an already-reviewed fix (#37820)

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)

A double-quoted $( ) nested about 1,000 levels deep made _is_ssh_to_self and
_double_quoted_substitution_bodies recurse past Python's limit, so the
RecursionError aborted the turn before the permission request was answered.
_is_ssh_to_self now counts the readings open at once and refuses past 32.
Only text that names an ssh-family verb recurses, so a deep nest without one
is still allowed.

Fixes #37792

(cherry picked from commit 7505181)
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 16, 2026 10:42
@buluoray
buluoray requested review from dodgeblaster and removed request for a team November 16, 2026 10:42
@github-actions

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/argv_floor.py

  • src/kiro_crew/security/argv_floor_ssh.py

  • No reasoning template for 71318b1 yet.

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@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

UX Review (Opus 5.5) — ⏭️ skipped

Revision 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b 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 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. This is a clean cherry-pick of a reviewed fix. Once 32 readings are open, the check refuses the command instead of raising RecursionError, and it takes nothing away from commands nested less deeply.

[DESIGN-REVIEWED] 71318b1

Description read

[DESCRIPTION-READ] dcc7f00d2866e221848c0275c954c8b79c381a505536a4111a1b46c8594680dd

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

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b — 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

A clean cherry-pick of #37820. It turns a RecursionError that aborts the turn into a refusal, at the recursion's own entry point. The wider depth cap is named in ## Not a goal and deferred to #37875.

What this change ships

Inventory (4 items) — 4 justified

Intent: Get the fix to 0.13 users, so a crafted, deeply nested command no longer aborts a turn before its permission request is answered. This is a FIX (backport).

  1. In the ssh-to-self floor, a command whose $( )/function/value readings nest more than 32 deep and that names an ssh-family verb is now refused instead of crashing the turn — justified
  2. A deep nest that names no ssh verb is still allowed — justified
  3. The facade's type-checking manifest now names the three new names (_MAX_SSH_READING_DEPTH, _bounded_ssh_reading, _ssh_reading_depth) — justified
  4. A new security line-budget row, ssh-self-reading-depth.txt (+33) — justified

[FIRST-PRINCIPLES-REVIEWED] 71318b1

Description read

[DESCRIPTION-READ] c43ab96b346597bebc397eed532df6e5e1c2b2bfb5eddd97d358b1155880f935

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 71318b1

Verdict parsed from the review's SHA-scoped output markers for commit 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b 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 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 71318b1

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

@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 71318b14dfd46e9827e56f7ce5f11f21bf9fb60b 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): 15 classified, 0 newly refused, 4 still allowed.
  • ubuntu-latest (platform posix): 15 classified, 0 newly refused, 4 still allowed.
  • windows-latest (platform windows): 3 classified, 0 newly refused, 0 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The change caps how deeply _is_ssh_to_self can nest its readings, and it refuses only once 32 readings are open at the same time. The depth comes from a context variable that is put back in finally, so sibling readings never add up, and a deep nest with no ssh verb is still allowed. Ordinary ssh, scp, sftp and rsync use stays far under 32 levels, and I found no legitimate operation that comes close.

TIGHTENING: _bounded_ssh_reading decorator on _is_ssh_to_self (src/kiro_crew/security/argv_floor_ssh.py) -- it refuses a crafted command that nests double-quoted $( ) bodies, bound function bodies or carried values past Python's recursion limit (the RecursionError that aborted the turn in #37792): if depth >= _MAX_SSH_READING_DEPTH: return True, with _MAX_SSH_READING_DEPTH = 32.

ADJUDICATED: 18 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix: ssh, scp, sftp and rsync to remote hosts, plus -e, RSYNC_RSH, ProxyCommand and -L forwards. It also covers a helper function that wraps ssh, a host carried in a variable, and 2-level and 4-level double-quoted $( ) nests that name ssh. A 6-level nest with no ssh verb and a commit message that names ssh round it out. Together these exercise each place the new bound wraps: substitution bodies, bound function bodies, carried values, and the proxycommand and rsh value re-reads. windows: ssh.exe and scp.exe rows with a drive-letter source, \ separators and a %USERPROFILE% key path. The diff itself assumes nothing about paths, separators or executable names, since the bound counts only nesting depth. These rows just confirm the counter does not reach Windows spellings. I wrote no any rows, because every row names an executable.

UNADJUDICATED: The bound is shared through a ContextVar, which is not a gate of its own, and every way into it goes through the shell deny composite, so the rows above adjudicate the change in full. One boundary cannot go in as a row: a legitimate generated command with 32 or more nested readings that names an ssh verb. That would be machine-written nesting 32 levels deep, and I found nobody who runs such a command, so I proposed no row for it.

[SCOPE-REVIEWED] 71318b1

@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
@buluoray
buluoray merged commit 75724ec into release/0.13.0 Nov 16, 2026
150 of 152 checks passed
@buluoray
buluoray deleted the crew/slack/backport-0.13.0-37820 branch November 16, 2026 11:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants