Summary
OpenSAGRES XDocReport versions 0.9.2 through 2.0.3 are vulnerable to XML External Entity (XXE) processing when handling uploaded .docx files.
By supplying a crafted DOCX that embeds malicious XML entities, an attacker may be able to trigger arbitrary code execution in the context of the application processing the document.
Affected context
This vulnerability arises in applications that integrate OpenSAGRES XDocReport (v0.9.2–v2.0.3) to generate or convert DOCX documents, typically on the server side.
It is relevant when:
- User-supplied DOCX files are accepted for processing, transformation, or templating.
- The XDocReport library parses internal XML parts of the DOCX without disabling external entity resolution.
- The document processing occurs in a backend service or batch job with network and filesystem access.
The risk grows when the processing service runs with elevated privileges or has reach into sensitive internal networks or filesystems.
Exploit preconditions
- Attack surface: Any endpoint or feature that accepts or processes DOCX files using vulnerable XDocReport versions.
- Required access: Ability to upload or otherwise supply a DOCX file to the application (e.g., authenticated user role or public upload feature).
- Trigger point: The moment the application invokes XDocReport to parse or transform the uploaded DOCX (e.g., template merge, conversion to other formats).
- Why exploitation is possible: The XML parser used within XDocReport is configured (directly or implicitly) to honor external entities, allowing crafted XML inside the DOCX to define entities that resolve to external resources or trigger dangerous processing paths, which can escalate to arbitrary code execution in some environments.
Why this happens
The root cause is the use of an XML parser configuration that permits external entity expansion when processing XML content embedded in DOCX files.
This aligns with CWE-611: Improper Restriction of XML External Entity Reference, where untrusted XML input is parsed without disabling external DTDs and entity resolution.
In XDocReport's DOCX handling, internal XML parts (such as document.xml and related components) are treated as trusted, allowing custom entity declarations that can reference local files, internal network services, or parser features that lead to unsafe behavior.
The lack of a secure-by-default XML parsing configuration leaves document-processing features exposed to XXE-driven attacks that can ultimately result in remote code execution depending on the runtime environment.
Potential impact
- Remote code execution in the context of the document-processing service.
- Exfiltration of sensitive files accessible to the server (e.g., configuration files, credentials).
- Server-side request forgery (SSRF) to internal services, metadata endpoints, or other protected resources.
- Denial of service through resource exhaustion (e.g., recursive entities or large external resources).
- Lateral movement or further compromise of the hosting environment if the service runs with high privileges.
General mitigation guidance
Effective mitigation focuses on hardening XML parsing and constraining what document-processing services can do:
- Configure XML parsers used by XDocReport to disable external entity resolution, DTD processing, and other external resource features by default.
- Favor high-level library APIs or builders that explicitly advertise "XXE-safe" or "secure processing" modes rather than hand-rolling parser instances.
- Treat all uploaded documents as untrusted input and ensure that processing occurs inside a sandboxed or low-privilege environment with minimal filesystem and network access.
- Apply the principle of least privilege to the document-processing service account, restricting OS-level capabilities and access to sensitive directories.
- Use content validation to reject suspicious or malformed DOCX files before full processing, where practical (e.g., scanning, structural checks).
These patterns reduce the blast radius even if a parser is misconfigured or a new XML-based feature is introduced.
How teams detect issues like this
Detection typically combines code-level inspection and runtime monitoring:
- Static analysis: Search for XML parser constructions and configurations in code paths that handle DOCX or other office formats, flagging instances where external entities or DTDs are not explicitly disabled.
- Code review signals: Look for document-processing features that pass user-controlled documents into XDocReport without clear parser hardening or sandboxing; verify that secure-processing flags and factory methods are used.
- Configuration review: Validate that JVM-level or framework-level XML security properties (e.g., secure processing features) are enabled across the application.
- Runtime detection: Monitor for abnormal outbound requests or filesystem access immediately following document uploads, which may indicate XXE exploitation attempts.
- Automated tools: Integrate SAST and dependency-scanning tools into CI to highlight known XXE patterns and usage of XML libraries that require hardening.

