GHSA-253c-mchw-3w2r: markdown-it linkify: true has two quadratic paths, so a few hundred KB of markdown blocks the event loop for tens of seconds
(updated )
Two independent quadratic paths in the linkify: true handling. Both are in markdown-it’s own code rather than in linkify-it, which stays linear on both payloads.
src/rules_core/linkify.ts calls arrayReplaceAt once per linkified text token, and that rebuilds the whole children array each time. A paragraph of N soft-broken lines is one inline token with about 2N children, so you get N rebuilds over a 2N array. Schema-less emails are what reach it. A http:// link gets consumed by the inline rule first and never arrives as a text token, so those stay linear.
src/rules_inline/linkify.ts runs state.pending.match(SCHEME_RE) at every :// in the source. state.pending only gets truncated once a link is actually produced, so an unregistered scheme leaves it growing and every :// rescans the lot.
References
- github.com/advisories/GHSA-253c-mchw-3w2r
- github.com/markdown-it/markdown-it/commit/09fa07118dda4c953f058848f53dae88395618ca
- github.com/markdown-it/markdown-it/commit/aaadcfa6d817b3c5f89afb49d97c7b797a6dd4fd
- github.com/markdown-it/markdown-it/commit/ad70f6b7cff64bee10e42a774147112480ca0d49
- github.com/markdown-it/markdown-it/security/advisories/GHSA-253c-mchw-3w2r
Code Behaviors & Features
Detect and mitigate GHSA-253c-mchw-3w2r with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →