Summary
A SQL injection vulnerability in DataEase allows user-supplied table names in the /de2api/datasource/previewData endpoint to be directly concatenated into SQL queries without filtering or parameterization.
Under conditions where an attacker can control the table (or tableName) parameter, they may inject arbitrary SQL, potentially leading to data exfiltration, tampering, or other impactful database operations.
Affected context
This vulnerability occurs in DataEase deployments that expose the /de2api/datasource/previewData API and accept a user-supplied table (or tableName) parameter as part of data preview functionality.
When the application builds SQL queries by concatenating this parameter directly into the query string, an attacker who can invoke this endpoint—through the UI, an API client, or an integrated system—can influence the resulting SQL.
The risk is elevated in environments where the database account used for preview operations has broad read or write permissions.
Exploit preconditions
- Attack surface: HTTP(S) endpoint
/de2api/datasource/previewData - Required access: Ability to send requests that control the
table/tableNameparameter (e.g., authenticated user with data preview rights, or exposed API parameter in a multi-tenant setup) - Trigger point: Execution of dynamically constructed SQL queries that embed the unvalidated table name directly into the query string
- Why exploitation is possible: The application concatenates user-controlled input into SQL without using parameterized queries, quoting/escaping, or allowlisting of table identifiers, enabling crafted input to alter the intended SQL structure
Why this happens
The underlying issue is the construction of SQL statements using string concatenation that directly incorporates user-controlled input.
Instead of treating the table name as a strictly validated identifier, the application embeds the table / tableName parameter into the SQL command text without parameterization, sanitization, or structural constraints.
This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where attackers can inject additional SQL fragments by leveraging metacharacters and control sequences within the input.
Potential impact
- Attackers may read data from tables they are not intended to access.
- Attackers may modify or delete data if the database role has write or DDL permissions.
- Attackers may infer or manipulate schema metadata, such as listing tables or columns.
- Attackers may chain SQL injection with other weaknesses to escalate privileges or pivot further within the environment.
General mitigation guidance
Effective mitigation centers on eliminating dynamic SQL built from raw user input and enforcing strict control over identifiers:
- Use parameterized queries or prepared statements wherever possible, avoiding string concatenation for SQL command construction.
- Treat table names and other identifiers as untrusted; enforce strict allowlists (e.g., only permit known, configured tables) rather than accepting arbitrary identifier strings.
- Apply robust input validation for any remaining dynamic elements, constraining input to a safe character set and expected patterns (e.g., alphanumeric plus underscore).
- Run database operations under least-privilege accounts that only have the minimal read/write access required for data preview, limiting impact if injection occurs.
- Separate query-building logic from request parsing, and centralize safe SQL construction patterns to reduce the chance of ad hoc concatenation.
How teams detect issues like this
Detection can combine code-centric review with runtime monitoring:
- Static analysis: Configure SAST rules to flag SQL construction via string concatenation, especially where HTTP parameters are used in query-building methods.
- Code review: Look for patterns where
tableortableNameparameters flow directly into query strings; verify the use of prepared statements and allowlists for any dynamic identifiers. - Security testing: Use automated DAST tools and manual penetration testing to probe the
/de2api/datasource/previewDataendpoint with injection tests and monitor for abnormal responses or errors. - Runtime monitoring: Enable database logging (e.g., query logs, audit trails) to detect anomalous queries with unexpected concatenated fragments or comment markers suggestive of injection attempts.

