Repository navigation
fix(security): 0.13 backport, read a double-quoted $( ) as a command in ssh floor (#37443) - #37551
Conversation
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 No blocker: this is a conflict-free cherry-pick of a fix main already reviewed. It changes how the floor judges commands and removes no surface anyone reads. Notes
[DESIGN-REVIEWED] d9ab644 Description read[DESCRIPTION-READ] c21fac371063775a53bd884c92ac35d3189345ea5be7e85812a5001eb7f5d13a 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 This is a straight backport of reviewed #37443. It tightens the ssh-to-self floor for a sandbox-escape spelling, and the added denied-row tests are the defect's provenance. Notes
Inventory (4 items) — 4 justifiedIntent: give 0.13 users the main-branch ssh-floor fix for a command run from inside a double-quoted
[FIRST-PRINCIPLES-REVIEWED] d9ab644 Description read[DESCRIPTION-READ] 4538f21d0d33a8c59e3f92791fc3e1ae168b33b0935837e360a7004b89d61fa6 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 — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/security/argv_floor_ssh.py:1109 -- Nested substitutions crash the permission scan
[BLOCK-MERGE] d9ab644 Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (fenced): The harm is not unbounded. The crash happens before anything is approved, so it fails closed: the command never runs and no credential or ceiling is exposed. What I confirmed in the code:
🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
Replace False positive or not applicable? A repository writer can comment: |
Security Scope Review -- 🔴 BLOCK (blocking)Which legitimate operations does Verdict basis: a script-confirmed newly-refused operation. Security scope review -- adjudicated candidates
Newly refused (confirmed by the real classifier at both refs)
ssh -p 22 localhost id is now refused in double quotes
ssh -p 22 localhost id is now refused in double quotes
Each row above is an operation that the base ref ALLOWS and this change REFUSES. Narrow the rule at the tier named. Withdrawing a row is not the way to green: that is its own pull request, on its own merits. Scope-Verdict: PASS Reason: The new rule judges the body of a TIGHTENING: ssh-to-self argv floor ( ADJUDICATED: 27 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix (21 rows) and windows (6 rows). I wrote no
The windows rows cover PowerShell's double-quoted
One assumed spelling has no row. PowerShell escapes with a backtick, not a backslash, and the scanner reads every input with bash quoting. A command whose meaning depends on PowerShell escaping can only be classified under bash rules, so no row can test PowerShell's own reading. cmd.exe does not expand UNADJUDICATED: Two narrowing questions the rows probe but that no verdict confirms, and that prose can only argue:
[SCOPE-REVIEWED] d9ab644 The confirmed rows, in the committed corpus's own shape{
"golden_paths": [
{
"kind": "shell",
"command_or_flow": "git commit -m \"$(cat <<EOF\ndocs: ssh floor\n\nssh -p 22 localhost id is now refused in double quotes\nEOF\n)\"",
"platform": "posix",
"reason": "A maintainer's commit about this very floor, with an UNQUOTED heredoc tag: cat only prints the text, but the new cut keeps unquoted-tag text and reads it at the top level"
},
{
"kind": "shell",
"command_or_flow": "git commit -m \"$(cat <<'EOF' 2>/dev/null\nfix: ssh -p 22 localhost id refused\nEOF\n)\"",
"platform": "posix",
"reason": "A quoted-tag commit message whose cat also carries a stderr redirect; the new cut requires every redirect to be a heredoc and so keeps this text"
}
]
} |
|
MacFlackyGuard:
|
…37443) The ssh-to-self floor masks quoted separators and parens before it walks a command line, so it never saw a `$(` inside double quotes: `echo "$(ssh -p 22 <this host> id)"` and `x="$(...)"` slipped past the floor, although bash runs that substitution. The mask stays as it was, so the parent command's walk still reads the quoted word as one argument. The floor now also takes each double-quoted `$( )` body from the unmasked text, opened only by an unpaired `$` and ended at its own matching `)`, and judges it as a command line of its own. A quoted-tag heredoc that a bare `cat` only prints is cut from the body first, so a PR body passed through `"$(cat <<'EOF' ...)"` stays allowed. Closes #36904 (cherry picked from commit 87b11b5)
ce60e9c to
d9ab644
Compare
Problem / Motivation
Goal: Ship in 0.13 the ssh-floor fix that lets a KAS custom agent's auto-approved commands through when a double-quoted
$( )appears, part of the custom-agent auto-approve work users reported.Backport onto
release/0.13.0(headb45ee13fbcf). One commit, made withgit cherry-pick -x. It applied with no conflict; nothing was hand-resolved.87b11b5ef245$( )as a command, as the shell does, so the floor judges the command that really runs. Brings its own line-budget row (ssh-self-dquote-subst.txt,+69), equal to its net growth of the security package.No prerequisite is needed: #36903, the ssh-floor change it builds on, is already on
release/0.13.0.Why it matters
Users reported KAS custom agents whose auto-approved commands were refused or judged wrong. This is one of the main fixes for that work, so 0.13 should carry it.
Not a goal
What changed (motivation → approach → change)
Cherry-pick only. No hunk was hand-resolved and no line is new.
Backwards compatibility
Compatible. The pick behaves as it does on main, where it was reviewed. Nothing is removed.
Tests
Test changes come from the pick.
Release PRs get no backend test lanes on this branch yet, so the backend tests also ran locally on this head, one pytest process per batch of 20 files, no xdist: the 17 test files the pick touches or that import a module it changes, 2,149 passed, 0 failed.
test_security_gate_liveness.pypasses with the cap equal to the measured package size. 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
Backport of #37443.
Sibling sweep
Siblings: none -- the backport touches the same sites #37443 changed on main
Pattern harvest
Not generalizable: backport of an already-reviewed fix (#37443)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.