Summary
fast-xml-parser versions 4.1.3 through 5.3.5 are vulnerable to excessive XML entity expansion, allowing a tiny XML payload to trigger disproportionate processing.
An attacker can send crafted XML that causes the parser to spend seconds or minutes expanding entities, potentially freezing applications that rely on this library for XML processing.
Affected context
This vulnerability affects applications that use fast-xml-parser (4.1.3–5.3.5) to process XML input where DOCTYPE declarations and entity expansion are allowed.
It becomes relevant when XML content can be influenced by external or semi-trusted sources and is parsed synchronously within request/response paths or other latency-sensitive flows.
Systems that parse large volumes of external XML, or that run with limited CPU resources and blocking event loops (such as Node.js services), are particularly exposed to application-level stalls.
Exploit preconditions
- Attack surface: Any API endpoint, service, or component that parses attacker-controlled or untrusted XML using fast-xml-parser with entity processing enabled.
- Required access: Ability to submit or relay XML content to the vulnerable parser (e.g., HTTP POST body, message queue payload, file upload, or integration webhook).
- Trigger point: Parsing of XML documents containing deeply nested or exponentially defined entities (e.g., crafted DOCTYPE sections) that the library expands.
- Why exploitation is possible: The parser performs unbounded entity expansion without enforcing limits on depth, count, or cumulative size, allowing a very small input to consume disproportionate CPU time.
Why this happens
The underlying issue aligns with CWE-776: Improper Restriction of Recursive Entity Expansion in DTDs.
fast-xml-parser versions 4.1.3–5.3.5 expand XML entities defined in DTDs without robust limits on recursion depth or total expansions.
This design trusts the structure of the XML input and assumes entity expansion will remain reasonable, but crafted inputs can define entities that reference each other in ways that cause exponential growth in the expansion process.
Because the library does this work synchronously and without safeguards, it enables attackers to turn small XML payloads into heavy CPU workloads that stall or block the hosting application.
Potential impact
- Application-level denial of service due to CPU exhaustion during XML parsing.
- Increased request latency, timeouts, or thread/event-loop starvation for other users.
- Service instability under load, including cascading failures across dependent services.
- Potential exhaustion of server resources that may trigger watchdog restarts or scaling anomalies in containerized environments.
General mitigation guidance
Effective mitigation focuses on restricting XML features and bounding parser behavior so that untrusted input cannot cause unbounded work:
- Disable or avoid processing of XML DTDs and entities when they are not strictly required; in fast-xml-parser, use configuration options that prevent entity expansion (e.g., disabling DOCTYPE processing).
- Apply strict limits on XML input size and structural complexity (e.g., maximum depth, maximum number of nodes, or maximum entity count) before or during parsing.
- Treat all externally influenced XML as untrusted data, and minimize reliance on complex XML features like entities, parameter entities, and external subsets.
- Isolate heavy or potentially untrusted XML parsing from latency-sensitive request paths, for example by offloading to worker processes or services that can be rate-limited and monitored.
- Apply general resource limiting and rate-limiting controls at the application and infrastructure layers to prevent a small set of hostile requests from monopolizing CPU time.
How teams detect issues like this
Detection typically combines code-level inspection with behavioral monitoring:
- Static analysis & code review:
- Look for use of fast-xml-parser (versions in the affected range) with configuration that allows DOCTYPE and entity processing.
- Flag XML parsing code paths that handle untrusted input without explicit limits on size, structure, or features.
- Review for synchronous parsing of client-controlled XML in hot paths (e.g., request handlers) without timeouts or isolation.
- Dynamic & operational monitoring:
- Track CPU spikes, long-running request handlers, and timeouts correlated with XML-heavy endpoints or workloads.
- Log and inspect unusually small XML requests that lead to large processing times or repeat failures.
- Policy enforcement:
- Enforce secure XML parsing policies via code quality gates or automated review tools, requiring entity expansion and DTD support to be explicitly justified and guarded.
- Maintain dependency policies that flag vulnerable XML-related libraries and configurations in CI/CD pipelines.

