Skip to content

Fix #713: bound spec_exposure ReDoS across remaining 17 vulnerable languages - #798

Merged
squid-protocol merged 1 commit into
mainfrom
fix/713-spec-exposure-redos-sweep
Jul 30, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/713-spec-exposure-redos-sweep

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #713. The spec_exposure signature's \[(?:\s*SPEC\s*-\s*\d+|spec|audit)[^\]]*\] shape (or close per-language variants) was copy-pasted across the majority of LANGUAGE_DEFINITIONS, and most copies still carried the unbounded [^\]]* immediately after the equally-unbounded \d+ — digits satisfy both character classes, so an unclosed [SPEC-11111... tag with no closing ] forces the engine to re-scan an ever-shrinking digit suffix at every possible split point, genuine O(n²) catastrophic backtracking.

The original issue found 28 languages carrying this bug. Re-audited the current state before touching anything — this exact class had already been fixed independently, one language at a time, across this epic (embedded_python, css, tcl, matlab, scheme, typescript, rust, c, cpp, csharp, groovy, shell, sqlite). Confirmed only 17 remain vulnerable: python, javascript, java, go, php, ruby, swift, kotlin, html, assembly, perl, dart, dockerfile, solidity, objective-c, yacc, m4.

Applied the same clamp already proven correct for the earlier fixes: bounded \d+ to \d{1,10} and [^\]]* to [^\]]{0,300}. Deliberately left each language's own extra alternatives (html's RFC|W3C|CERN|TBL, dockerfile's CVE-\d{4}-\d+, solidity's ERC-\d+|EIP-\d+, etc.) untouched beyond the specific adjacent-quantifier shape — not part of the vulnerability, not this issue's scope.

Test plan

  • New test: test_spec_exposure_adjacent_quantifier_redos_sweep — a single dedicated cross-language regression test parametrized over all 17 languages, rather than scattering 17 near-identical tests (the issue itself explicitly authorizes this as the cleaner alternative). Uses the scale-relative ratio methodology, not an absolute wall-clock threshold.
  • Full strict-parsing suite — 2508 passed
  • Full test suite — 3414 passed; 14 pre-existing, unrelated failures in test_security_auditor.py (missing xgboost in this environment, confirmed identical without this change)
  • ruff format --check / ruff_audit.py --ci — clean
  • Differential Scan (crucible_check.py, both venvs) — zero diff, confirmed legitimate rather than masking a problem: the corpus's only 18 real Specification Traceability Tag hits are all in cobol/agc_assembly, neither of which is among the 17 languages touched here (both were already correctly excluded as "not affected" by the original issue)

Co-Authored-By: Claude Sonnet 5 [email protected]

…nguages

The spec_exposure signature's `\[(?:\s*SPEC\s*-\s*\d+|spec|audit)[^\]]*\]`
shape (or close per-language variants) was copy-pasted across the
majority of LANGUAGE_DEFINITIONS, and most copies still carried the
unbounded `[^\]]*` immediately after the equally-unbounded `\d+` --
digits satisfy both character classes, so an unclosed "[SPEC-11111..."
tag with no closing "]" forces the engine to re-scan an ever-shrinking
digit suffix at every possible split point between the two quantifiers,
genuine O(n^2) catastrophic backtracking on a single crafted or
accidentally-malformed file.

The original issue found 28 languages carrying this bug. Re-audited the
current state before touching anything (this exact class had already
been fixed independently, one language at a time, across this epic --
embedded_python, css, tcl, matlab, scheme, typescript, rust, c, cpp,
csharp, groovy, shell, sqlite): confirmed only 17 remain vulnerable --
python, javascript, java, go, php, ruby, swift, kotlin, html, assembly,
perl, dart, dockerfile, solidity, objective-c, yacc, m4.

Applied the same clamp already proven correct for the earlier fixes:
bounded `\d+` to `\d{1,10}` and `[^\]]*` to `[^\]]{0,300}` -- generous
enough for any realistic spec/audit tag, only removing the
pathological-input hang. Deliberately left each language's own extra
alternatives (html's RFC/W3C/CERN/TBL, dockerfile's CVE-\d{4}-\d+,
solidity's ERC-\d+/EIP-\d+, etc.) untouched beyond the specific
adjacent-quantifier shape -- those aren't part of the vulnerability and
bounding them isn't this issue's scope.

New test: a single dedicated cross-language regression test
(parametrized over all 17 languages) rather than scattering 17
near-identical tests across each language's own already-large
strict-parsing section -- the issue itself explicitly authorizes this
as the cleaner alternative. Uses the scale-relative ratio methodology
(not an absolute wall-clock threshold, which is flaky across CI
hardware -- the exact failure mode already found and fixed for a
different spec_exposure test earlier in this epic) plus the shared
_best_of_timing() helper.

Verified: full strict-parsing suite (2508 passed), full test suite
(3414 passed; 14 pre-existing, unrelated failures in
test_security_auditor.py -- missing xgboost in this environment,
confirmed identical without this change), ruff format/lint clean.
Differential Scan (crucible_check.py, both venvs): zero diff, and
confirmed this is legitimate rather than masking a problem -- the
corpus's only 18 real Specification Traceability Tag hits are all in
cobol/agc_assembly, neither of which is among the 17 languages touched
here (both were already correctly excluded as "not affected" by the
original issue).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@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 62803bc into main Jul 30, 2026
38 of 39 checks passed
@squid-protocol
squid-protocol deleted the fix/713-spec-exposure-redos-sweep branch July 30, 2026 19:39
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.

spec_exposure's unbounded [^\]]* ReDoS is copy-pasted across 28 languages, including already-merged yacc

1 participant