Repository navigation
FIX: Detect modern OpenSSH private keys in PathTraversalOutputScorer (#4232) - #4312
Closed
Hrushikesh Ramilla (Hrushikesh-ramilla) wants to merge 1 commit into
Conversation
…icrosoft#4232) Update PathTraversalOutputScorer pattern to detect default OpenSSH private key filenames (id_dsa, id_ecdsa, id_ed25519, id_ecdsa_sk, id_ed25519_sk) alongside id_rsa, while preserving negative lookahead guards against public keys (.pub), backups (.bak), and custom suffixes. Signed-off-by: hrushikeshramilla <ramillahrushikesh@gmail.com>
Copilot started reviewing on behalf of
Hrushikesh Ramilla (Hrushikesh-ramilla)
November 15, 2026 10:07
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the expanded SSH private-key traversal detection.
No open issues 🎉
What changed in this PR
Updates PathTraversalOutputScorer to detect traversal attempts targeting additional default OpenSSH private keys, addressing #4232 while preserving exclusions for public keys, backups, and custom filename suffixes.
Changes:
- Expands SSH key matching beyond RSA to DSA, ECDSA, Ed25519, and hardware-backed ECDSA/Ed25519 keys.
- Adds positive and negative tests covering the new key names, backslash paths, encoded dots, and filename boundaries.
| File | Description |
|---|---|
tests/unit/score/regex/test_path_traversal_output_scorer.py |
Adds detection and suffix-exclusion regression cases. |
pyrit/score/true_false/regex/path_traversal_output_scorer.py |
Expands the default SSH private-key regex while retaining filename guards. |
Review effort: Balanced
Contributor
|
Hrushikesh Ramilla (@Hrushikesh-ramilla) Heads up that PR #4233 addressing #4232 was already opened on Nov 12 and is currently in review. Please close this PR to avoid duplicate work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4232.
Description
PathTraversalOutputScorerdetected path traversal attempts targeting sensitive files, but its SSH private key target list was limited toid_rsa. Modern environments widely use Ed25519 (id_ed25519), ECDSA (id_ecdsa), legacy DSA (id_dsa), and hardware-backed keys (id_ed25519_sk,id_ecdsa_sk), allowing path traversals targeting these keys to bypass the scorer.id_dsa,id_ecdsa,id_ed25519,id_ecdsa_sk, andid_ed25519_skalongsideid_rsa._FILE_END) so public keys (.pub), backup files (.bak), and custom suffixes are not flagged as private key traversals.