CVE-2026-83610: xmldom: XML fragment injection via invalid EntityReference.nodeName during requireWellFormed serialization

Published Sep 1, 2026
·
Updated

Summary

An EntityReference node can be created with an invalid, attacker-controlled name through Document.createEntityReference(name). When this node is serialized directly with:

js serializer.serializeToString(ref, { requireWellFormed: true })

the invalid nodeName is emitted into the serialized XML fragment without validation or escaping.

This can produce real XML markup in the serialized output. In the proof of concept below, the serialized fragment contains <injected/>, and reparsing the fragment creates a real injected element.

---

Details

The issue appears to be in the serialization path for ENTITYREFERENCENODE.

For several other node types, requireWellFormed: true performs specific validation checks before serialization. For example, comments, processing instructions, document types, and some character data cases are checked before being emitted.

However, for ENTITYREFERENCENODE, the serializer appears to emit the node name directly in entity reference form:

js case ENTITYREFERENCENODE: buf.push('&', n.nodeName, ';'); return null;

As a result, if nodeName contains characters that break out of the intended &name; structure, the serializer can emit additional XML markup.

For example, an entity reference created with the name:

text safe; <injected/> &x

is serialized as:

xml &safe; <injected/> &x;

When this fragment is later parsed in an XML context, <injected/> becomes a real element.

This is especially surprising when { requireWellFormed: true } is used, because applications may reasonably treat this mode as the stricter or safer XML serialization mode.

---

Proof of Concept

Tested with:

text @xmldom/xmldom@0.9.10 Node.js v24.18.0 Windows 10 / PowerShell

js 'use strict';

const { DOMImplementation, XMLSerializer, DOMParser } = require('@xmldom/xmldom');

const impl = new DOMImplementation(); const doc = impl.createDocument(null, 'root', null); const serializer = new XMLSerializer();

function countInjected(fragment) { try { const parsed = new DOMParser().parseFromString(<root>${fragment}</root>, 'application/xml'); return parsed.getElementsByTagName('injected').length; } catch (e) { return PARSETHROW ${e.name}: ${e.message}; } }

for (const name of [ 'safe', 'safe; <injected/> &x', 'x<injected', 'x y' ]) { try { const ref = doc.createEntityReference(name); const xml = serializer.serializeToString(ref, { requireWellFormed: true });

console.log([SERIALIZED] ${JSON.stringify(name)}: ${xml}); console.log([INJECTEDCOUNT] ${JSON.stringify(name)}: ${countInjected(xml)}); } catch (e) { console.log([THROW] ${JSON.stringify(name)}: ${e.name}: ${e.message}); } }

Observed output:

text [SERIALIZED] "safe": &safe; [INJECTEDCOUNT] "safe": 0

[SERIALIZED] "safe; <injected/> &x": &safe; <injected/> &x; [INJECTEDCOUNT] "safe; <injected/> &x": 1

[SERIALIZED] "x<injected": &x<injected; [INJECTEDCOUNT] "x<injected": 0

[SERIALIZED] "x y": &x y; [INJECTEDCOUNT] "x y": 0

---

Impact

An application that creates an EntityReference from attacker-controlled input and then serializes that node or XML fragment with requireWellFormed: true may produce XML containing attacker-controlled markup.

The impact is limited by two observations:

1. The parser does not create EntityReference nodes from ordinary XML entity references. 2. Appending an EntityReference node as an element child is rejected with a HierarchyRequestError.

The main affected scenario is applications that directly use createEntityReference(name) and then serialize the resulting node or fragment.

Fix Applied

Two complementary, non-breaking fixes. (1) document.createEntityReference(name) rejects an invalid Name at creation, closing the reachable creation vector by default — the opt-in serializer check alone cannot, since a later nodeName mutation would bypass a creation-only guard. (2) Under requireWellFormed, the serializer validates the EntityReference nodeName as a well-formed XML Name and throws InvalidStateError when it is not; a valid reference still serializes as &name;. Both ship on both maintained versions. The EntityReference / createEntityReference docs note that under requireWellFormed the nodeName is validated as an XML Name, and that xmldom does not expand entities. See the XML Name production. ⚠ Opt-in required. Protection is not automatic. Existing serialization calls remain vulnerable unless { requireWellFormed: true } is explicitly passed. Applications that serialize untrusted DOM content should audit all serializeToString() call sites and add it.

Proof of Concept - fixed path

js 'use strict';

const { DOMImplementation, XMLSerializer } = require('@xmldom/xmldom');

const impl = new DOMImplementation(); const doc = impl.createDocument(null, 'root', null); const serializer = new XMLSerializer();

// Creation-time anchor (applied by default): an invalid XML Name is rejected at creation. try { doc.createEntityReference('safe; <injected/> &x'); } catch (e) { console.log(${e.name}); // rejected at creation }

// Default path (requireWellFormed omitted): because creation now rejects an ill-formed name, // an ill-formed nodeName is only reachable via a post-creation mutation — and is emitted verbatim. const ref = doc.createEntityReference('safe'); ref.nodeName = 'safe; <injected/> &x'; console.log(serializer.serializeToString(ref)); // -> &safe; <injected/> &x; (injection present on the default path)

