Repository navigation
fix(security): read literal echo/printf substitutions as argv in the ssh floor - #23303
JLargent42 wants to merge 1 commit into
Conversation
Sensitive Change ReviewSensitive files changed:
|
Sensitive change review
|
|
Local pre-push review (hand-written charters; the brief extractor reported a parity failure, so this is approximate to CI).
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The full-output splice falls back to main's one-word reading whenever it can't model the output, so it only adds refusals and widens no allow. Notes
[DESIGN-REVIEWED] 137b45e Description read[DESCRIPTION-READ] 9936f59ec90587743f72be4468e60134325f4fc53ec13cfa9d7c73f78674d881 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 The fix fits gap 2 of #21345 closely. The only extra is three spec paragraphs about gaps 1, 3 and 4, which this PR leaves unchanged. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: stop an agent from reaching ssh to this host by hiding the command in the printed output of
[FIRST-PRINCIPLES-REVIEWED] 137b45e Description read[DESCRIPTION-READ] 826180eb844cd8ba8a47e0d64270f7499fb54481efd7bd334ab3224558fb3b9f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed The ssh self-target floor now splits a multi-word substitution's output on the default IFS. Base refused BLOCKING — src/kiro_crew/security/argv_floor_ssh.py:979 [BLOCK-MERGE] 137b45e 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_self.py:461 -- Printf newline normalization invents an argv boundary
[BLOCK-MERGE] 137b45e Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (LOW harm). The bug is confirmed, but the fix is small and the bad code is new in this PR. 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)
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 change makes the ssh self-target floor read a literal TIGHTENING: ssh self-target argv floor ( ADJUDICATED: 19 candidates, 0 confirmed newly-refused PLATFORM COVERAGE:
[SCOPE-REVIEWED] 137b45e The confirmed rows, in the committed corpus's own shape{
"golden_paths": [
{
"kind": "shell",
"command_or_flow": "$(echo ssh build.example.com uptime)",
"platform": "posix",
"reason": "One token off the attack: an operator script builds the ssh line from a literal and runs it against the remote build host to check load before a deploy; only the host differs from the refused self-target shape."
},
{
"kind": "shell",
"command_or_flow": "$(echo ssh deploy@build.example.com systemctl status kiro-crew)",
"platform": "posix",
"reason": "A maintainer's status query on the remote runner built from a literal echo; a far host with a user@ prefix, multi-word output now spliced as argv."
},
{
"kind": "shell",
"command_or_flow": "rsync $(echo dist/ build.example.com:/srv/app/)",
"platform": "posix",
"reason": "A deploy step pushes the built dist directory to the remote app host with the src/dest pair from a literal; multi-word splice into rsync's any-position target walk."
},
{
"kind": "shell",
"command_or_flow": "logger -t kiro $(echo rsync localhost mirror finished)",
"platform": "posix",
"reason": "A cron-run mirror script logs completion to syslog with an unquoted literal message; logger is the program, the ssh-family words are message data."
},
{
"kind": "shell",
"command_or_flow": "$(echo ssh.exe build.example.com uptime)",
"platform": "windows",
"reason": "The Windows spelling of the program-position splice: a PowerShell helper composes the OpenSSH client line for the remote build host; must stay allowed as the posix row does."
}
]
} |
0a500a8 to
9b58139
Compare
Sensitive change review
|
|
9b58139 to
9361179
Compare
|
Sensitive change review
|
|
|
9361179 to
ac72e4a
Compare
|
Sensitive change review
|
|
Disposition for the confirmed rows on
|
|
Fixed the second of two GPT findings on
Fixed in head |
Sensitive change review
|
|
Simplification pass on this head (617cfb2): the shared shell reader's three new pattern constants are replaced with string and set checks, the two glued-separator scans share one predicate, and a named-descriptor check the literal-word check already covered is removed. Source is 3 lines shorter and the package budget drops to 32,793. Old and new helpers agree on 400,000 random ASCII words; the targeted floor suites pass. No rule changed, and the open review findings on the prior head are unchanged by this commit. |
617cfb2 to
8b8a6d1
Compare
Sensitive change review
|
|
Disposition for GPT F1 on
|
|
Disposition for GPT F2 on
|
|
Disposition for the Opus glued-separator findings (rounds on
|
8b8a6d1 to
6f1a06b
Compare
|
Fixed the blocking finding on
|
|
Fixed GPT F2 in head
|
Sensitive change review
|
…ssh floor The ssh self-target floor splices a literal `$(echo ...)` / `printf` substitution back into the command text, so a substitution in program position reads as the argv the shell builds from it. `_static_substitution_words` returns every word the substitution prints: `echo` with its -n/-e/-E options consumed, or `printf` with one format operand and no `%` conversion. Like the shell, it strips only trailing newlines. It returns None for anything else, and the existing one-word reader applies. Output carrying quoting, operators, expansions or comments is never re-spliced. A line where any such output holds a word starting with `-` is not spliced as a line. The whole command keeps the one-word reading, so no option word reaches the walk from a substitution. Glued redirections and separators in the self-protection floor (gap 1) are deferred to #23351 with the shared tokenizer work; the spec records that. The package line budget is recomputed to 32,721.
6f1a06b to
137b45e
Compare
|
Fixed the blocking finding on
|
Sensitive change review
|
|
Disposition for the blocking Opus finding on
|
|
Disposition for the blocking GPT finding on
|
|
Closing this PR. All of its remaining work moves to #23351. Gap 1 (glued redirects) was already deferred to #23351. The only thing left here was gap 2, the static-substitution splice in the ssh floor. Four review rounds in a row found a new bypass in that splice, each a different shell edge: dash-word options, option values, IFS splitting and printf newline handling. Patching each edge as it's found isn't converging, so the splice is better rebuilt once, on the shell tokenizer planned in #23351. Everything this PR covered, plus every reviewer finding from the GPT and Opus rounds, is recorded on #23351, so nothing is lost. Main's behaviour is unchanged. |
Problem / Motivation
Goal: The ssh self-target floor reads the literal output of an
echo/printfsubstitution as the argv it becomes.#21345 records four gaps in the reader in
src/kiro_crew/security/that the self-protection, git-publish,sandbox-escape-ssh-selfand network-exposure floors share:kirocrew restart>/tmp/log) was read so that the verb was dropped.$(echo …)in program position was not read as the argv it becomes, for the ssh-self floor.time grep …,sudo grep …) and ofgit grepwere read as invocations, so ordinary searches were refused.git commit -m "$(cat <<'EOF' … EOF)"was refused.This PR ships gap 2 only. Gaps 1, 3 and 4 are deferred to #23351 (see Not a goal).
Why it matters
Gap 2 lets a command shape through that the ssh-self floor exists to refuse.
Not a goal
shlexwithpunctuation_chars), which is security: let a quoted heredoc body through the shell-reader floors (deferred gap 4 of #21345) #23351's parser work. Each per-shape guard tried here met a further glued shape in review; those shapes are recorded on security: let a quoted heredoc body through the shell-reader floors (deferred gap 4 of #21345) #23351. The self-protection floor reads these tokens exactly as on main.git grep) is deferred to security: let a quoted heredoc body through the shell-reader floors (deferred gap 4 of #21345) #23351. It is over-refusal relief, and it needs the same parser. Its review constraints are recorded on security: let a quoted heredoc body through the shell-reader floors (deferred gap 4 of #21345) #23351. A launcher search is still read as an invocation (fail-closed), exactly as on main.git grep -e git -e push origin main: the git-publish detector scans forgit…pushindependently of program position. That is a separate change to that detector.What changed (motivation → approach → change)
The ssh-self floor spliced a literal substitution back as its first printed word only, so
$(echo ssh localhost id)did not read as the command it runs._static_substitution_words(inargv_floor_self.py) rebuilds the whole output of a literal substitution:echowith its-n/-e/-Eoptions consumed, orprintfwith one format operand and no%conversion. Like the shell, it strips only trailing newlines. Anything else returns None, and the existing one-word reader_static_substitution_outputapplies as before.argv_floor_ssh.py) splices that output in, so a substitution in program position reads as the argv it expands to. A line where any such output holds a word starting with-is not spliced: the whole command keeps main's reading, so no option word reaches the floor's argv walk from a substitution.argv_floor.py,__init__.pyand_exports.pyre-export the new helper on the package facade. The security spec (docs/system-specs/modules/security.md) records that glued redirections, launcher searches and quoted heredoc bodies keep main's reading until #23351.Backwards compatibility
Compatible: gap 2 adds refusals for shapes the ssh-self floor already intends to refuse.
Removes nothing: no rule, row, config key or public function is removed.
Tests
test/test_denied_commands_security_ssh_self.py::TestSandboxEscapeSshSelf: literal substitution output naming this host is refused, and the same output naming another host stays allowed. Output that holds an option word is not spliced, and the shapes main refuses stay refused. A trailing space in the output still separates words. There is also a unit test of_static_substitution_words.test/test_security_gate_liveness.py: the package line budget is raised with its reason recorded beside it.Manual verification
N/A — unit coverage sufficient: every changed read is reached through
is_denied, the entry point the tool-call gate uses.Related Issues
Part of #21345
Sibling sweep
Swept: git grep -nE "_static_substitution_output|_splice_static_substitution" -- src/
Sibling: src/kiro_crew/security/argv_floor_self.py -- changed here
Sibling: src/kiro_crew/security/argv_floor_ssh.py -- changed here
Sibling: src/kiro_crew/security/rm_floor.py -- not affected -- reads its own segments; its gaps are in #21365
Pattern harvest
Rule candidate: review-prompt
Pattern: a security reader that narrows a refusal must fall back to the prior reading for every shape it does not fully model, with a guard test pairing each narrowed allow with the nearest shape that must stay refused
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)