Summary
Docling's USPTO patent XML parsers between versions 2.13.0 and 2.74.0 used an unprotected SAX-based XML parser, exposing them to XML External Entity (XXE) style issues including entity expansion.
When processing attacker-controlled patent XML, this flaw can allow reading arbitrary server files, performing SSRF, or triggering denial of service via exponential entity expansion.
Affected context
The vulnerability occurs in Docling deployments that ingest and parse USPTO patent XML in the ICE (v4.x), Grant v2.5, or Application v1.x formats using the built-in patent parsers.
It becomes relevant when XML content can be influenced or supplied by untrusted or semi-trusted sources, such as uploaded documents, batch imports, or external feeds, and is parsed using the default xml.sax.parseString() configuration without disabling external entities or limiting expansion.
Exploit preconditions
- Attack surface: XML-based USPTO patent ingestion endpoints or workflows in Docling.
- Required access: Ability to submit or control USPTO patent XML content consumed by the Docling parser (e.g., file upload, import pipeline, or feed manipulation).
- Trigger point: Parsing of the crafted XML via xml.sax.parseString() in the ICE, Grant, or Application USPTO patent parsers.
- Why exploitation is possible: The parser processes XML entities and external references without restrictions, allowing attackers to define entities that resolve to local files, remote URLs, or recursively expanding entities, leading to information disclosure, SSRF, or resource exhaustion.
Why this happens
At its core, this issue stems from using a generic XML SAX parser configuration that implicitly trusts entity declarations in the input document.
By not disabling external entity resolution or limiting entity expansion, the parser follows attacker-defined entity references and processes them as part of normal XML handling.
This aligns with CWE-776: Improper Restriction of Recursive Entity References in XML, where uncontrolled expansion or resolution of XML entities can be abused to read internal resources, relay arbitrary HTTP requests, or exhaust memory and CPU through exponential expansion.
Potential impact
- An attacker may read sensitive files from the server filesystem that the Docling process can access.
- Malicious XML could be used to perform SSRF, making the server send requests to internal services or external endpoints.
- Excessive entity expansion can cause denial of service by consuming CPU and memory (e.g., Billion Laughs-style attacks).
- Compromised XML processing may expose internal infrastructure details through error messages or timing behavior.
General mitigation guidance
Mitigation focuses on hardening XML parsing and constraining what the parser is allowed to process.
Common defensive patterns include:
- Configuring XML parsers to disable external entity resolution and DTD processing, using secure defaults for all XML inputs.
- Enforcing strict schema or structure validation on USPTO patent XML, rejecting documents that contain entity declarations or unexpected constructs.
- Isolating document parsing in low-privilege processes or containers with restricted filesystem and network access to reduce impact if parsing is abused.
- Treating all incoming XML as untrusted by default, and minimizing the set of XML features required for business logic.
How teams detect issues like this
Detection typically relies on reviewing how XML is handled and monitored within the application:
- Static analysis and secure code review can flag uses of xml.sax.parseString() or similar XML APIs without hardened settings (e.g., entity resolution disabled).
- Security-focused code review checklists can require explicit XML parser hardening whenever new document ingestion paths are added.
- Runtime monitoring and logging can track unusual XML parsing failures, high resource usage during XML processing, or unexpected outbound HTTP requests from parsing workflows.
- Automated application security testing tools that include XXE and Billion Laughs payloads can help validate that XML parsers behave safely under adversarial input.

