Repository navigation
Conversation
Account for multiline and unknown flags in the shared whole-string anchoring check so generic and membership-based taint sanitizers agree. Add inline regression coverage for the reported command-injection and reflected-XSS cases, regex API variants, and class-validator decorators. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
DCA decreases analysis time, though I don't understand why. It's mostly in one repo. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Changes to shared regexp sanitizers can affect alerts across JavaScript security queries, so a maintainer should validate alert-count and performance impacts on real-world code before approval.
No open issues 🎉
What changed in this PR
Corrects JavaScript taint analysis so anchored regular expressions with multiline or unknown flags no longer incorrectly suppress security alerts.
Changes:
- Makes whole-string anchoring checks account for regular-expression flags.
- Adds regression tests for taint guards, security-query flows, and decorators, including documented limitations.
- Adds a change note describing the analysis improvement.
| File | Description |
|---|---|
javascript/ql/test/library-tests/RegExpSanitizer/test.ql |
Defines inline checks for taint flows and decorator sanitizers. |
javascript/ql/test/library-tests/RegExpSanitizer/test.expected |
Stores expected regression-test results. |
javascript/ql/test/library-tests/RegExpSanitizer/routes.js |
Adds command-injection and reflected-XSS regression cases. |
javascript/ql/test/library-tests/RegExpSanitizer/guards.js |
Covers flags, constructors, matching methods, and negative checks. |
javascript/ql/test/library-tests/RegExpSanitizer/decorators.ts |
Tests decorator sanitizers and documents a remaining limitation. |
javascript/ql/lib/semmle/javascript/Regexp.qll |
Rejects whole-string anchoring for multiline or unknown flags. |
javascript/ql/lib/change-notes/2026-10-22-multiline-regexp-sanitizer.md |
Documents the fix and its effect on alert detection. |
Review effort: Max (auto)
This branch has not been deployed
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.
Stop treating anchored regexps with multiline or unknown flags as whole-string sanitizers. Add regression tests, including documented limitations.
Fixes #22845.