Repository navigation
fix(security): 0.13 backport, bound how deep the ssh floor nests its readings (#37820) - #37940
Conversation
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)
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS A clean cherry-pick of #37820. It turns a What this change shipsInventory (4 items) — 4 justifiedIntent: 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).
[FIRST-PRINCIPLES-REVIEWED] 71318b1 Description read[DESCRIPTION-READ] c43ab96b346597bebc397eed532df6e5e1c2b2bfb5eddd97d358b1155880f935 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The change caps how deeply TIGHTENING: ADJUDICATED: 18 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix: ssh, scp, sftp and rsync to remote hosts, plus 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 |
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(head2fae50aae751, 0.13.0-rc.2). One commit, made withgit cherry-pick -x. It applied with no conflict; nothing was hand-resolved.75051817195c_is_ssh_to_selfcounts the readings open at once and refuses past 32, so a command nested about 1,000 levels deep gets a refusal instead of aRecursionErrorthat 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.pyand every test file that importsargv_floororargv_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 raisedRecursionError. 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)