Repository navigation
Description
Goal
A glob read of renamed private SSH keys is rated red data risk even when the glob word is glued to a redirect or wrapped in a backtick substitution, the same as the plain form.
Context
Follow-up of #1564 (PR #1580): the review noticed that cat ~/.ssh/backup_id_*>/tmp/x and a glob inside backtick substitution get no red data-risk label, although the concrete names (backup_id_rsa) do. The secret-path check still escalates the confirmation, so this is a missing label, not a missing confirmation.
Current behaviour on develop: glob_reads_private_key (crates/core/src/risk/classifier.rs:1006) splits the segment with split_whitespace() and trims only ", ' and ) from each word (line 1019). A word like ~/.ssh/backup_id_*>/tmp/x therefore keeps the > and the redirect target, so the last path part is x and the glob is not seen. A word starting with a backtick (`cat ~/.ssh/id_*`) keeps the trailing backtick in the glob. Spec 0026 §2 describes the glob rule.
Requirements
- In
glob_reads_private_key, cut each word at an unquoted redirect operator (<,>) and strip a surrounding backtick, so the glob part is judged on its own. - Keep the near misses non-red:
*,*.pub,known_*,rapid_*,bid_*,i*,*id*. - No change to the secret-path check.
Acceptance Criteria
-
cat ~/.ssh/backup_id_*>/tmp/xandcat ~/.ssh/id_*>>/tmp/xhave data risk Red. -
echo `cat ~/.ssh/backup_id_*`has data risk Red. -
cat ~/.ssh/*.pub>/tmp/xandcat ~/.ssh/known_*>/tmp/xstay non-Red. - The new tests fail on the current code and pass with the change (regression proof).
- Relevant automated tests pass (
cargo test -p ssh-manager-core risk).
Technical Notes
Security-critical module (crates/core/src/risk/): only adds Red, never lowers a rating. Add adversarial cases next to the existing #1564 tests. Check whether Spec 0026 §2 needs a word on these forms. Changelog fragment per changelog.d/README.md.
Files: crates/core/src/risk/classifier.rs, crates/core/src/risk/tests_ssh_key_names.rs, docs/specs/0026-command-risk-indicators.md, changelog.d
Spec impact: none
Open questions
- Reuse the shell word tokenizer already used for the secret-path check (
classifier.rs:~781) instead of patching the trim. Recommendation: reuse it if it exposes the glob words, otherwise patch the trim; either way the acceptance criteria are the same.
Related Work
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(core): rate glob key reads red with glued redirect or backticks (#…
smart-ssh-coder commentedon Nov 25, 2026
Implementation ready for review. PR #1594. Glob key-read rule now cuts words at unquoted redirects and trims backticks; new tests (fail without the fix) cover glued redirects, backticks and near misses. CI green on PR #1594.
smart-ssh-reviewer commentedon Nov 25, 2026
Review: 1. Loosening in crates/core/src/risk/classifier.rs (cut_at_redirect, used at :1019): only the part before the first unquoted '<'/'>' is kept, so a word starting with an input redirect becomes empty.
cat <~/.ssh/backup_id_*,cat <~/.ssh/id_*andcat 0<~/.ssh/backup_id_*were data risk Red on develop and are None with this PR. The issue requires only adding Red, never lowering a rating. Also judge the part after an unquoted '<' (e.g. check every non-empty part split at redirect operators) and add these inputs as Red test cases.fix(risk): judge every part around redirect operators for key globs (#…
smart-ssh-coder commentedon Nov 25, 2026
Implementation ready for review. PR #1594. Fixed the review point: key-glob detection now splits each word at every unquoted redirect operator and judges all parts, so input-redirect forms (<
/.ssh/id_*, 0</.ssh/backup_id_*) are Red again. Tests added; CI green.smart-ssh-reviewer commentedon Nov 25, 2026
Review passed – moving on to merge. Approved. The input-redirect loosening from the previous round is fixed in d16f984: every part around an unquoted redirect is now checked, and
cat <~/.ssh/backup_id_*,cat <~/.ssh/id_*andcat 0<~/.ssh/backup_id_*are Red again, with tests. The counter-proof (test red against the previous commit, green now) and a probe against develop found no real key read that lost Red. Risk tests pass locally (149 passed). CI is green. Spec 0026 §2 already covers the rule.fix(core): rate glob key reads red with glued redirect or backticks (#…
smart-ssh-coordinator commentedon Nov 25, 2026
Merged and branch deleted: PR #1594 (squash) in develop