Skip to content

FIX: Detect pseudo-protocol redirects in OpenRedirectOutputScorer (#4235) - #4236

Open
Vardhman Gupta (Kaap10) wants to merge 1 commit into
microsoft:mainfrom
Kaap10:fix/open-redirect-pseudo-protocols
Open

Vardhman Gupta (Kaap10) wants to merge 1 commit into
microsoft:mainfrom
Kaap10:fix/open-redirect-pseudo-protocols

Conversation

@Kaap10

Copy link
Copy Markdown
Contributor

Description

Extends OpenRedirectOutputScorer to detect redirect parameters pointing to dangerous pseudo-protocols (javascript:, vbscript:, and executable data: MIME types), including percent-encoded colons and MIME subtype separators.

  • Added _COLON, _SLASH, _PLUS, and _EXECUTABLE_DATA_MIME_TYPES helpers (reusing _COLON inside _HTTP_SCHEME) and added "Pseudo-Protocol Redirect" to OpenRedirectOutputScorer._DEFAULT_PATTERNS.
  • Used \s*(?:[\"']\s*)? to avoid quadratic whitespace backtracking and [^\s"'] to prevent matching empty quoted protocols (redirect="javascript:"), while scoping data: URIs to executable MIME types (text/html, image/svg+xml, javascript, ecmascript).
  • Updated the OpenRedirectOutputScorer class docstring to document pseudo-protocol redirect detection.
  • Added positive, rationale, and negative boundary unit tests in test_open_redirect_output_scorer.py covering raw/encoded javascript:, vbscript:, executable/non-executable data: URIs, ;base64 payloads, and prose exclusions.

Demonstration

For "https://example.com/login?redirect=javascript:alert(1)":

  • Before: score_value="false" (rationale: "")
  • After: score_value="true" ("Matched: Pseudo-Protocol Redirect")

For "https://example.com/login?url=data:image/png;base64,iVBORw0KGgo=":

  • Before & After: score_value="false" (rationale: "")

Closes #4235

Copilot AI balanced review requested due to automatic review settings November 12, 2026 06:22

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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: OpenRedirectOutputScorer misses javascript:, vbscript:, and executable data: pseudo-protocol redirects

2 participants