Summary
DataEase versions 2.10.20 and below contain a SQL injection flaw in the API that saves datasource configurations, where the deTableName field is interpolated directly into a DDL statement.
An authenticated attacker who can create or modify datasource configurations may craft a malicious table name to execute arbitrary SQL, enabling error-based extraction of database information such as the MySQL version.
Affected context
This vulnerability occurs in DataEase deployments that:
- Use versions 2.10.20 or earlier
- Allow authenticated users to create or update datasource configurations through the API
- Construct DDL statements using
deTableNamedirectly from the Base64-encoded configuration payload - Execute the resulting SQL against a MySQL (or compatible) database with typical application-level privileges
In this context, the table name is treated as trusted input and is not sanitized or parameterized before being incorporated into dynamic SQL.
Exploit preconditions
- Attack surface: HTTP(S) API endpoint responsible for saving datasource configurations.
- Required access: Valid authenticated account with permissions to create or edit datasource configurations.
- Trigger point: Submission of a crafted datasource configuration where the Base64-encoded
deTableNamefield contains SQL metacharacters designed to escape identifier quoting. - Why exploitation is possible: The application constructs a DDL statement using simple string replacement, embedding
deTableNamedirectly into the SQL without parameterization, quoting discipline, or server-side validation, allowing attacker-controlled fragments to alter the intended SQL structure.
Why this happens
The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Instead of treating deTableName as untrusted input that must be strictly validated and safely incorporated into SQL, the code performs raw string concatenation or replacement to assemble a DDL statement.
Because no robust identifier validation, escaping, or parameterization is applied, an attacker can inject SQL control characters and additional clauses that change the semantics of the query, leading to error-based SQL injection and arbitrary SQL execution within the scope of the application's database credentials.
Potential impact
- Extraction of database metadata (e.g., MySQL version, current database, table names, column names)
- Unauthorized reading of sensitive application data through injected SELECT statements (depending on error behavior and query context)
- Modification or deletion of tables and records via injected DDL/DML statements (DROP, ALTER, UPDATE, DELETE)
- Creation of new tables or objects that may assist further compromise or persistence
- Potential escalation of impact to other tenants or datasets if the application uses a shared database schema
General mitigation guidance
Effective mitigation centers on removing direct string interpolation of untrusted input into SQL and tightening trust boundaries:
- Use parameterized queries or prepared statements wherever possible, even for DDL operations, and avoid constructing SQL via manual concatenation.
- Apply strict server-side validation to all identifier-like fields (such as table names), enforcing allowed character sets and patterns and rejecting unexpected tokens or SQL metacharacters.
- Introduce a mapping or whitelisting layer between user-facing identifiers and actual database objects, so user input never directly controls raw SQL identifiers.
- Limit the database privileges of the application account to the minimal set required, reducing the blast radius of any injected statements.
- Centralize SQL construction logic and enforce a secure-by-default API for query building to prevent ad-hoc string-based SQL assembly in business code.
How teams detect issues like this
Detection can combine code-level analysis with runtime monitoring:
- Static analysis: Configure SAST rules to flag dynamic SQL construction where user-controlled values (such as request body fields) are concatenated into queries, especially around DDL operations or identifier fields.
- Code review: During manual review, look for:
- Queries built using string concatenation, interpolation, or template replacement.
- Use of unvalidated configuration fields in SQL identifiers (table names, column names).
- Lack of centralized query builders or parameterization wrappers.
- Runtime monitoring: Enable database logging (e.g., general query logs or audit logs) to detect anomalous statements, such as unexpected DDL from application accounts or queries containing user-supplied patterns.
- Security testing: Incorporate automated and manual SQL injection tests into CI/CD pipelines for all API endpoints that persist or interpret configuration data.

