/

CVE-2025-70830

Severity:

CRITICAL RISK

(9.9)

Server-Side Template Injection (SSTI) in Datart Freemarker

CVE-2025-70830

Awaiting Analysis

Vulnerability type

Category:

Server-Side Template Injection (SSTI)

CWE:

CWE-94

Impact:

Remote Code Execution (RCE) by authenticated users

Severity:

CRITICAL RISK

(9.9)

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

Datart v1.0.0-rc.3 contains a Server-Side Template Injection (SSTI) flaw in its Freemarker template engine integration, where user-controlled data is processed as executable template code within the SQL script field.

An authenticated attacker who can submit or modify SQL scripts may inject malicious Freemarker syntax that the server evaluates, potentially leading to arbitrary code execution on the Datart server.

Affected context

The vulnerability arises in Datart v1.0.0-rc.3 where SQL scripts or similar query definitions are passed through the Freemarker template engine.

Any deployment that:

  • Enables dynamic SQL or query configuration through the UI or APIs, and
  • Uses Freemarker to process those SQL scripts, and
  • Does not strictly separate untrusted data from template logic

is exposed to this issue when authenticated users can influence the SQL script field.

Exploit preconditions

  • Attack surface: Application endpoints (UI or API) that accept or update SQL script definitions processed by Freemarker.
  • Required access: Valid authenticated account with permission to create or edit SQL script configurations or similar templated content.
  • Trigger point: Server-side rendering of the Freemarker template containing the attacker-controlled SQL script field (e.g., when executing or previewing the query).
  • Why exploitation is possible: The application passes user-controlled SQL script content directly into the Freemarker engine as template code instead of treating it as plain data, allowing attackers to inject Freemarker directives and expressions that the server executes.

Why this happens

This vulnerability is caused by treating untrusted or semi-trusted input as executable template code in the Freemarker engine.

Instead of passing only controlled template definitions and binding user input strictly as data-model variables, Datart allows content from the SQL script field—partially or fully under user control—to influence the Freemarker template itself.

This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because user input is incorporated into a server-side template that is interpreted as code, giving attackers a way to execute expressions, access server-side objects, or invoke methods exposed through Freemarker.

Potential impact

  • Execution of arbitrary code or expressions on the server within the Freemarker execution context.
  • Access to sensitive application data, configuration values, or environment variables available to the template engine.
  • Lateral movement by interacting with server-side APIs, file system, or network resources accessible to the Datart process.
  • Full compromise of the Datart instance and potential access to connected databases or data sources.
  • Use of the compromised server as a foothold for further attacks within the hosting environment.

General mitigation guidance

Effective mitigation focuses on strictly separating template logic from user-controlled content and reducing the power of the template engine:

  • Treat all user-provided or user-editable fields (including SQL scripts) as data, not as Freemarker template code.
  • Use a fixed, vetted Freemarker template layer and bind user input only via variables in the data model, disallowing user control over directives, macros, or expressions.
  • Configure Freemarker in a locked-down mode:
  • Restrict or disable access to arbitrary Java objects, reflection, or method invocations.
  • Limit template capabilities to simple value interpolation when used with partially untrusted content.
  • Apply rigorous server-side validation and allowlisting on templated fields, ensuring only expected syntax or patterns are accepted.
  • Follow least-privilege principles for the Datart process and underlying runtime so that, if template misuse occurs, the execution environment has minimal privileges.

How teams detect issues like this

Detection can combine static and dynamic approaches:

  • Static analysis & code review:
  • Identify all code paths where Freemarker templates are constructed or evaluated.
  • Flag any usage where user-supplied strings (e.g., SQL scripts, configuration text) are concatenated into template bodies or passed directly to Freemarker parsing/evaluation APIs.
  • Look for generic "evaluate template from string" patterns that do not clearly separate template definitions from user data.
  • Configuration and policy checks:
  • Verify that Freemarker is configured with restricted object wrapping and disabled or limited access to system-level classes.
  • Enforce policies that prohibit dynamic template creation from user input.
  • Runtime monitoring:
  • Monitor for unusual template errors, template evaluation timeouts, or unexpected method invocation from within templates.
  • Use application security tooling (SAST/IAST/DAST) capable of recognizing SSTI patterns and untrusted template evaluation flows.

Sources

SourceLink
github.comgithub.com/running-elephant/datart
github.comgithub.com/xiaoxiaoranxxx/CVE-2025-70830
portswigger.netportswigger.net/web-security/server-side-template-injection

Frequently asked

questions

Yes. Any authenticated user who can access the Datart interface or APIs that accept SQL script input can potentially exploit this issue over the network, provided their input is processed by Freemarker as a template.

Not necessarily. The attacker only needs a role that allows editing or creating SQL script fields or other content that is passed into the Freemarker engine. In many deployments, non-admin users may have such capabilities.

The most robust fix is to remove user control over Freemarker template structure entirely: keep templates static and vetted, and pass all user input strictly as escaped data-bound variables. Additionally, configure Freemarker in a hardened mode that prevents access to arbitrary server-side objects or methods.

Establish a design rule that template engines are never given raw user input as template code. During development and code review, verify that all untrusted data is bound as variables, not concatenated into templates, and that template engines are configured with least privilege. Supplement this with automated checks in CI/CD that flag dynamic template evaluation on user-controlled strings.

Find out what's already
exploitable in your codebase.