Executive brief
xmldom is an XML/HTML parser library used by many JavaScript applications. When parsing HTML with raw-text elements (script, style, textarea, title tags), the parser fails to handle closing tags that use different case from the opening tag (e.g., `</ScRiPt>` for `<script>`). This causes the output to grow quadratically—a small input of tens of kilobytes can produce output in the tens or hundreds of megabytes, exhausting memory and CPU and causing service outages.
Technical details
The vulnerability is a combination of improper case-sensitive matching and unguarded array index handling in the `parseHtmlSpecialContent` function (lib/sax.js). The parser searches for closing tags using a case-sensitive `indexOf` operation, contrary to the WHATWG HTML specification which requires case-insensitive matching for raw-text element end tags. When a mixed-case closing tag is encountered (e.g., `</ScRiPt>` instead of `</script>`), the search fails and returns -1. The code then calls `source.substring(elStartEnd + 1, -1)`, which extracts text backwards from the document start instead of the element's content. The function returns -1 to the parse loop, which cannot advance normally and falls back to character-by-character reprocessing. This causes every raw-text element to re-capture all preceding source text, resulting in O(n²) output growth. An attacker can craft HTML with multiple case-mismatched raw-text elements to force disproportionate resource consumption. The fix (applied in version 0.9.12) implements case-insensitive matching per the HTML specification and properly handles missing closing tags. Only 0.9.x versions (0.9.0-beta.1 through 0.9.11) are affected; 0.8.x is unaffected.
Affected products
- xmldom xmldom >=0.9.0-beta.1, <=0.9.11
Timeline
- 2026-09-08: disclosed: Published to GitHub Advisory Database
- 2026-09-01: advisory: Published to NVD
- 2026-09-08: patched: Patch released in version 0.9.12
References
- https://api.github.com/users/KarimTantawey
- https://github.com/KarimTantawey
- https://api.github.com/users/KarimTantawey/gists%7B/gist_id%7D
- https://api.github.com/users/KarimTantawey/repos
- https://avatars.githubusercontent.com/u/111700861?v=4
- https://api.github.com/users/KarimTantawey/events%7B/privacy%7D