/

CVE-2025-65482

Severity:

CRITICAL RISK

(9.8)

XML External Entity (XXE) in OpenSAGRES XDocReport DOCX

CVE-2025-65482

Analyzed

Vulnerability type

Category:

XML External Entity (XXE)

CWE:

CWE-611

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

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.

Sources

SourceLink
drive.google.comdrive.google.com/drive/folders/1hUyCznpBN7ivo5krmyJ4OQc_q626Hy5q?usp=sharing
github.comgithub.com/AT190510-Cuong/CVE-2025-65482-XXE-
github.comgithub.com/opensagres/xdocreport
hackmd.iohackmd.io/@cuongnh/r1B7B8fJ-g
hackmd.iohackmd.io/@cuongnh/rkJPCgSy-l

Frequently asked

questions

Yes. If an attacker can remotely upload or supply a DOCX file that is processed by the affected XDocReport integration, the vulnerability can be exploited remotely within the privileges of the processing service.

The attacker needs whatever access is required to submit DOCX files to the application—this may be an authenticated user role or, in some cases, a public upload interface. No shell or local access to the server is required.

The most robust pattern is to ensure all XML parsing in the document-processing pipeline enforces secure settings: disable external entities and DTD processing, enable secure-processing flags, and run document-handling code in a restricted, least-privilege environment. Where feasible, abstract XML usage behind hardened utility components to avoid ad hoc parser configuration.

Establish organization-wide defaults for secure XML parsing, mandate their use in coding standards, and enforce them via code review and static analysis. Combine this with strong isolation for any feature that processes user-supplied documents, minimizing privileges and access to the broader system so that parser misconfigurations do not lead to severe compromise.

Find out what's already
exploitable in your codebase.