Skip to content

FIX: Detect encoded path traversal to sensitive files - #3326

Merged
Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
pasmud:fix/encoded-path-traversal-scoring
Oct 20, 2026
Merged

Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
pasmud:fix/encoded-path-traversal-scoring

Conversation

@pasmud

@pasmud Merge_Conflict - Pasi (pasmud) commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

PathTraversalOutputScorer missed paths with URL-encoded traversal dots or separators, even when they led to a sensitive file. It also missed .ssh/id_rsa, .aws/credentials, and .env targets. The default pattern now recognizes literal, URL-encoded, and double URL-encoded traversal segments and separators while still requiring at least two parent segments and a known-sensitive target.

Sensitive filenames must be complete, so .ssh/id_rsa.pub, .aws/credentials.example, and encoded suffixes do not match. A period ending a sentence still allows detection of a path such as ../../etc/passwd.. The existing directory-prefix behavior for windows/system32 and proc/self remains. Custom pattern overrides continue to see the original text.

Related to #3324

Tests and Documentation

  • uv run --frozen -m pytest tests/unit/score/regex -q: 865 passed.
  • uv run --frozen ruff check pyrit/score/true_false/regex/path_traversal_output_scorer.py tests/unit/score/regex/test_path_traversal_output_scorer.py: passed.
  • uv run --frozen ruff format --check pyrit/score/true_false/regex/path_traversal_output_scorer.py tests/unit/score/regex/test_path_traversal_output_scorer.py: both files formatted.
  • uv run --frozen ty check pyrit/score/true_false/regex/path_traversal_output_scorer.py: passed.
  • Updated the scorer docstring. JupyText was not run because no notebooks changed in this PR.

@pasmud
Merge_Conflict - Pasi (pasmud) force-pushed the fix/encoded-path-traversal-scoring branch from 9de4fc6 to 7ad954d Compare October 19, 2026 10:04
@pasmud

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@pasmud
Merge_Conflict - Pasi (pasmud) force-pushed the fix/encoded-path-traversal-scoring branch from 7ad954d to 4bb6dcc Compare October 19, 2026 22:33
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f544d42c-f6a5-4964-823d-2715d94ae0c9
Allow a period before whitespace or the end of model output without accepting literal or encoded filename extensions. Add public scoring regressions for sensitive targets and URL encoding variants.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f544d42c-f6a5-4964-823d-2715d94ae0c9
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.

2 participants