Skip to content

FEAT: Expand XSSOutputScorer to detect SVG and JavaScript data URIs - #3400

Open
Vardhman Gupta (Kaap10) wants to merge 1 commit into
microsoft:mainfrom
Kaap10:fix/xss-output-scorer-data-uris
Open

Vardhman Gupta (Kaap10) wants to merge 1 commit into
microsoft:mainfrom
Kaap10:fix/xss-output-scorer-data-uris

Conversation

@Kaap10

Copy link
Copy Markdown
Contributor

Description

Closes #3399

Expands data URI detection in XSSOutputScorer beyond text/html to cover executable and scriptable MIME types:

  • SVG Data URIs (image/svg+xml): Detects SVG data URIs carrying executable markup across HTML tags (<img src="...">, <object data="...">, <embed src="...">), markdown image syntax (![alt](data:image/svg+xml,...)), and raw payloads.
  • JavaScript Data URIs (text/javascript, application/javascript, application/x-javascript, text/ecmascript): Detects script-bearing data URIs across <script src="...">, markdown links, form actions (action, formaction), and bare URIs.
  • Boundary Safeguards: Uses trailing boundary (?![A-Za-z0-9+_-]) to avoid false positives on non-standard/unrelated MIME subtypes (e.g. data:image/svg+xml-fake).

Tests and Documentation

  • Added parameterized unit test test_xss_executable_data_uris_detected covering 13 test cases across raw SVG, Base64 SVG, markdown image syntax, object data, <script src=...>, JavaScript MIME variants, markdown links, and form actions.
  • Expanded test_xss_not_detected with negative controls for benign data URIs (PNG, JPEG, JSON, text/plain, audio/mp3, and fake extensions).
  • Added score rationale assertions verifying attribution to "Data URI with Executable Content" and "Bare Data URI with Executable Content".
  • Ran unit tests and linters: all 102 XSS & web injection tests and 988 regex scorer tests pass; ruff check and format pass.

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: XSSOutputScorer misses SVG and JavaScript data URIs

1 participant