Summary
DataEase versions 2.10.20 and below contain a SQL injection vulnerability in the /de2api/datasetData/previewSql API, where user-supplied SQL is embedded into a subquery without enforcing that it is a single, safe SELECT statement.
In combination with a JDBC blocklist bypass that allows enabling allowMultiQueries=true, an authenticated attacker with valid datasource credentials can execute arbitrary stacked SQL statements, potentially achieving full read and write access to the connected database.
Affected context
This vulnerability appears in DataEase deployments (2.10.20 and below) where:
- The /de2api/datasetData/previewSql endpoint is exposed to authenticated users
- User-provided SQL text is passed through to the database as part of a subquery
- The JDBC configuration can be influenced such that allowMultiQueries=true is enabled
In such environments, the application treats user SQL as trusted and does not strictly constrain it to a single, read-only SELECT operation before sending it to the underlying database.
Exploit preconditions
- Attack surface: HTTP(S) API endpoint at /de2api/datasetData/previewSql
- Required access: Authenticated access to DataEase with permission to use a datasource and valid datasource credentials configured in the application
- Trigger point: Submission of crafted SQL to the previewSql endpoint that breaks out of the intended subquery and leverages multi-statement execution
- Why exploitation is possible:
- The application wraps user SQL in a subquery but does not enforce that it is a single SELECT statement
- Input is not normalized or parsed to prevent additional statements
- A JDBC blocklist bypass allows enabling allowMultiQueries=true, permitting stacked statements
- Database privileges associated with the configured datasource are typically broad (read/write), magnifying impact
Why this happens
The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
DataEase allows user-supplied SQL text to be incorporated directly into a database query template and executed by the JDBC driver. The wrapping of the input in a subquery is treated as sufficient isolation, but the system fails to:
- Enforce that the input is a single, syntactically constrained SELECT statement
- Reject or sanitize statement terminators and control tokens that enable stacked queries
- Prevent multi-statement execution (allowMultiQueries=true) from being leveraged by user-controlled SQL
This design implicitly trusts user SQL and relies on an incomplete structural constraint, rather than using parameterization, a safe query builder, or a dedicated SQL parsing/validation layer. As a result, attackers can inject additional UPDATE/DELETE/INSERT statements and other operations beyond the intended read-only preview behavior.
Potential impact
- Full read access to tables within the connected database using the configured datasource account
- Unauthorized modification of data via injected UPDATE, INSERT, or DELETE statements
- Creation or alteration of database objects (e.g., tables, views, indexes) where privileges allow
- Tampering with analytics results by modifying underlying datasets
- Potential escalation to broader database compromise if injected statements can change credentials or access controls
- Destructive operations such as data wiping or corruption, depending on database permissions
General mitigation guidance
Effective mitigation centers on treating user SQL as untrusted and strictly constraining or eliminating direct execution paths:
- Limit functionality scope: Where possible, avoid accepting arbitrary SQL text from users; instead, provide controlled query builders, parameterized filters, or whitelisted query templates.
- Enforce read-only semantics: If arbitrary SQL must be accepted for preview purposes, enforce that queries are read-only:
- Use a SQL parser or database-specific mechanisms to ensure only a single SELECT statement without side effects is allowed.
- Reject statements containing delimiters, stacked queries, or modification keywords.
- Disable multi-statement execution: Configure database connections to disallow multi-query execution (e.g., disallow allowMultiQueries or equivalent), and treat any configuration that re-enables it as a security-sensitive change requiring review.
- Apply least-privilege database accounts: Use datasource credentials with minimal necessary permissions (ideally read-only for preview functionality) to reduce blast radius if injection occurs.
- Centralize query construction patterns: Implement a standardized abstraction or service for executing user-driven queries that enforces validation and policy, rather than constructing SQL directly in endpoint handlers.
- Defense in depth: Introduce application-level guards such as query length limits, keyword blocklists/allowlists (as a supplement, not a primary defense), and stricter role-based access around features that accept SQL input.
How teams detect issues like this
Detection can rely on both code-level analysis and operational monitoring:
- Static analysis and code review:
- Search for endpoints or services that accept raw SQL strings from HTTP parameters or request bodies.
- Flag any code paths that concatenate user input into SQL strings or templates, especially when passed directly to JDBC execute/executeQuery.
- Review JDBC configuration for options enabling multi-statement execution (e.g., allowMultiQueries=true) and treat them as high-risk patterns.
- Examine logic that attempts to "wrap" user SQL in subqueries or templates without using a real SQL parser; these are strong signals of potential SQL injection.
- Configuration and policy enforcement:
- Enforce policies that block dangerous JDBC connection parameters in configuration repositories or deployment pipelines.
- Use CI checks to detect introduction of raw SQL execution APIs where user input is involved.
- Runtime and logging analysis:
- Monitor database logs for anomalous patterns, such as multiple statements in a single request or unexpected DML/DDL commands originating from the application.
- Instrument the previewSql endpoint with enhanced logging that records query patterns (without sensitive data) and alert on presence of suspicious tokens (e.g., statement terminators, comment injection patterns).
- Automated tooling:
- Employ SAST tools configured with rules for CWE-89 and JDBC multi-query options.
- Periodically run dynamic application security testing focused on endpoints that accept SQL or query-like input.

