/

CVE-2026-25896

Severity:

CRITICAL RISK

(9.3)

XSS via Entity Shadowing (CWE-79) in fast-xml-parser

CVE-2026-25896

Modified

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-185, CWE-79

Impact:

Client-Side Code Execution / XSS

Severity:

CRITICAL RISK

(9.3)

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

A flaw in fast-xml-parser's XML entity handling allows attackers to redefine built-in entities like <, >, &, ", and ' using crafted DOCTYPE declarations.

When the parsed output is rendered in a browser or embedded into HTML without strict encoding, this can lead to cross-site scripting (XSS) and execution of attacker-controlled JavaScript.

Affected context

This vulnerability appears in applications that rely on fast-xml-parser (versions 4.1.3 to before 5.3.5) to convert untrusted or semi-trusted XML into JavaScript objects or HTML fragments.

It becomes risky when:

  • XML input can contain custom DOCTYPE entity declarations, and
  • Parsed values are later embedded into web pages, templates, or DOM without robust output encoding.

The issue is more likely in services that accept user-provided XML or integrate XML feeds from external partners without strict sanitization or entity restrictions.

Exploit preconditions

  • Attack surface: Any endpoint, service, or component that accepts XML input and parses it with affected versions of fast-xml-parser.
  • Required access: Ability to submit or influence XML content (e.g., HTTP request body, uploaded file, message queue payload, or partner feed).
  • Trigger point: Parsing of XML with a DOCTYPE where entity names include dots, enabling redefinition of built-in entities (<, >, &, ", ').
  • Why exploitation is possible: The parser treats the dot (.) in DOCTYPE entity names as a regex wildcard during entity replacement instead of a literal character, allowing attacker-controlled entities to shadow standard ones. When the resulting content is rendered, attacker-controlled HTML or script can execute.

Why this happens

The underlying bug class maps to CWE-185: Incorrect Regular Expression combined with CWE-79: Improper Neutralization of Input During Web Page Generation (XSS).

Entity replacement logic in fast-xml-parser uses regular expressions that interpret dots in entity names as wildcards, causing overly broad matching and allowing malicious redefinitions of built-in XML entities. This breaks the assumption that <, >, &, ", and ' will always be safe-encoded. When these compromised entities are expanded and the resulting data is embedded into HTML or JavaScript contexts, the framework no longer neutralizes attacker-controlled markup or scripts, enabling XSS.

Potential impact

  • Attackers can inject arbitrary HTML or JavaScript into pages rendered using parsed XML data.
  • User sessions may be hijacked via theft of cookies or authentication tokens.
  • Sensitive data displayed in the browser can be exfiltrated through malicious scripts.
  • UI content, forms, or links can be altered to conduct phishing or drive-by attacks.
  • Browser-side security controls relying on DOM integrity can be bypassed.

General mitigation guidance

Effective mitigation typically centers on tightening entity handling and strengthening output encoding patterns:

  • Avoid trusting XML-defined entities when processing untrusted or mixed-trust XML; disable or ignore external and custom entity declarations where feasible.
  • Ensure that all data derived from XML parsing is contextually encoded (HTML, attribute, JavaScript, URL) before insertion into any web page or DOM.
  • Apply strict validation on XML inputs, rejecting payloads that declare unexpected DOCTYPEs or entities, especially those shadowing built-in ones.
  • Treat server-side XML parser configuration as a security boundary: prefer safe defaults that do not allow entity expansion or DTD features unless explicitly required.
  • Use least-privilege design for web views: minimize the amount of dynamic content inserted directly into script-sensitive contexts (e.g., inline event handlers or <script> blocks).

How teams detect issues like this

High-level detection approaches include:

  • Static analysis: Scan codebases for use of fast-xml-parser where parsed results are later concatenated into HTML strings, templates, or client-side scripts without robust encoding or sanitization.
  • Configuration review: Examine XML parsing configurations for support of custom DOCTYPEs and entity expansion, flagging implementations that allow untrusted DTD content.
  • Code review signals: Look for patterns where XML-sourced values are passed straight into templating engines, framework render functions, or DOM manipulation APIs (e.g., innerHTML, unsafe bindings).
  • Security testing: Incorporate XSS-oriented XML payloads in automated tests and dynamic analysis to identify flows where entity redefinitions alter rendered content.
  • Automated tooling (SAST/DAST and dependency analysis platforms) can help detect both insecure usage patterns and presence of vulnerable parser versions, complementing manual review efforts.

Sources

SourceLink
github.comgithub.com/NaturalIntelligence/fast-xml-parser/commit/943ef0eb1b2d3284e72dd74f44a042ee9f07026e
github.comgithub.com/NaturalIntelligence/fast-xml-parser/commit/ddcd0acf26ddd682cb0dc15a2bd6aa3b96bb1e69
github.comgithub.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.3.5
github.comgithub.com/NaturalIntelligence/fast-xml-parser/security/advisories/GHSA-m7jm-9gc2-mpf2
access.redhat.comaccess.redhat.com/errata/RHSA-2026:40984
access.redhat.comaccess.redhat.com/errata/RHSA-2026:41941
access.redhat.comaccess.redhat.com/errata/RHSA-2026:41944
access.redhat.comaccess.redhat.com/errata/RHSA-2026:51349
access.redhat.comaccess.redhat.com/errata/RHSA-2026:6174
access.redhat.comaccess.redhat.com/errata/RHSA-2026:6802
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7110
access.redhat.comaccess.redhat.com/errata/RHSA-2026:7128
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-25896
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2441501
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25896.json

Frequently asked

questions

It can be widely exploitable wherever fast-xml-parser processes attacker-controlled or externally sourced XML and the parsed output is used to generate web content. If XML input is strictly internal and never influences rendered HTML, practical risk is lower.

An attacker needs the ability to supply or modify XML data consumed by an affected service. This could be as simple as sending an HTTP request with XML payload, uploading a file, or influencing an external XML feed that the application trusts.

The safest pattern is to prevent untrusted XML from redefining core entities and to treat all parsed values as untrusted until they are contextually encoded. This includes disabling or strictly limiting DOCTYPE and entity handling for untrusted inputs, and enforcing robust output encoding before data reaches the browser.

Future prevention relies on using XML parsers with conservative configurations, avoiding dynamic DTD or entity features for untrusted data, and institutionalizing secure output encoding across the stack. Security reviews should explicitly examine XML-to-HTML flows, and automated checks should flag risky combinations of XML parsing and template rendering.

Find out what's already
exploitable in your codebase.