/

CVE-2026-38165

Severity:

CRITICAL RISK

(9.8)

Server-Side Template Injection (CWE-94) in XDocReport

CVE-2026-38165

Deferred

Vulnerability type

Category:

Server-Side Template Injection

CWE:

CWE-94

Impact:

Arbitrary 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

A critical Server-Side Template Injection vulnerability in XDocReport's Velocity template configuration allows a crafted expression to be evaluated as template logic.

When attacker-controlled template content reaches the affected rendering path, the issue may enable arbitrary code execution in the process hosting the template engine.

Affected context

The vulnerability occurs in XDocReport deployments that use the Velocity template engine and process template content or expressions influenced by an attacker. Risk increases when untrusted users can submit templates, alter document-generation inputs, or reach an application endpoint that renders attacker-controlled content with server-side privileges.

Exploit preconditions

  • Attack surface: An application feature or service that renders documents or responses through XDocReport and Velocity
  • Required access: The ability to influence template content or values interpreted as template expressions
  • Trigger point: Processing of the crafted expression by the Velocity rendering configuration
  • Why exploitation is possible: Template expressions are evaluated with server-side capabilities instead of being treated strictly as inert data

Why this happens

The underlying flaw is insufficient separation between trusted template logic and untrusted input. A server-side template engine evaluates expressions supplied through a rendering path, allowing attacker-controlled syntax to access functionality beyond simple data substitution.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because externally influenced content is interpreted as executable template logic within the application process.

Potential impact

  • An attacker may execute arbitrary code with the privileges of the XDocReport process
  • The application or document-generation service could be compromised
  • Sensitive files, credentials, or environment data could be accessed
  • The vulnerability could enable data modification, service disruption, or lateral movement

General mitigation guidance

Mitigation generally focuses on preventing untrusted content from being interpreted as executable template logic.

Common defensive patterns include:

  • Treating user-provided values as data rather than dynamically constructed templates
  • Using a restricted or sandboxed template evaluation mode where supported
  • Exposing only an allowlisted set of variables, methods, and objects to templates
  • Separating trusted templates from user-controlled document content
  • Applying strict input validation and context-appropriate escaping
  • Running document-rendering services with least-privilege accounts and restricted filesystem and network access
  • Disabling unnecessary reflective, file, process, and runtime capabilities

How teams detect issues like this

Detection can include:

  • Static analysis rules identifying dynamic template construction and unsafe Velocity evaluation
  • Code review checks for user-controlled values entering template compilation or rendering APIs
  • Runtime monitoring for unexpected process creation, filesystem access, or outbound network activity from rendering services
  • Policy enforcement requiring approved templates and restricting exposed template objects and methods
  • Automated security review tools that flag server-side template injection patterns during development

Sources

SourceLink
github.comgithub.com/AT190510-Cuong/CVE-2026-38165-SSTI-
github.comgithub.com/opensagres/xdocreport
github.comgithub.com/opensagres/xdocreport/pull/723
hackmd.iohackmd.io/@cuongnh/H1sB1RIy-g
hackmd.iohackmd.io/@cuongnh/SyPn-XF0ll

Frequently asked

questions

It may be remotely exploitable when an application exposes a document-generation or template-rendering feature that accepts attacker-influenced template expressions. Exploitability depends on how the surrounding application handles templates and input.

The attacker generally needs access to a rendering path and the ability to influence template content or an input that is evaluated as template syntax. This may require authentication, depending on the deployment.

Keep templates trusted and treat all user-controlled content as data. Use restricted evaluation, allowlisted template capabilities, and strong separation between template definitions and rendered values.

Apply secure template-engine configuration, review all data-to-template boundaries, restrict process privileges, and test rendering features for injection behavior during development and security assessments.

Find out what's already
exploitable in your codebase.