Skip to content

JS: Fix multiline regexp sanitization - #22966

Open
owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:owen-mc/22845-multiline-regexp-sanitizer
Open

owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:owen-mc/22845-multiline-regexp-sanitizer

Conversation

@owen-mc

@owen-mc owen-mc commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Stop treating anchored regexps with multiline or unknown flags as whole-string sanitizers. Add regression tests, including documented limitations.

Fixes #22845.

owen-mc and others added 2 commits October 22, 2026 15:28
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>
@owen-mc

owen-mc commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

DCA decreases analysis time, though I don't understand why. It's mostly in one repo.

@owen-mc
owen-mc marked this pull request as ready for review November 2, 2026 18:48
@owen-mc
owen-mc requested a review from a team as a code owner November 2, 2026 18:48
@owen-mc
owen-mc requested review from a team and an auto review from Copilot November 2, 2026 18:48

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.

🔵 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS: Why does SanitizingRegExpTest treat /^...$/m as a whole-string check?

2 participants