{"id":"CVE-2026-34601","aliases":["CVE-2026-34601","GHSA-wh4c-j3r5-mjhp"],"related":[],"kind":"vulnerability","state":"published","title":"xmldom: XML injection via unsafe CDATA serialization allows attacker-controlled markup insertion","summary":"xmldom is a pure JavaScript W3C standard-based (XML DOM Level 2 Core) `DOMParser` and `XMLSerializer` module. In xmldom versions 0.6.0 and prior and @xmldom/xmldom prior to versions 0.8.12 and 0.9.9, xmldom/xmldom allows attacker-controlled strings containing the CDATA terminator ]]> to be inserted into a CDATASection node. During serialization, XMLSerializer emitted the CDATA content verbatim without rejecting or safely splitting the terminator. As a result, data intended to remain text-only became active XML markup in the serialized output, enabling XML structure injection and downstream business-logic manipulation. This issue has been patched in xmldom version 0.6.0 and @xmldom/xmldom versions 0.8.12 and 0.9.9.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"xmldom is a pure JavaScript W3C standard-based (XML DOM Level 2 Core) `DOMParser` and `XMLSerializer` module. In xmldom versions 0.6.0 and prior and @xmldom/xmldom prior to versions 0.8.12 and 0.9.9, xmldom/xmldom allows attacker-controlled strings containing the CDATA terminator ]]> to be inserted into a CDATASection node. During serialization, XMLSerializer emitted the CDATA content verbatim without rejecting or safely splitting the terminator. As a result, data intended to remain text-only became active XML markup in the serialized output, enabling XML structure injection and downstream business-logic manipulation. This issue has been patched in xmldom version 0.6.0 and @xmldom/xmldom versions 0.8.12 and 0.9.9.","source":"cvelist"},{"lang":"en","text":"## Summary\n\n`@xmldom/xmldom` allows attacker-controlled strings containing the CDATA terminator `]]>` to be inserted into a `CDATASection` node. During serialization, `XMLSerializer` emitted the CDATA content verbatim without rejecting or safely splitting the terminator. As a result, data intended to remain text-only became **active XML markup** in the serialized output, enabling XML structure\ninjection and downstream business-logic manipulation.\n\nThe sequence `]]>` is not allowed inside CDATA content and must be rejected or safely handled during serialization. ([MDN Web Docs](https://developer.mozilla.org/))\n\n### Attack surface\n\n`Document.createCDATASection(data)` is the most direct entry point, but it is not the only one. The WHATWG DOM spec intentionally does not validate `]]>` in mutation methods — only `createCDATASection` carries that guard. The following paths therefore also allow `]]>` to enter a CDATASection node and reach the serializer:\n\n- `CharacterData.appendData()`\n- `CharacterData.replaceData()`\n- `CharacterData.insertData()`\n- Direct assignment to `.data`\n- Direct assignment to `.textContent`\n\n(Note: assigning to `.nodeValue` does **not** update `.data` in this implementation — the serializer reads `.data` directly — so `.nodeValue` is not an exploitable path.)\n\n### Parse path\n\nParsing XML that contains a CDATA section is **not** affected. The SAX parser's non-greedy `CDSect` regex stops at the first `]]>`, so parsed CDATA data never contains the terminator.\n\n---\n\n## Impact\n\nIf an application uses `xmldom` to generate \"trusted\" XML documents that embed **untrusted user input** inside CDATA (a common pattern in exports, feeds, SOAP/XML integrations, etc.), an attacker can inject additional XML elements/attributes into the generated document.\n\nThis can lead to:\n\n- Integrity violation of generated XML documents.\n- Business-logic injection in downstream consumers (e.g., injecting `<approved>true</approved>`,  `<role>admin</role>`, workflow flags, or other security-relevant elements).\n- Unexpected privilege/workflow decisions if downstream logic assumes injected nodes cannot appear.\n\nThis issue does **not** require malformed parsers or browser behavior; it is caused by serialization producing attacker-influenced XML markup.\n\n---\n\n## Root Cause (with file + line numbers)\n\n**File:** `lib/dom.js`\n\n### 1. No validation in `createCDATASection`\n\n`createCDATASection: function (data)` accepts any string and appends it directly.\n\n- **Lines 2216–2221** (0.9.8)\n\n### 2. Unsafe CDATA serialization\n\nSerializer prints CDATA sections as:\n\n```\n<![CDATA[ + node.data + ]]>\n```\n\nwithout handling `]]>` in the data.\n\n- **Lines 2919–2920** (0.9.8)\n\nBecause CDATA content is emitted verbatim, an embedded `]]>` closes the CDATA section early and the remainder of the attacker-controlled payload is interpreted as markup in the serialized XML.\n\n---\n\n## Proof of Concept — Fix A: `createCDATASection` now throws\n\nOn patched versions, passing `]]>` directly to `createCDATASection` throws `InvalidCharacterError` instead of silently accepting the payload:\n\n```js\nconst { DOMImplementation } = require('./lib');\n\nconst doc = new DOMImplementation().createDocument(null, 'root', null);\ntry {\n  doc.createCDATASection('SAFE]]><injected attr=\"pwn\"/>');\n  console.log('VULNERABLE — no error thrown');\n} catch (e) {\n  console.log('FIXED — threw:', e.name); // InvalidCharacterError\n}\n```\n\nExpected output on patched versions:\n\n```\nFIXED — threw: InvalidCharacterError\n```\n\n---\n\n## Proof of Concept — Fix B: mutation vector now safe\n\nOn patched versions, injecting `]]>` via a mutation method (`appendData`, `replaceData`, `.data =`, `.textContent =`) no longer produces injectable output. The serializer splits the terminator so the result round-trips as safe text:\n\n```js\nconst { DOMImplementation, XMLSerializer } = require('./lib');\nconst { DOMParser } = require('./lib');\n\nconst doc = new DOMImplementation().createDocument(null, 'root', null);\n\n// Start with safe data, then mutate to include the terminator\nconst cdata = doc.createCDATASection('safe');\ndoc.documentElement.appendChild(cdata);\ncdata.appendData(']]><injected attr=\"pwn\"/><more>TEXT</more><![CDATA[');\n\nconst out = new XMLSerializer().serializeToString(doc);\nconsole.log('Serialized:', out);\n\nconst reparsed = new DOMParser().parseFromString(out, 'text/xml');\nconst injected = reparsed.getElementsByTagName('injected').length > 0;\nconsole.log('Injected element found in reparsed doc:', injected);\n// VULNERABLE: true  |  FIXED: false\n```\n\nExpected output on patched versions:\n\n```\nSerialized: <root><![CDATA[safe]]]]><![CDATA[><injected attr=\"pwn\"/><more>TEXT</more><![CDATA[]]></root>\nInjected element found in reparsed doc: false\n```\n\n---\n\n## Fix Applied\n\nBoth mitigations were implemented:\n\n### Option A — Strict/spec-aligned: reject `]]>` in `createCDATASection()`\n\n`Document.createCDATASection(data)` now throws `InvalidCharacterError` (per the [WHATWG DOM spec](https://dom.spec.whatwg.org/#dom-document-createcdatasection)) when `data` contains `]]>`. This closes the direct entry point.\n\nCode that previously passed a string containing `]]>` to `createCDATASection` and relied on the silent/unsafe behaviour will now receive `InvalidCharacterError`. Use a mutation method such as `appendData` if you intentionally need `]]>` in a CDATASection node's data (the serializer split in Option B will keep the output safe).\n\n### Option B — Defensive serialization: split the terminator during serialization\n\n`XMLSerializer` now replaces every occurrence of `]]>` in CDATA section data with the split sequence `]]]]><![CDATA[>` before emitting. This closes all mutation-vector paths that Option A alone cannot guard, and means the serialized output is always well-formed XML regardless of how `]]>` entered the node.\n\n## Update — 2026-04-xx (0.9.10 / 0.8.13)\n\n### `splitCDATASections` is deprecated\n\nThe CDATA split behavior introduced as Option B of this fix (replacing `]]>` with`]]]]><![CDATA[>` during serialization) is **deprecated** as of 0.9.10 / 0.8.13.\n\nThis release introduces a `requireWellFormed` option on `XMLSerializer.serializeToString()`. When `{ requireWellFormed: true }` is passed as the second argument, the serializer throws `InvalidStateError` if CDATA section data contains `]]>` — this is the spec-aligned behavior (W3C DOM Parsing and Serialization, `require well-formed` flag) and the recommended migration path going forward.\nThe split behavior is now controlled by an explicit `splitCDATASections` option (default `true`, preserving the current behavior). The three serialization behaviors are:\n| `requireWellFormed` | `splitCDATASections` | Behavior ||---|---|---|| `false` (default) | `true` (default) | Split `]]>` → `]]]]><![CDATA[>` (current behavior, deprecated) || `true` | — (ignored) | Throw `InvalidStateError` — spec-aligned, recommended |\\ `false` | `false` | Emit verbatim — same as pre-0.9.9 behavior |\n\n`requireWellFormed: true` takes precedence: the split path is unreachable when it is set.\n\n### Migration\nReplace any reliance on the default split behavior with an explicit opt-in:\n```js// Before (implicit split, deprecated): const xml = new XMLSerializer().serializeToString(doc);\n\n// After (explicit guard, spec-aligned): const xml = new XMLSerializer().serializeToString(doc, { requireWellFormed: true }); // Throws InvalidStateError if any CDATASection contains ']]>' ```\n\n### Removal timeline\nBoth the `splitCDATASections` option and the underlying `]]>` → `]]]]><![CDATA[>` split mechanics will be removed in the next breaking (`0.10.0`) release. After removal, the only behaviors will be verbatim (default) and `requireWellFormed: true` (throws).\n\nRemoval is tracked in [xmldom/xmldom#999](https://github.com/xmldom/xmldom/issues/999).","format":"markdown","source":"ghsa"},{"lang":"es","text":"xmldom es un módulo de JavaScript puro basado en el estándar W3C (XML DOM Nivel 2 Core) para 'DOMParser' y 'XMLSerializer'. En las versiones 0.6.0 y anteriores de xmldom y en @xmldom/xmldom anteriores a las versiones 0.8.12 y 0.9.9, xmldom/xmldom permite que cadenas controladas por el atacante que contienen el terminador CDATA ]]> sean insertadas en un nodo CDATASection. Durante la serialización, 'XMLSerializer' emitía el contenido CDATA textualmente sin rechazar o dividir de forma segura el terminador. Como resultado, los datos destinados a permanecer solo como texto se convirtieron en marcado XML activo en la salida serializada, lo que permitía la inyección de estructura XML y la manipulación de la lógica de negocio posterior. Este problema ha sido parcheado en la versión 0.6.0 de xmldom y en las versiones 0.8.12 y 0.9.9 de @xmldom/xmldom.","source":"nvd"}],"published":"2026-04-01T00:19:06.000Z","modified":"2026-09-10T03:51:03.715Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-91"],"affected":[{"ranges":[{"version":"xmldom <= 0.6.0","status":"affected"},{"version":"@xmldom/xmldom < 0.8.12","status":"affected"},{"version":"@xmldom/xmldom >= 0.9.0, < 0.9.9","status":"affected"}],"vendor":"xmldom","product":"xmldom","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Migration Toolkit for Applications 8","package":"redhat-user-workloads/art-images","cpe":"cpe:/a:redhat:migration_toolkit_applications:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Build of Podman Desktop","package":"podman-desktop-macos-1-0","cpe":"cpe:/a:redhat:podman_desktop:1","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Build of Podman Desktop","package":"podman-desktop-windows-1-0","cpe":"cpe:/a:redhat:podman_desktop:1","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Developer Hub","package":"rhdh/rhdh-hub-rhel9","cpe":"cpe:/a:redhat:rhdh:1","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Fuse 7","package":"xmldom","cpe":"cpe:/a:redhat:jboss_fuse:7","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-mlflow-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift Container Platform 4","package":"redhat-user-workloads/art-images","cpe":"cpe:/a:redhat:openshift:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift Dev Spaces","package":"redhat-user-workloads/code-rhel9","cpe":"cpe:/a:redhat:openshift_devspaces:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Self-service automation portal 2","package":"redhat-user-workloads/ansible-plugins","cpe":"cpe:/a:redhat:ansible_portal:2","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"0.6.0"}],"ecosystem":"npm","package":"xmldom","purl":"pkg:npm/xmldom","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.8.12"}],"ecosystem":"npm","package":"@xmldom/xmldom","purl":"pkg:npm/%40xmldom/xmldom","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.9.0","status":"affected","fixed":"0.9.9"}],"ecosystem":"npm","package":"@xmldom/xmldom","purl":"pkg:npm/%40xmldom/xmldom","source":"ghsa"}],"references":[{"url":"https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/xmldom/xmldom/commit/2b852e836ab86dbbd6cbaf0537f584dd0b5ac184","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/xmldom/xmldom/releases/tag/0.8.12","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/xmldom/xmldom/releases/tag/0.9.9","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-34601","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2454595","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-34601.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34601","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/xmldom/xmldom","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-04-03T16:02:29.353Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-34601","url":"https://www.cve.org/CVERecord?id=CVE-2026-34601","licence":"CVE Terms of Use","modified":"2026-07-15T01:04:09.128Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wh4c-j3r5-mjhp","url":"https://github.com/advisories/GHSA-wh4c-j3r5-mjhp","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:03.715Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-34601","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34601","licence":"Public domain","modified":"2026-07-21T19:10:00.107Z"}],"updatedAt":"2026-11-25T22:59:17.829Z","epss":{"score":0.00535,"percentile":0.46628,"date":"2026-12-01T12:00:22.000Z"}}