Summary
Docling's METS GBS backend is vulnerable to XML Entity Expansion (often called an XML bomb) because XML files from .tar.gz archives are parsed with entity resolution enabled.
A crafted XML file with deeply nested entities can cause exponential memory and CPU consumption during parsing, leading to denial of service on systems running the Docling parser.
Affected context
This vulnerability appears in environments where Docling's METS GBS backend processes XML files extracted from .tar.gz archives.
The risk is most relevant when:
- Archive contents originate from untrusted or semi‑trusted sources (user uploads, third‑party feeds, automated imports), and
- The backend invokes
etree.fromstring()or similar XML APIs without disabling external and internal entity expansion.
In such deployments, a single malicious XML within an archive can monopolize CPU and memory on the parsing host.
Exploit preconditions
- Attack surface: XML documents handled by the METS GBS backend via .tar.gz archives.
- Required access: Ability to supply or influence the .tar.gz archive consumed by Docling (e.g., upload, ingestion feed, or repository control).
- Trigger point: Automatic or manual processing of the archive, causing the backend to extract and parse the malicious XML using
etree.fromstring(). - Why exploitation is possible: The XML parser is invoked with entity resolution enabled and without expansion limits, allowing nested entity references to expand exponentially during parsing and exhaust system resources.
Why this happens
The root cause is the use of a general‑purpose XML parser (etree.fromstring()) with default settings that allow entity expansion, applied to data that may be influenced by untrusted sources.
This aligns with CWE-776: Improper Restriction of Recursive Entity References in DTDs, where XML input can define entities that reference each other recursively.
When the parser processes these entities without hard limits, each expansion step multiplies the data in memory and CPU work, eventually overwhelming the host and causing a denial‑of‑service condition.
Potential impact
- The Docling parsing process may consume excessive CPU, degrading overall system responsiveness.
- Unbounded memory use can cause the service to crash or be terminated by the operating system.
- Other applications on the same host can experience slowdowns or outages due to resource starvation.
- Automated document processing workflows may stall, leading to backlog buildup and potential operational disruption.
General mitigation guidance
Mitigation typically focuses on hardening XML parsing behavior and minimizing trust in incoming documents:
- Prefer XML parsing libraries or configurations that disable DTDs and entity expansion by default when handling untrusted content.
- Configure XML parsers to reject external and internal entities, or to enforce strict limits on entity depth, size, and total expansions.
- Introduce an explicit validation layer that inspects or normalizes XML before deep processing, avoiding full expansion of user‑controlled entities.
- Isolate and rate‑limit document processing components, using timeouts and per‑request resource limits to contain worst‑case behavior.
- Apply least‑privilege and containment at the process or container level so that failure modes are localized and easier to recover from.
How teams detect issues like this
Effective detection combines code‑level analysis with runtime monitoring:
- Static analysis / code review: Flag usages of XML APIs (such as
etree.fromstring()or similar) where DTD loading and entity resolution are not explicitly disabled for untrusted inputs. - Security review patterns: Look for document ingestion paths that accept archives or XML from external parties and feed them directly into parsers without pre‑validation or sandboxing.
- Automated tooling: Use SAST or linters configured with rules for XXE and XML bomb patterns to identify risky parser configurations in CI pipelines.
- Operational monitoring: Track CPU and memory usage patterns for the Docling parser, set alerts for unusual spikes tied to document processing, and enforce timeouts or circuit breakers when processing individual archives.

