Summary
A critical SQL injection vulnerability in NocoBase's checkSQL function may allow attackers to manipulate database queries through crafted input. Successful exploitation could expose sensitive database information when the affected function processes attacker-controlled data without adequate query separation or validation.
Affected context
The vulnerability occurs in NocoBase v2.1.21 where the checkSQL function handles input that can influence database queries. Risk depends on whether an attacker can reach the function through an exposed application endpoint or workflow and whether the resulting database account has access to sensitive records.
Exploit preconditions
- Attack surface: An application interface, API endpoint, or workflow that invokes the
checkSQLfunction - Required access: Any access level permitted to submit or influence the relevant input, depending on deployment configuration
- Trigger point: Processing of attacker-controlled input by the database query construction or validation logic
- Why exploitation is possible: Input may be incorporated into SQL statements without sufficient parameterization, allowing query structure to be altered
Why this happens
The underlying bug is a failure to maintain a strict separation between SQL code and external data. When the checkSQL function constructs or evaluates queries using insufficient parameterization, validation, or escaping, specially crafted input can be interpreted as part of the SQL statement rather than as a data value. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- Attackers may read sensitive database records
- Database metadata or application configuration may be exposed
- Unauthorized query behavior could occur within the database account's permissions
- Data integrity could be affected if the vulnerable context permits write operations
- Further compromise may be possible when database credentials or stored secrets are accessible
General mitigation guidance
Mitigation generally focuses on eliminating the mixing of SQL syntax and untrusted input.
Common defensive patterns include:
- Use parameterized queries, prepared statements, or query-builder APIs that keep values separate from SQL structure
- Apply allowlisted validation for inputs that represent identifiers, operators, or other query components
- Avoid relying on escaping alone as the primary protection
- Restrict database accounts to the minimum read and write permissions required
- Reduce exposure of database errors and sensitive query results
- Treat client-controlled filters, sorting fields, and query expressions as untrusted by default
How teams detect issues like this
Organizations can identify SQL injection risks through:
- Static analysis rules for string concatenation or interpolation in SQL construction
- Code review checks for raw query APIs and dynamic query fragments
- Tests that verify user-controlled values are passed as parameters rather than embedded in statements
- Runtime monitoring for anomalous query patterns, unexpected database errors, and unusual data-access volume
- Policy enforcement that requires approved database-access abstractions for application code
Automated application-security and code-review tools may help identify unsafe query construction, but findings should be validated against the actual data flow and database context.

