/

CVE-2026-33036

Severity:

HIGH RISK

(7.5)

XML Entity Expansion Denial of Service in fast-xml-parser

CVE-2026-33036

Analyzed

Vulnerability type

Category:

XML Entity Expansion Denial of Service

CWE:

CWE-776

Impact:

Denial of Service via uncontrolled resource consumption

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

fast-xml-parser versions 4.0.0-beta.3 through 5.5.5 contain an XML entity expansion vulnerability where numeric character references and standard XML entities bypass configured expansion limits.

An attacker who can supply XML input to be parsed can trigger excessive memory allocation and CPU usage, potentially crashing the process, even when developers believe they have enforced strict safety limits.

Affected context

This vulnerability affects applications that use fast-xml-parser (versions 4.0.0-beta.3 to 5.5.5) to parse untrusted or semi-trusted XML, particularly where:

  • Entity expansion limits (e.g., maxTotalExpansions, maxExpandedLength) are configured to mitigate XML bombs
  • The parser is invoked on user-supplied XML documents or data from external services
  • The resulting JSON/JS object is processed in memory in a long-lived Node.js or browser process

The risk is higher in services that perform synchronous parsing on the main event loop or in resource-constrained environments where spikes in memory or CPU can cause outages.

Exploit preconditions

  • Attack surface: Any endpoint, message handler, or job that accepts XML and uses fast-xml-parser for processing.
  • Required access: Ability to submit or influence XML input (e.g., HTTP request body, message queue payload, file upload, webhook payload, or API integration).
  • Trigger point: Parsing of XML that contains a large number of numeric character references (e.g., &#NNN;, &#xHH;) or standard XML entities.
  • Why exploitation is possible: The parser's entity expansion limits are only applied to DOCTYPE-defined entities; numeric character references and built-in XML entities are expanded in a separate code path (lastEntities loop) that does not increment or enforce expansion counters. This allows an attacker to craft XML with massive effective expansion while the configured safety limits appear to be respected.

Why this happens

The underlying bug is a partial and inconsistent enforcement of resource limits on XML entity expansion. To mitigate XML bombs, fast-xml-parser introduced options such as maxTotalExpansions and maxExpandedLength, but the implementation only accounted for entities defined in the XML DOCTYPE.

In OrderedObjParser.js, replaceEntitiesValue() correctly counts expansions for DOCTYPE-defined entities, yet the subsequent lastEntities loop that replaces numeric character references (&#NNN;, &#xHH;) and standard entities (&, <, etc.) performs replacements without updating these counters. This mismatch between the intended security policy and its implementation maps directly to CWE-776: Improper Restriction of Recursive Entity Expansion in XML, where XML constructs can trigger uncontrolled resource consumption because protective limits are incomplete or bypassable.

Potential impact

  • XML parsing may consume large amounts of memory, potentially exhausting heap space.
  • CPU utilization can spike as the parser processes vast numbers of expansions, degrading performance.
  • The Node.js process or service can crash, causing denial of service for all users of the affected application.
  • In multi-tenant or shared environments, resource exhaustion could impact other services on the same host.
  • Upstream systems, load balancers, or autoscalers may experience cascading failures due to repeated crashes and restarts.

General mitigation guidance

Effective mitigation focuses on limiting trust in XML inputs and ensuring entity handling is safe by default, regardless of configuration:

  • Prefer XML parsing configurations that fully disable DTDs and external entities when they are not strictly required.
  • Treat all forms of entity or character reference expansion (DOCTYPE entities, numeric references, and standard entities) as potentially dangerous, and apply consistent counting and bounding across them.
  • Introduce application-level safeguards such as:
  • Global request body size limits at reverse proxies or API gateways.
  • Timeouts and concurrency limits for parsing operations.
  • Isolation of XML parsing into separate worker processes with explicit memory limits.
  • Avoid parsing untrusted XML on the main event loop of high-value services; instead, offload to sandboxed or rate-limited components.
  • Apply a defense-in-depth strategy: combine parser-level limits with infrastructure-level protections (WAF rules for obviously abusive XML payloads, rate limiting, and anomaly detection).

How teams detect issues like this

Organizations can use several approaches to detect and monitor for this class of vulnerability:

  • Static analysis and dependency review:
  • Search code for usage of fast-xml-parser in versions known to be affected and flag any use where the input might be attacker-controlled.
  • Code review for patterns where XML parsing is done on untrusted data without upstream size or rate limits.
  • Configuration and policy checks:
  • Enforce policies that DTDs and entity expansion features are disabled unless explicitly justified.
  • Integrate software composition analysis (SCA) tools into CI to surface vulnerable parser versions and require review before deployment.
  • Runtime monitoring:
  • Instrument services to log unusually large XML payloads or repeated parsing errors.
  • Monitor for spikes in memory usage or CPU consumption correlated with XML parsing endpoints.
  • Use application performance monitoring (APM) to identify slow or resource-heavy parsing operations indicative of entity expansion attacks.
  • Security testing:
  • During QA and security assessments, include fuzzing or stress tests with XML payloads containing many numeric character references to validate that limits are enforced effectively.

Sources

SourceLink
github.comgithub.com/NaturalIntelligence/fast-xml-parser/commit/bd26122c838e6a55e7d7ac49b4ccc01a49999a01
github.comgithub.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.5.6
github.comgithub.com/NaturalIntelligence/fast-xml-parser/security/advisories/GHSA-8gc5-j5rx-235r

Frequently asked

questions

Yes. If an application exposes any network-accessible functionality that accepts XML and uses fast-xml-parser, a remote attacker can submit crafted XML payloads to attempt exploitation.

The attacker only needs the ability to influence the XML that the application parses. This could be through public HTTP APIs, partner integrations, uploaded files, or any other input channel that is eventually processed by fast-xml-parser.

The safest pattern is to use an XML parser configuration where all entity and character reference expansions are consistently limited or disabled unless absolutely necessary, and to treat library-provided limits as advisory rather than your only line of defense. Pair parser-level protections with external request size limits, timeouts, and process isolation, so that even if a specific limit is bypassed, resource exhaustion is constrained.

Prevention relies on a combination of secure dependency management and defensive design: keep XML and parsing libraries up to date, prefer configurations that disable complex XML features (like DTDs and entities) by default, and enforce architectural safeguards—such as bounded input sizes, rate limiting, and sandboxed parsing workers. Additionally, include XML bomb and entity expansion scenarios in your standard security testing and CI checks so regressions are detected early.

Find out what's already
exploitable in your codebase.