Skip to the content.

CodeQL regex alerts (2026-10)

The public mirror runs CodeQL; this repository does not. The first sync with all workspace packages raised 12 alerts. Each was checked here by timing the original regex on CodeQL’s attack shape at the input limit the code actually enforces.

Real: fixed

Code Limit Before Fix
SAFE_IMAGE (core/web/shared/preferences/document.ts) 600 characters 200 chars: > 20 s Drop the repeated , name(…) group
SVG sniff (packages/image/src/sanitize-format.ts) first 1 KiB 256 bytes: > 20 s (<!--…-->\s*)* → (<!--…-->\s*)?
PDF stream blanking (packages/image/src/sanitize-scan.ts) 10 MiB upload cap 1 MB: 10.6 s indexOf loop instead of a lazy regex

The two regex fixes accept exactly the same strings: one lazy or [^;{}<>]* span already reaches across what the repeated group matched, so the repetition only added backtracking. A fuzz run of 300,000 random inputs per pattern found no difference against the originals, and the PDF loop returns the same output. Regression tests: core/web/tests/background-options.spec.ts and packages/image/tests/sanitize-backtracking.spec.ts.

Bounded or false positive: unchanged

Rule of thumb

Before rewriting a flagged regex, time it at the real input limit. If the repeated group can be absorbed by a neighbouring * span, drop the repetition; otherwise replace it with a linear scan.