Skip to content

fix(regex): resolve ReDoS timeout in typescript args extraction - #2156

Merged
squid-protocol merged 2 commits into
mainfrom
fix/typescript-redos-timeout
Aug 23, 2026
Merged

fix(regex): resolve ReDoS timeout in typescript args extraction#2156
squid-protocol merged 2 commits into
mainfrom
fix/typescript-redos-timeout

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What\nThis PR fixes a Regular Expression Denial of Service (ReDoS) vulnerability in the args extraction rule for TypeScript, which was causing the CI pipeline to timeout after 180 seconds.\n\n### Why\nThe args regex had an overlapping alternative in its nested parentheses matcher: \((?:[^()]|\([^()]*\)|\((?:[^()]|\([^()]*\))*\))*\). The middle alternative \([^()]*\) was fully subsumed by the third alternative, which matched up to depth 2. This created a classic ReDoS structure (A|B|C)* where B and C overlap, causing catastrophic backtracking on long inputs that ultimately fail to match.\n\n### How\nRemoved the redundant \([^()]*\) alternative from the three branches of the TypeScript args regex, converting it to \((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\). This maintains the exact same depth-3 matching capabilities while eliminating the exponential backtracking. Verified by running the TypeScript test suite.

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 7e2808c into main Aug 23, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/typescript-redos-timeout branch August 23, 2026 15:05
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.

1 participant