/

CVE-2025-66913

Severity:

CRITICAL RISK

(9.8)

Code Injection via Database Connection String

CVE-2025-66913

Analyzed

Vulnerability type

Category:

Code Injection via Database Connection String

CWE:

CWE-94

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

JimuReport up to version 2.1.3 is vulnerable to remote code execution when it processes user-controlled H2 JDBC URLs without restriction.

By supplying a crafted JDBC connection string, an attacker can trigger H2-specific directives that execute arbitrary Java code on the server whenever the application initializes a connection.

Affected context

This vulnerability occurs in JimuReport deployments that:

  • Allow users or administrators to configure or influence H2 database connection strings (JDBC URLs), directly or indirectly
  • Use the H2 database driver in embedded or server mode
  • Pass the configured JDBC URL to the H2 driver without applying restrictions to disallow dangerous directives or protocol variants

The risk is most pronounced where JDBC URLs can be created, edited, or imported from untrusted or semi-trusted sources, such as report data source configuration screens or configuration files influenced by external input.

Exploit preconditions

  • Attack surface: Application interfaces or configuration channels that accept or derive H2 JDBC URLs (e.g., data source configuration, importable settings, or multi-tenant configuration flows)
  • Required access: Ability to supply or modify the JDBC URL used by JimuReport to establish an H2 connection; this could be through authenticated configuration panels or any indirect user input that influences connection strings
  • Trigger point: The moment JimuReport (or its underlying data access layer) uses the attacker-controlled JDBC URL to initialize or reinitialize an H2 connection
  • Why exploitation is possible: The application passes the JDBC URL directly to the H2 driver without filtering or constraining dangerous URL features; H2 supports directives and URL syntaxes that can load and execute arbitrary Java code when processed, turning what should be data into executable instructions

Why this happens

The underlying issue aligns with CWE-94: Improper Control of Generation of Code, specifically in the context of database connection metadata that can embed executable behavior.

Instead of treating the JDBC URL purely as configuration data, the application allows untrusted input to flow unvalidated into a mechanism (the H2 driver) that can interpret parts of the URL as instructions that instantiate or execute Java code.

This pattern emerges when:

  • Frameworks or applications expose low-level JDBC configuration directly to end users or tenants
  • The database driver supports special URL features that can trigger code loading, script evaluation, or class instantiation
  • No allowlist is enforced on the URL scheme, parameters, or features, enabling an attacker to craft a malicious connection string that results in code execution within the application's JVM.

Potential impact

  • Execution of arbitrary Java code within the JimuReport server process
  • Complete takeover of the application, including access to reports, data sources, and stored configurations
  • Lateral movement to other systems reachable from the compromised server (e.g., databases, internal services)
  • Data exfiltration, tampering, or deletion of report data and underlying data sources
  • Installation of persistent backdoors, web shells, or malicious scheduled tasks on the host
  • Use of the compromised server as a pivot for further attacks inside the network

General mitigation guidance

Effective mitigation focuses on treating JDBC URLs as highly sensitive and never fully controllable by untrusted input.

Common defensive patterns include:

  • Restricting database drivers and modes: Avoid exposing H2 for untrusted or multi-tenant use, and disable driver features that allow loading external code or executing scripts via URL options.
  • Enforcing strict allowlists on JDBC URLs: Permit only known-safe URL patterns, schemes, and parameters, and reject any connection strings that deviate from a predefined template.
  • Separating configuration duties: Limit who can configure data sources; prevent low-privilege users from creating or editing connection strings, especially for embedded engines like H2.
  • Central configuration management: Store and manage JDBC URLs in server-side configuration that is not derived from user input; expose only high-level options (e.g., database name) and compose the final URL on the server.
  • Principle of least privilege: Run JimuReport with minimal OS and database privileges so that, even if code execution occurs, the impact is constrained.
  • Hardening H2 usage: Where possible, configure H2 to disable features that are not required by the application and that increase the attack surface (for example, code-loading or script-execution features driven by URLs).

How teams detect issues like this

Detection strategies typically combine code-level inspection with runtime monitoring:

  • Static code analysis: Search for code paths where JDBC URLs are:
  • Constructed directly from HTTP request parameters, form fields, or multi-tenant configuration structures
  • Concatenated or interpolated from user-controlled strings into connection creation APIs (DriverManager.getConnection, connection pool configuration, etc.).
  • Code review signals:
  • Any admin or tenant feature that allows arbitrary JDBC URL entry, especially for H2
  • Lack of validation or pattern-matching on connection strings before they are used
  • Direct exposure of low-level database connection options to UI or API clients.
  • Policy enforcement:
  • Internal guidelines or linters that flag use of H2 in production or external-facing contexts
  • Configuration review processes that require justification for enabling dynamic JDBC URLs.
  • Runtime monitoring:
  • Logging and alerting on unusual or new JDBC URL patterns, especially those containing uncommon H2 directives or external resource references
  • JVM and application telemetry to detect unexpected class loading, script execution, or outbound network connections initiated by the H2 engine.

Automated security scanners and SAST tools can be configured to flag unvalidated use of user-controlled configuration in database connection APIs.

Sources

SourceLink
gist.github.comgist.github.com/Catherines77/f15d53e9705b24cf018e5bffed3e8234
github.comgithub.com/jeecgboot/jimureport/issues/4306

Frequently asked

questions

Yes, if an attacker can access any JimuReport interface or API that allows them to define or influence H2 JDBC URLs, they can exploit this issue remotely whenever the application uses that connection string.

It depends on how JimuReport is deployed. If only privileged administrators can edit H2 data source configurations, an attacker would typically need those credentials. In less restricted deployments where lower-privilege users can define data sources, the bar for exploitation is lower.

The safest pattern is to remove or strictly restrict user control over JDBC URLs, especially for H2. Compose connection strings entirely on the server from vetted components, enforce strict URL templates, and disable or avoid database driver features that can execute code or load external resources.

Avoid exposing low-level connection and driver options to end users, treat configuration strings as potential execution vectors, and apply layered validation and allowlists at every boundary. During design and code review, flag any feature that mixes untrusted input with configuration channels capable of influencing code execution paths (such as JDBC URLs, script engines, or plugin loaders).

Find out what's already
exploitable in your codebase.