// Opt-in path: throws on the invalid nodeName. try { serializer.serializeToString(ref, { requireWellFormed: true }); } catch (e) { console.log(${e.name}); // InvalidStateError }

// A valid name still serializes as &name; under requireWellFormed. const ok = doc.createEntityReference('valid'); console.log(serializer.serializeToString(ok, { requireWellFormed: true })); // -> &valid;

Why the default stays verbatim

The creation-time anchor is applied by default, because it is classified non-breaking. The serializer check, by contrast, stays gated behind { requireWellFormed: true }: W3C DOM Parsing's require-well-formed flag defaults to false, and the browser XMLSerializer emits the nodeName verbatim in that default mode, so unconditionally throwing for an ill-formed EntityReference.nodeName would be an unjustified breaking change — which is why the default serialization path stays verbatim.

Residual limitation

The creation vector is closed by default — the non-breaking creation-time anchor — with no further deferred work. The residual is at serialization: the default path still emits an ill-formed nodeName verbatim, because the serializer check is opt-in via { requireWellFormed: true }.

Other sources

xmldom is a pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module. Prior to @xmldom/xmldom versions 0.8.15 and 0.9.12, and in xmldom version 0.6.0 and earlier, Document.createEntityReference(name) accepts an invalid name and the ENTITYREFERENCENODE serializer emits the resulting nodeName directly in &name; form. Directly serializing the node or fragment with XMLSerializer.serializeToString() and requireWellFormed: true can therefore break the entity-reference boundary and produce attacker-controlled XML markup when reparsed. The parser does not ordinarily create these nodes, and element-child insertion is rejected, so exploitation requires an application to create and directly serialize an EntityReference. This issue is fixed in @xmldom/xmldom versions 0.8.15 and 0.9.12; no fixed version is available for xmldom.

— MITRE

xmldom: XML fragment injection via invalid EntityReference.nodeName during requireWellFormed serialization

— Microsoft

Affected Software

6 affected componentsFixes available
npm/@xmldom/xmldom>0.8.15<
npm/@xmldom/xmldom>0.9.12<
npm/@xmldom/xmldom<=0.6.0
npm/xmldom<=0.6.0
npm/@xmldom/xmldom>=0.9.0<=0.9.11
0.9.12
npm/@xmldom/xmldom>=0.7.0<=0.8.14
0.8.15

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/@xmldom/xmldom to a version that resolves this vulnerability.

    Fixed in 0.9.12
  2. Upgrade

    Upgrade npm/@xmldom/xmldom to a version that resolves this vulnerability.

    Fixed in 0.8.15
  3. Upgrade

    Upgrade @xmldom/xmldom to a version that resolves this vulnerability.

    Fixed in 0.8.15
  4. Upgrade

    Upgrade @xmldom/xmldom to a version that resolves this vulnerability.

    Fixed in 0.9.12
  5. Configuration

    For any code path that serializes an EntityReference created via Document.createEntityReference(name) from untrusted input, call XMLSerializer.serializeToString(node, { requireWellFormed: true }) so that an invalid EntityReference nodeName fails validation and throws InvalidStateError instead of being emitted verbatim.

    @xmldom/xmldom XMLSerializer.serializeToString() requireWellFormed = true
  6. Compensating control

    Audit all serializeToString() call sites that serialize DOM built from untrusted input; ensure EntityReference nodes created from attacker-controlled names are not serialized without { requireWellFormed: true }. (Protection is opt-in and not automatic.)

Event History

Sep 1, 2026
CVE Published
via MITRE·02:31 PM
Data Sourced
via MITRE·02:31 PM
DescriptionWeakness
Data Sourced
via NVD·03:17 PM
DescriptionSeverityWeakness
Sep 2, 2026
Advisory Published
via GitHub·03:18 PM
Data Sourced
via GitHub·03:18 PM
DescriptionWeaknessAffected Software
Sep 7, 2026
Data Sourced
via Microsoft·09:01 AM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which applications are realistically exposed to this issue?

Exposure requires application code to call Document.createEntityReference() with attacker-influenced input and directly serialize the resulting EntityReference node or fragment using XMLSerializer.serializeToString() with requireWellFormed: true. The parser does not normally create these nodes, and inserting them as element children is rejected.

2

Are normal XML parsing workflows affected?

The parser does not ordinarily create the affected EntityReference nodes. The issue arises from application-created EntityReference nodes that are directly serialized and whose output is later reparsed.

3

What should be done if upgrading is not immediately possible?

Do not create EntityReference nodes from untrusted names, and avoid directly serializing application-created EntityReference nodes or fragments containing them. Validate entity-reference names before calling Document.createEntityReference().

4

Which versions contain fixes?

Fixed versions are @xmldom/xmldom 0.8.15 and 0.9.12. No fixed version is available for xmldom; affected releases include xmldom 0.6.0 and earlier.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203