Skip to content

FIX: Detect url/target params, double-encoded slashes, and backslash bypasses in OpenRedirectOutputScorer (#3324) - #3679

Merged
Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
Hrushikesh-ramilla:fix/open-redirect-payload-detection-3324
Nov 2, 2026
Merged

Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
Hrushikesh-ramilla:fix/open-redirect-payload-detection-3324

Conversation

@Hrushikesh-ramilla

Copy link
Copy Markdown
Contributor

Description

This PR addresses the open redirect payload detection gaps reported in #3324 for OpenRedirectOutputScorer (pyrit/score/true_false/regex/open_redirect_output_scorer.py):

  1. Common parameter names (url, target, return_to, etc.): The previous parameter regex required redirect, return_url, returnto, next, continue, dest, goto, callback, forward, or location. It did not match common redirect parameters such as url= (e.g., ?url=//attacker.example) or target= (e.g., target=//attacker.example), which are among the most frequent open redirect sink query parameters in web applications.
  2. Double URL-encoded slashes (%252f%252f / %252F%252F): Encoded Slash Redirect previously matched only single %2f%2f. It now detects double-encoded slashes (%252f%252f, %255c%255c, and mixed variants) commonly used to evade basic decode filters.
  3. Backslash protocol-relative bypasses: Browsers normalize /\, \/, and \\ into network paths when resolving protocol-relative URLs. Protocol-Relative Redirect Param now supports these slash and backslash variants ([/\\]{2,}) leading to host destinations.

Closes part of #3324.

Tests and Documentation

  • Updated unit tests in tests/unit/score/regex/test_open_redirect_output_scorer.py:
    • Added 27 new positive test cases covering url=, target=, return_to=, double-encoded %252f%252f / %255c, and backslash forms (/\, \/, \\).
    • Added 4 negative test cases to guard against false positives on standard query parameters and non-redirect paths.
    • Added 3 dedicated rationale assertions for double-encoded, backslash, and url= parameters.
  • Ran test suite: All 80 tests in test_open_redirect_output_scorer.py and all 1,241 tests in tests/unit/score/regex/ pass.
  • Verified linting and type checks (ruff check, ruff format, ty check pyrit).

@romanlutz Roman Lutz (romanlutz) 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.

making the fix myself

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Allow raw and encoded scheme colons before leading encoded separators without scanning into paths or other parameters. Cover case and mixed encoding variants through public scoring and SQLite persistence.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into microsoft:main with commit 61fc052 Nov 2, 2026
63 of 64 checks passed
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