Sep 8, 2026·6 min read·60 visits
Unauthenticated Denial of Service via quadratic output amplification triggered by parsing HTML with case-mismatched closing raw-text tags in xmldom.
A Denial of Service (DoS) vulnerability exists in the xmldom library when parsing HTML-mode documents with mixed-case closing tags for raw-text or escapable raw-text elements like script, style, textarea, or title. This leads to algorithmic complexity issues and quadratic output amplification during DOM serialization.
The @xmldom/xmldom package is a pure JavaScript implementation of the W3C standard DOMParser and XMLSerializer specifications. It is widely used in server-side Node.js environments to parse, manipulate, and serialize XML and HTML documents. Because it runs in server-side applications, any vulnerabilities in its parsing logic can expose the host application to remote attacks.
A denial of service vulnerability, tracked as CVE-2026-83612, arises when the parser processes HTML documents containing specific raw-text or escapable raw-text elements. These elements, which include <script>, <style>, <textarea>, and <title>, are parsed in a dedicated mode designed to read content without evaluating sub-elements. The attack surface is exposed directly through the DOMParser.parseFromString() method when called with the text/html mime type.
An attacker can exploit this vulnerability by submitting a crafted HTML document that contains mismatched casing in the closing tags of these elements. This leads to a severe degradation of performance, causing uncontrolled resource consumption. The flaw affects all versions of the library starting from 0.9.0-beta.1 up to, but not including, 0.9.12.
The root cause of the vulnerability lies in a mismatch between the implementation of xmldom and the WHATWG HTML Specification regarding raw-text elements. The specification states that the closing tag of raw-text and escapable raw-text elements must be matched in a case-insensitive manner. Therefore, tags like </SCRIPT> or </ScRiPt> are valid closing markers for an opening <script> tag.
In vulnerable versions of xmldom, the internal helper function parseHtmlSpecialContent (located in lib/sax.js) attempted to find the end of raw-text elements using a case-sensitive search. It implemented this search via the source.indexOf('</' + tagName + '>', elStartEnd) statement. Because the variable tagName preserved the casing of the opening tag (typically lowercase), the parser failed to find closing tags that utilized mixed-case or uppercase characters, resulting in an index value of -1.
The parsing logic then used this return value directly within the String.prototype.substring() method to slice out the content of the element. In JavaScript, when substring(start, end) receives a negative value for the end parameter, it normalizes that parameter to 0. Furthermore, if the start parameter is greater than the end parameter, the method silently swaps the two arguments.
Consequently, the execution of source.substring(elStartEnd + 1, -1) resolved to source.substring(0, elStartEnd + 1). This behavior caused the parser to extract the entire document from its starting offset up to the opening of the current element, rather than returning an empty string or gracefully handling the missing tag. When serialized, this leading document portion was re-emitted, leading to a quadratic growth of the output size over repeated elements.
The vulnerability is localized within the file lib/sax.js inside the parseHtmlSpecialContent function. Below is an analysis of the vulnerable implementation compared directly against the patched code.
// In vulnerable versions of lib/sax.js
function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
// Vulnerable case-sensitive search
var elEndStart = source.indexOf('</' + tagName + '>', elStartEnd);
// If elEndStart is -1, substring(elStartEnd + 1, -1) swaps arguments
// and returns source.substring(0, elStartEnd + 1)
var text = source.substring(elStartEnd + 1, elEndStart);
// Text contains the entire document from index 0
}
}// In patched version 0.9.12
function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
// Escape special regex characters in the tag name
var escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// Perform case-insensitive search using a safe regular expression
var closeTag = new RegExp('</' + escapedTagName + '>', 'ig');
closeTag.lastIndex = elStartEnd;
var match = closeTag.exec(source);
var elEndStart = match ? match.index : -1;
// Introduce an explicit boundary guard to prevent backward slicing
if (elEndStart < 0) {
// Safely exit and delegate recovery to the main parser loop
return elStartEnd + 1;
}
var text = source.substring(elStartEnd + 1, elEndStart);
}
}By replacing the case-sensitive string search with a case-insensitive regular expression, the patch aligns xmldom with the WHATWG specification. The introduction of the boundary guard if (elEndStart < 0) ensures that if no closing tag is found, the function exits immediately and prevents any dangerous parameter swapping in the substring call.
An attacker can exploit this vulnerability if they have the ability to supply arbitrary HTML input to an application that processes it using xmldom. The exploit payload utilizes multiple raw-text elements that contain mismatched closing tags to trigger the quadratic amplification mechanism.
Consider the following raw-text bomb payload:
<html>
<body>
<script>x</ScRiPt>
<script>x</ScRiPt>
<script>x</ScRiPt>
</body>
</html>When the parser processes this markup, the first <script> tag fails to find its closing tag </ScRiPt> due to the case mismatch. The parser back-captures everything from the beginning of the document up to the end of the opening tag. The second <script> tag does the same, capturing the preceding markup which now includes the amplified contents of the first tag.
As the number of elements increases, the size of the parsed text buffer grows quadratically ($O(n^2)$). When the application calls XMLSerializer.serializeToString(), this massive internal buffer is written back to the output string. A payload of 1,000 repeating script blocks can result in an output string that is several hundred times larger than the input, locking the single-threaded Node.js event loop and exhausting system memory.
The concrete impact of CVE-2026-83612 is a severe Denial of Service (DoS) condition on the hosting application. Because Node.js operates on a single-threaded event loop, any operation that consumes excessive CPU cycles or causes heavy garbage collection will block all concurrent requests.
This vulnerability has been assigned a CVSS v4.0 score of 8.7, indicating high severity. The attack vector is Network (AV:N), the complexity is Low (AC:L), and no privileges are required (PR:N). There is no impact on confidentiality or integrity, but the impact on availability is High (VA:H).
If an application parses user-generated HTML in real-time (such as in a rich-text comment parser, an email processing system, or an HTML sanitizer), a remote unauthenticated attacker can submit a relatively small payload (under 50 KB) that exhausts the server's memory, eventually crashing the Node.js process due to Out-of-Memory (OOM) errors.
Remediation requires upgrading the @xmldom/xmldom package to version 0.9.12 or above. This release addresses the root parsing issue and prevents the quadratic amplification loop.
If the library is a transitive dependency (introduced by another package), you can force its resolution using your package manager's override capabilities. For npm, add the following to your package.json:
{
"overrides": {
"@xmldom/xmldom": "^0.9.12"
}
}If an immediate upgrade is not possible, applications should implement input size limits on incoming HTML payloads or sanitize tag names using a pre-parser that standardizes all closing tag casing to lowercase before handing the document to xmldom.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
@xmldom/xmldom xmldom | >= 0.9.0-beta.1 < 0.9.12 | 0.9.12 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-178 / CWE-400 |
| Attack Vector | Network (Unauthenticated) |
| CVSS Score | 8.7 |
| EPSS Score | 0.00301 (22.45th percentile) |
| Impact | Denial of Service (CPU & Memory exhaustion) |
| Exploit Status | Proof-of-Concept Available |
| KEV Status | Not Listed |
The software does not properly handle case sensitivity when parsing raw-text HTML tags, causing a fallback logic error that results in resource exhaustion.
CVE-2026-126297 (GHSA-v8f3-6phw-6mh9) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Natural Language Toolkit (NLTK) prior to version 3.10.4. Located in the Semantic Role Labeling (SRL) parser within `nltk/corpus/reader/conll.py`, the flaw allows an attacker to trigger quadratic O(N^2) CPU processing overhead by providing crafted CoNLL-formatted corpus inputs containing decoy span columns or nested full-width verb spans. Applications parsing untrusted linguistic corpora can experience prolonged CPU exhaustion and application-level Denial of Service (DoS).
CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.