Executive brief
@xmldom/xmldom is a popular XML parsing library used to read and process XML documents in Node.js applications. The library contains a regular expression vulnerability that causes the parser to consume excessive CPU time when processing maliciously crafted XML with unterminated processing instructions. An attacker can send a single small XML document to a server to stall the Node.js event loop for multiple seconds, causing denial of service and preventing the server from handling legitimate requests.
Technical details
The vulnerability is a ReDoS (Regular Expression Denial of Service) affecting the PI (processing instruction) production in lib/grammar.js. The regex pattern uses both a greedy separator (S+) and a lazy quantifier (Char*?) that can both match XML whitespace. When parsing an unterminated processing instruction (missing the closing `?>`), the regex engine must try every partition of the whitespace between these two quantifiers before ultimately failing, resulting in O(n²) time complexity. The regex is invoked in parsePI() and parseProcessingInstruction() functions in lib/sax.js, executing against the entire remaining source string. Only versions 0.9.0-beta.9 through 0.9.10 are affected; versions 0.8.x and earlier use a different bounded PI parsing approach. The fix in 0.9.11 inserts a fixed-width negative lookahead (?!\\s) after the greedy S+ to prevent backtracking while maintaining correct behavior on valid XML.
Affected products
- xmldom @xmldom/xmldom 0.9.0-beta.9 through 0.9.10
Timeline
- 2026-08-12: disclosed
- 2026-09-08: patched: Fixed in version 0.9.11 via PR #1039
References
- https://github.com/xmldom/xmldom/security/advisories/GHSA-g53g-w8rj-fmg7
- https://github.com/xmldom/xmldom/pull/1039
- https://github.com/xmldom/xmldom/commit/73df6b8bdbd86f904b9e8c3ab9c49aa54ef2802e
- https://github.com/xmldom/xmldom/releases/tag/0.9.11
- https://api.github.com/repos/xmldom/xmldom/security-advisories/GHSA-g53g-w8rj-fmg7