Summary
DataEase versions 2.10.20 and below contain a SQL injection vulnerability in the sort parameter of the /de2api/datasetData/enumValueObj API endpoint.
Because user-controlled sort values are interpolated directly into an ORDER BY clause without proper validation, an authenticated attacker can perform time-based blind SQL injection and execute arbitrary SQL within the underlying database.
Affected context
This vulnerability affects deployments of DataEase that expose the /de2api/datasetData/enumValueObj endpoint and allow authenticated users to supply arbitrary sort parameters when querying datasets.
The risk is present when the DatasetDataManage service layer passes user-provided sort values into query construction logic without enforcing a strict whitelist of sortable fields or using a parameterized abstraction for ORDER BY clauses.
Typical scenarios include dashboards, reports, or dataset exploration interfaces where users can change sorting behavior dynamically.
Exploit preconditions
- Attack surface: HTTP(S) interface for the /de2api/datasetData/enumValueObj endpoint.
- Required access: Valid authenticated user account with permission to invoke the endpoint and control the sort parameter.
- Trigger point: Submission of crafted requests where the sort parameter contains injected SQL fragments.
- Why exploitation is possible: The sort value is propagated from the DatasetDataManage service to sorting metadata, then into Order2SQLObj, and finally into the SQL ORDER BY clause without whitelist validation or safe construction.
The resulting SQL is executed by CalciteProvider, allowing attacker-controlled content to influence query structure and timing (time-based blind behavior).
Why this happens
The core issue is unvalidated and unsafely constructed dynamic SQL, aligning with CWE-89: SQL Injection.
Instead of treating the sort parameter as an abstract field identifier mapped to a predefined column list, the implementation directly concatenates or interpolates the user-supplied value into the ORDER BY clause.
ORDER BY segments are not parameterized in the same way as data values, so application code must enforce strict whitelisting of allowed column names and sort directions.
By failing to normalize and validate the sort parameter before building the query, the system allows attacker-controlled input to modify the structure of the SQL statement itself.
Potential impact
- Extraction of sensitive data that the authenticated account can indirectly reach.
- Modification of query logic to infer data using time-based blind SQL injection.
- Potential alteration or deletion of data if the underlying database permissions allow it.
- Discovery of schema details, including table and column names, through crafted injection probes.
- Lateral movement to other queries or stored procedures invoked by the same database connection, depending on database configuration.
General mitigation guidance
Effective mitigation for this class of vulnerability centers on strict input control for query structure and safe query construction patterns:
- Treat ORDER BY components (column names, directions) as identifiers, not free-form text, and map user choices to a fixed, hard-coded list of permitted fields and sort directions.
- Use higher-level query builders or ORM abstractions that separate query structure from user input, making it difficult to directly concatenate raw strings into SQL.
- Normalize and validate all sorting inputs (e.g., enforcing a known set of column keys, rejecting unexpected tokens, and disallowing multiple expressions or functions).
- Apply defense-in-depth on the database layer with least-privilege accounts that only have the minimal required permissions for read and write operations.
- Implement centralized validation utilities for query parameters (filters, sorts, pagination) to avoid duplicating risky string handling logic across services.
How teams detect issues like this
Detection involves both code-level and runtime approaches:
- Static analysis: Configure rules to flag string concatenation or unparameterized interpolation of request parameters (such as sort, order, column) into SQL-building logic, including ORDER BY clauses.
- Code review: Examine service layers that translate user-requested sorting into SQL or DSL constructs; ensure they only use whitelisted field mappings and never accept raw SQL fragments.
- Unit and integration tests: Include negative tests that send deliberately malformed sort values to verify that they are rejected or sanitized rather than executed.
- Runtime monitoring: Enable database and application logs to capture slow queries and unusual patterns typical of time-based blind injection (e.g., repeated requests with small variations in sort values causing consistent timing anomalies).
- Automated scanning: Use API-focused security testing tools or fuzzers to probe sort/order parameters and detect behavior consistent with SQL injection, particularly timing-based techniques.

