Skip to content
Threat Feed
high advisory

XML Injection Vulnerability in @xmldom/xmldom via Processing Instruction Targets

The @xmldom/xmldom library fails to validate the target parameter in createProcessingInstruction, enabling attackers to break out of XML processing instructions and inject arbitrary content when serializing with the requireWellFormed flag.

CVE search metadata

CVE search record: CVE-2026-83616. EPSS: 0.35%. KEV: no. Product: @xmldom/xmldom (<= 0.8.14), @xmldom/xmldom (0.9.0 - 0.9.11), xmldom (<= 0.6.0). Brief: XML Injection Vulnerability in @xmldom/xmldom via Processing Instruction Targets. Brief link: https://feed.craftedsignal.io/briefs/2026-09-xmldom-injection/

The @xmldom/xmldom library is susceptible to an XML injection vulnerability (CVE-2026-83616) due to insufficient validation of the target parameter in the Document.createProcessingInstruction() method. When developers use the requireWellFormed: true option in XMLSerializer.serializeToString(), the library fails to properly sanitize the processing instruction (PI) target. Specifically, it does not check for the > character, which prematurely terminates the processing instruction (<?target data?>).

An attacker controlling the input to the target parameter can inject arbitrary XML elements, including <script> tags, into the serialized output. If this output is subsequently served as XHTML or processed by a downstream XML parser, it may lead to Cross-Site Scripting (XSS) or XML External Entity (XXE) injection attacks. The protection is not enabled by default, requiring developers to explicitly opt-in to the requireWellFormed mode, which remains incomplete in its validation logic across various versions of the library.

Impact

Successful exploitation allows for the injection of arbitrary XML structure, leading to potential XSS in browser-based applications and XXE vulnerabilities in backend XML parsers. Impact is localized to applications that generate XML dynamically using user-provided data without sufficient secondary validation.

Recommendation

  • Upgrade to a non-vulnerable version of @xmldom/xmldom as soon as updates are available.
  • Audit all serializeToString() call sites to ensure requireWellFormed: true is explicitly enabled for any serialization of untrusted or user-influenced DOM content.
  • Implement strict input validation on any string used as a processing instruction target, ensuring it conforms strictly to the XML NCName production (no colons, whitespace, or XML-reserved characters like > or ?).
  • Do not rely on requireWellFormed: true as the sole mitigation for untrusted input, as it is an opt-in configuration that may not catch all malicious injection vectors.

Immediate actions

Audit codebase for usage of Document.createProcessingInstruction with user-supplied input

Development Team 72h

Mitigations

Enable requireWellFormed: true in all XMLSerializer.serializeToString calls processing untrusted data

immediate Development Team

CVE-2026-83616