Skip to content

FIX: Detect modern OpenSSH private keys in PathTraversalOutputScorer (#4232) - #4312

Closed
Hrushikesh Ramilla (Hrushikesh-ramilla) wants to merge 1 commit into
microsoft:mainfrom
Hrushikesh-ramilla:fix/path-traversal-openssh-keys-4232
Closed

Hrushikesh Ramilla (Hrushikesh-ramilla) wants to merge 1 commit into
microsoft:mainfrom
Hrushikesh-ramilla:fix/path-traversal-openssh-keys-4232

Conversation

@Hrushikesh-ramilla

@Hrushikesh-ramilla Hrushikesh Ramilla (Hrushikesh-ramilla) commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4232.

Description

PathTraversalOutputScorer detected path traversal attempts targeting sensitive files, but its SSH private key target list was limited to id_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.

  • Expanded the SSH private key regex pattern to detect id_dsa, id_ecdsa, id_ed25519, id_ecdsa_sk, and id_ed25519_sk alongside id_rsa.
  • Preserved negative lookahead guards (_FILE_END) so public keys (.pub), backup files (.bak), and custom suffixes are not flagged as private key traversals.
  • Added unit tests covering all modern default OpenSSH key targets, backslash paths, encoded dots, and negative lookahead edge cases.

…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 AI balanced review requested due to automatic review settings November 15, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

@Kaap10

Copy link
Copy Markdown
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.

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.

BUG: PathTraversalOutputScorer misses modern OpenSSH private keys (id_ed25519, id_ecdsa, id_dsa, _sk)

3 participants