/

CVE-2026-41674

Severity:

HIGH RISK

(7.5)

Unescaped DOCTYPE Fields (CWE-91) in xmldom XMLSerializer

CVE-2026-41674

Deferred

Vulnerability type

Category:

Improper Output Neutralization for XML Elements

CWE:

CWE-91

Impact:

XML Injection and Malformed Document Generation

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

xmldom's XMLSerializer component writes DocumentType fields directly into the XML output without escaping or validation, allowing attacker-controlled strings to break out of the DOCTYPE declaration.

When an application lets untrusted data populate internalSubset, publicId, or systemId, hostile markup can be injected into serialized XML documents, becoming risky wherever that XML is consumed, rendered, or further processed.

Affected context

This vulnerability arises in JavaScript applications that use xmldom's DOMParser/XMLSerializer to construct or manipulate XML documents and then serialize them to strings.

It is most relevant when applications programmatically set DocumentType node fields (internalSubset, publicId, systemId) with values influenced by untrusted or partially trusted input.

The risk increases when the serialized XML is fed into downstream parsers, templating engines, or systems that assume the document structure is well-formed and trustworthy.

Exploit preconditions

  • Attack surface: Application logic that constructs or modifies XML DocumentType nodes using xmldom and exposes serialized XML to clients or downstream services.
  • Required access: Ability to control or influence the strings assigned to internalSubset, publicId, or systemId fields (e.g., via user input, API parameters, or data from external systems).
  • Trigger point: Invocation of XMLSerializer.serializeToString on a Document that contains a DocumentType node with attacker-controlled fields.
  • Why exploitation is possible: The serializer includes these fields verbatim, with no escaping or structural validation, enabling early termination of the DOCTYPE declaration and injection of arbitrary markup into the resulting XML.

Why this happens

The underlying flaw is improper output neutralization of XML content, aligning with CWE-91: Improper Neutralization of XML Elements in Data.

xmldom's XMLSerializer assumes that DocumentType fields are well-formed and trustworthy, and therefore writes them directly into the serialized document without escaping special characters or validating structural correctness.

This insecure pattern allows an attacker to craft values that break the expected DOCTYPE syntax and inject additional tags, entities, or markup outside the declaration, impacting any component that consumes the resulting XML.

Potential impact

  • Attacker-controlled markup may appear in serialized XML documents.
  • Downstream XML parsers or processors could be tricked into interpreting injected elements or entities.
  • Applications that transform XML (e.g., XSLT, templating) can be driven into unintended logic paths.
  • XML-based configuration, messaging, or data interchange formats may be corrupted or misrouted.
  • Under certain ecosystems, this could contribute to client-side or server-side injection chains when XML is further converted to other formats.

General mitigation guidance

Mitigation focuses on treating all XML-related strings, including DocumentType fields, as untrusted and enforcing strict neutralization.

Recommended patterns include:

  • Applying robust escaping routines to internalSubset, publicId, and systemId before assigning them to DocumentType nodes.
  • Validating input against strict schemas or whitelists to ensure only expected characters and structures are allowed in DOCTYPE-related fields.
  • Avoiding dynamic or user-driven DocumentType construction where possible, favoring static, hard-coded declarations.
  • Designing XML handling paths under least-privilege assumptions, so that malformed or unexpected XML cannot cause high-impact behavior elsewhere in the system.

How teams detect issues like this

Detection typically involves a combination of static and review-based controls:

  • Static analysis rules that flag direct assignment of untrusted strings to DocumentType fields (internalSubset, publicId, systemId) without escaping or validation.
  • Code review checklists that require scrutiny of all XMLSerializer usage and dynamic DOCTYPE construction logic.
  • Centralized XML handling policies that mandate safe construction APIs or helper functions, making it easier to spot deviations.
  • Use of automated security testing tools to generate malformed or injected XML and verify how downstream components respond.

Sources

SourceLink
github.comgithub.com/xmldom/xmldom/commit/372008f9ae0e20fd69f761c7b79e202598267314
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-f6ww-3ggp-fr8h
access.redhat.comaccess.redhat.com/errata/RHSA-2026:20034
access.redhat.comaccess.redhat.com/errata/RHSA-2026:21338
access.redhat.comaccess.redhat.com/errata/RHSA-2026:21703
access.redhat.comaccess.redhat.com/errata/RHSA-2026:26234
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-41674
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2467620
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-41674.json

Frequently asked

questions

Exploitability depends on whether untrusted data can reach DocumentType fields and whether the serialized XML influences security-sensitive behavior in downstream consumers. In systems where XML documents drive configuration, workflows, or transformations, the impact can be significant.

An attacker needs the ability to control or influence the values assigned to XML DocumentType fields, typically via application inputs, API parameters, or data feeds. They do not need direct access to xmldom itself, only to the data that the application passes into it.

The safest pattern is to avoid dynamic DOCTYPE construction from user-supplied data. When DOCTYPE must be dynamic, enforce rigorous validation and escaping of all DocumentType-related strings before serialization, and centralize this logic in well-reviewed helper functions.

Treat XML as a structured yet vulnerable format: adopt standard encoding/escaping utilities for all XML output, integrate schema validation for critical documents, enforce coding guidelines around structured data handling, and use automated checks to flag any direct insertion of untrusted content into XML or other markup-like formats.

Find out what's already
exploitable in your codebase.