Summary
DataEase versions 2.10.20 and below contain a SQL injection vulnerability in the /datasource/getTableField endpoint, where the tableName parameter is directly interpolated into query strings without parameterization.
An authenticated attacker who can register a crafted API datasource may execute arbitrary SQL commands, enabling error-based extraction of sensitive information from the underlying database.
Affected context
This vulnerability appears in DataEase deployments using versions 2.10.20 and below, specifically when the /datasource/getTableField endpoint is exposed and API datasources can be registered by authenticated users.
The issue occurs in the Java backend (CalciteProvider.getTableFiledSql) where the tableName is incorporated into SQL via String.format instead of parameterized queries.
While DatasourceServer attempts to validate that the table exists in the datasource, the design allows registration of API datasources whose table names can be attacker-controlled, enabling a malicious table name to pass validation and reach the vulnerable SQL construction.
Exploit preconditions
- Attack surface: HTTP interface of the DataEase backend, specifically the
/datasource/getTableFieldendpoint. - Required access: Valid authenticated access with permissions to register or configure an API datasource, and to invoke the affected endpoint.
- Trigger point: Invocation of
/datasource/getTableFieldafter registering an API datasource whosedeTableName(tableName) contains crafted SQL content. - Why exploitation is possible: The backend uses string concatenation (
String.format) to embedtableNamedirectly into SQL without parameter binding or robust sanitization. The existing validation only checks that the table name appears in the datasource metadata, which can be influenced by the attacker by first registering a malicious datasource, thereby bypassing the intended safeguard.
Why this happens
The root cause is reliance on dynamic SQL string construction using untrusted input without parameterization, a classic instance of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
In CalciteProvider.getTableFiledSql, the tableName parameter is inserted into the SQL query via String.format, allowing attacker-controlled content to alter the query structure rather than being treated as a data value.
The architecture further assumes that table-name validation in DatasourceServer is sufficient to enforce safety, but because datasource registration accepts user-controlled table names, the attacker can influence the value that ultimately flows into the SQL builder.
This combination of unsafe query construction and insufficient trust boundaries between configuration metadata and runtime SQL execution leads to arbitrary SQL command execution in the database context used by DataEase.
Potential impact
- Extraction of sensitive data from application tables, including user records, configuration data, or analytics content.
- Error-based enumeration of database schema, tables, columns, and privileges.
- Modification or deletion of data, potentially corrupting dashboards, reports, or analytics results.
- Abuse of database-level functions and stored procedures, which may expand to broader system impact depending on database configuration.
- Privilege escalation within the database if the application account holds elevated permissions.
General mitigation guidance
Effective mitigation focuses on eliminating direct string-based SQL composition and tightening trust boundaries around datasource metadata:
- Use parameterized queries: Replace
String.formatand other concatenation patterns with prepared statements or framework-level query builders that treat incoming values as parameters, not SQL syntax. - Constrain identifiers: When dynamic table names are unavoidable, restrict them to a vetted allowlist or use strict identifier validation (e.g., matching only against known names and enforcing a restricted character set) rather than trusting user-registered metadata.
- Separate configuration from execution: Avoid allowing tenant or user-controlled configuration (such as datasource registrations) to directly influence SQL identifiers without an intermediate normalization or mapping layer.
- Apply least privilege to the database account: Ensure the database user used by DataEase has only the minimal required privileges, limiting the blast radius if injection occurs.
- Centralize query construction rules: Encapsulate SQL generation patterns in a shared module or data access layer that enforces parameterization and safe identifier handling by default.
How teams detect issues like this
Detection can be approached at both code and runtime levels:
- Static analysis: Use SAST tools or custom rules to flag instances of SQL construction that concatenate user-derived values or use format strings instead of parameter bindings. Searches for patterns like
String.format("...%s...", tableName)in data access code are particularly relevant. - Code review cues: During peer review, treat any dynamic SQL generation, especially involving identifiers such as table or column names, as a high-risk pattern that must be justified and constrained. Verify that datasource registration cannot introduce unchecked identifiers into query builders.
- Runtime monitoring: Enable application and database logging to capture unusual or malformed queries, particularly those containing SQL keywords where only identifiers are expected. Correlate access logs for
/datasource/getTableFieldwith database error logs for repeated or anomalous errors. - Policy enforcement in CI/CD: Integrate automated checks to block merges when unsafe SQL construction patterns are detected, and require security sign-off for changes to datasource management or query-building components.

