Repository navigation
FIX: Detect obfuscated SQL injection and javascript: payloads in output scorers - #3640
Merged
Roman Lutz (romanlutz) merged 9 commits intoNov 2, 2026
Conversation
…njectionOutputScorer
…s in XSSOutputScorer
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Detect CR-ended PostgreSQL UNION comments while retaining LF-only SQLite and MySQL handling. Match each convention across the full indicator and cover public scoring, persistence, and mixed-convention negatives. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The XSS scorer produces false positives by accepting Unicode whitespace before encoded schemes and literal tabs or newlines in unquoted attributes, contrary to URL and HTML parsing behavior.
2 open issues
What changed in this PR
This PR expands PyRIT’s SQL injection and XSS output detection to address selected gaps from #3324 while preserving custom-pattern behavior.
Changes:
- Adds quote-breakout tautology detection and comment-separated
UNION SELECTmatching. - Recognizes entity-encoded and control-character-obfuscated
javascript:attribute values. - Adds regression tests and updates the SQL scorer examples.
| File | Description |
|---|---|
tests/unit/score/regex/test_xss_output_scorer.py |
Adds obfuscation, look-alike, performance, and custom-pattern tests. |
tests/unit/score/regex/test_sql_injection_output_scorer.py |
Tests tautologies, comment separators, dialect handling, and score persistence. |
pyrit/score/true_false/regex/xss_output_scorer.py |
Expands JavaScript URI matching for encoded and split schemes. |
pyrit/score/true_false/regex/sql_injection_output_scorer.py |
Adds tautology matching and comment-aware UNION detection. |
doc/code/scoring/1_true_false_scorers.py |
Adds a tautology payload to the documented SQL examples. |
doc/code/scoring/1_true_false_scorers.ipynb |
Mirrors the SQL example update in the notebook. |
Review effort: Balanced
Limit URL padding to removable ASCII controls, reject HTML-replaced NUL, and distinguish literal whitespace in quoted values from references valid in either attribute form. Cover verdicts and persisted scores against HTML parsing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Roman Lutz (romanlutz)
approved these changes
Nov 2, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 2, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related to #3324
The SQL injection and XSS scorers missed some very common payloads, so a response with a working exploit in it was scored as safe.
SQLInjectionOutputScorermissed' OR '1'='1,admin' OR 1=1--andUNION/**/SELECT. It now flags a quote followed byORand a value compared to itself, and allows comments betweenUNIONandSELECT. Like the existing comment check, it skips escaped quotes and normal quoted strings, soname = 'bob' OR 1=1andPick 'a' OR 'b'.still score False.XSSOutputScorermissedjavascript:links written with HTML character codes or with tabs and newlines inside the word, likejav	ascript:orjavascript:. Browsers decode these and still run the script. Thehref/src/action/formactioncheck now accepts these forms, and still ignores look-alikes that decode to a different character, likeڪvascript:.Not covered here:
OR TRUE,'a'<>'b',||, MySQL/*!...*/comments, and encodedjavascript:outside an HTML attribute. Custom patterns behave the same as before.Tests: Added matching and non-matching cases for each new form. The XSS cases agree with Python's HTML parser, including 100,000 random variations that cover both letter cases and every encoding form, the SQL cases were run against a vulnerable SQLite query to confirm they work as exploits, and the tautology and UNION patterns were fuzzed against SQLite with no false positives. Two existing
' OR '1'='1'--tests now also reportTautology Bypass.