/

CVE-2026-41672

Severity:

HIGH RISK

(7.5)

XML Comment Injection (CWE-91) in xmldom Serializer

CVE-2026-41672

Deferred

Vulnerability type

Category:

XML Injection

CWE:

CWE-91

Impact:

XML Structure Manipulation and Data Integrity Compromise

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The xmldom JavaScript XML serializer fails to properly sanitize attacker-controlled comment content, allowing comment-breaking sequences to terminate comments prematurely.

When applications embed untrusted data inside XML comments, an attacker can inject arbitrary XML nodes into the serialized output, potentially altering downstream XML processing logic.

Affected context

This vulnerability occurs in Node.js or browser-based applications that use the xmldom XMLSerializer (or equivalent APIs in @xmldom/xmldom) to generate XML documents containing user- or externally supplied data in comments.

It is most relevant where serialized XML is consumed by other services, stored as configuration, or processed by parsers that trust the document structure. The risk increases when untrusted comment content is embedded without normalization or validation, and downstream logic acts on the injected nodes.

Exploit preconditions

  • Attack surface: Any XML serialization path that embeds untrusted data into <!-- ... --> comment sections using xmldom.
  • Required access: Ability to control or influence comment content (for example, user input, data from external systems, or logs injected into XML comments).
  • Trigger point: Invocation of XMLSerializer (or related serialization routines) that render the crafted comment into an XML string.
  • Why exploitation is possible: xmldom does not validate or neutralize comment-breaking sequences (such as -->) inside comment text, allowing an attacker to close the comment early and introduce arbitrary XML elements or attributes that become part of the document structure.

Why this happens

The underlying issue stems from insufficient normalization and validation of comment content before XML serialization.

In xmldom, attacker-controlled strings inserted into XML comments are treated as opaque text and written directly into the serialized output. When these strings contain comment-terminating sequences, the serializer produces syntactically valid XML that closes the comment and continues with additional nodes specified by the attacker.

This behavior maps to CWE-91: XML Injection, where untrusted data is embedded into XML without enforcing structural integrity, enabling modification of the document tree and downstream interpretation.

Potential impact

  • An attacker may inject arbitrary XML elements or attributes into the serialized document.
  • XML-based access control rules, routing decisions, or feature toggles could be modified or bypassed by injected nodes.
  • Downstream XML consumers can be tricked into processing attacker-defined configuration or policy data.
  • Integrity of logs, audit trails, or data interchange formats using XML comments can be compromised.
  • In complex XML workflows, injected nodes could contribute to SSRF, data exfiltration, or logic manipulation when combined with other weaknesses.

General mitigation guidance

Effective mitigation focuses on enforcing strict XML structural integrity and reducing trust in comment content.

Recommended patterns include:

  • Avoid embedding untrusted data inside XML comments; prefer data elements or attributes with proper escaping and validation.
  • Normalize or escape comment text to remove or encode sequences that can terminate comments (such as -->) before passing data to the serializer.
  • Introduce an abstraction layer for XML construction that never concatenates raw strings into markup; instead, build documents using safe DOM APIs and fixed schemas.
  • Apply schema-driven validation on serialized XML where feasible to ensure that only expected nodes and attributes are present.
  • Limit the authority and interpretation scope of XML documents generated from partially untrusted data, using least-privilege principles for any system consuming them.

How teams detect issues like this

Detection typically combines code-level inspection and policy enforcement around XML generation.

Useful strategies include:

  • Static analysis rules that flag direct insertion of untrusted strings into XML comments or other markup-sensitive locations.
  • Code review checklists focused on XML/HTML construction, requiring explicit escaping functions and discouraging use of string concatenation for document structure.
  • Automated scanning for patterns like <!-- combined with variables or user input in serialization code, particularly in xmldom usage sites.
  • Runtime validation or testing that fuzzes comment content with comment-terminating sequences to reveal structural injection issues.
  • Centralized XML generation utilities with security reviews, paired with CI policies that require their use instead of ad hoc serialization.

Sources

SourceLink
github.comgithub.com/xmldom/xmldom/commit/b397540889086da868c30c366ad5c220d1a750c7
github.comgithub.com/xmldom/xmldom/commit/fda7cc313de30243fea35cada64e0bb12099c2a1
github.comgithub.com/xmldom/xmldom/pull/987
github.comgithub.com/xmldom/xmldom/releases/tag/0.8.13
github.comgithub.com/xmldom/xmldom/releases/tag/0.9.10
github.comgithub.com/xmldom/xmldom/security/advisories/GHSA-j759-j44w-7fr8
access.redhat.comaccess.redhat.com/errata/RHSA-2026:26234
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-41672
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2467631
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-41672.json

Frequently asked

questions

Exploitability depends on how your application uses XML comments; if untrusted data can reach xmldom comments and downstream systems rely on the XML structure, the vulnerability can have significant impact.

An attacker needs the ability to control or influence the content placed into XML comments, typically via application inputs, external data feeds, or log messages that are embedded in comments.

The safest approach is to avoid putting untrusted data into XML comments altogether. If comments are required, enforce strict escaping or normalization of comment text and construct XML documents exclusively via safe DOM APIs rather than string concatenation.

Establish a secure XML construction pattern that treats all external data as untrusted, applies consistent encoding or schema validation, and prohibits direct insertion of raw input into markup-sensitive areas such as comments, CDATA, or element/attribute names.

Find out what's already
exploitable in your codebase.