Summary
NocoDB contained a SQL injection vulnerability where an authenticated user with the Creator role could inject arbitrary SQL through the unit parameter of the DATEADD formula.
When exploited, this issue can allow manipulation or disclosure of database contents under the permissions of the NocoDB application.
Affected context
This vulnerability occurs in NocoDB deployments that:
- Expose formula functionality to authenticated users with the Creator role
- Support the
DATEADDformula in spreadsheet-like views or formula fields - Construct SQL queries using user-controlled formula parameters without proper sanitization or parameterization
It is most relevant in environments where Creators can define or modify formulas that are translated into backend SQL queries.
Exploit preconditions
- Attack surface: Application formula handling and query-generation layer backing NocoDB's spreadsheet/database views.
- Required access: Valid authenticated account with at least the Creator role, allowing definition or editing of formulas.
- Trigger point: Evaluation or persistence of a
DATEADDformula where theunitparameter is accepted and subsequently used to construct SQL. - Why exploitation is possible: The
unitparameter of theDATEADDformula is incorporated into SQL statements without strong validation, escaping, or use of parameterized queries, allowing crafted input to alter the intended query structure.
Why this happens
The underlying issue is a classic SQL injection flaw, aligning with CWE-89: Improper Neutralization of Special Elements used in an SQL Command.
NocoDB's formula engine takes the unit parameter from the DATEADD formula—intended to specify time units like days or months—and feeds it into SQL query construction in a way that treats it as part of the SQL syntax rather than as data.
Because this parameter is not strictly validated against an allowlist of legitimate unit values and is not safely parameterized, an attacker with Creator privileges can craft input that injects additional SQL fragments, effectively modifying or extending the query executed by the backend database.
Potential impact
- Reading data from tables that the application has access to, beyond what the user's UI normally exposes.
- Modifying or deleting records, potentially corrupting application state and business data.
- Escalating impact by chaining with other misconfigurations (e.g., overly privileged database accounts).
- Inferring database schema and structure through error-based or blind injection techniques.
- Potential pivoting to other application functionalities that rely on the compromised data.
General mitigation guidance
Effective mitigation focuses on strict separation between user input and SQL logic within the formula and query-generation engine:
- Treat all formula parameters, including
unitinDATEADD, as data and pass them via parameterized queries or bind variables wherever possible. - Enforce strong validation and allowlisting for formula parameters that represent enums (e.g.,
second,minute,hour,day,week,month,year), rejecting any value outside the predefined set. - Centralize query construction logic so that user-controlled values never directly influence SQL keywords or structural elements (e.g., operators, identifiers, clauses).
- Apply least-privilege principles to the database account used by NocoDB, limiting the blast radius if an injection flaw is present.
- Design formula languages and expression evaluators to be compiled into a safe, intermediate representation before mapping to SQL, reducing direct string concatenation.
How teams detect issues like this
Organizations can detect and monitor for this class of issue using a combination of static and dynamic approaches:
- Static analysis: Scan the codebase for string-based SQL construction where formula parameters or other user inputs are concatenated directly into queries; flag any usage of formula components in SQL without parameter binding or strict validation.
- Code review: Pay special attention to formula evaluation logic and query-builders, looking for:
- Lack of allowlists for enum-like parameters.
- Conditional string concatenation to build
WHERE,ORDER BY, or function arguments from user-controlled values. - Dynamic testing: Use application-level security tests (including SAST/DAST) that exercise formula creation features, attempting to inject SQL through parameters like
unit. - Monitoring and logging: Instrument database and application logs to detect anomalous queries, unusual errors, or patterns indicative of injection (e.g., unexpected comments, stacked queries, or tautological conditions).
- Policy enforcement: Incorporate automated checks in CI/CD pipelines to prevent introduction of new query-building patterns that rely on unvalidated string concatenation.

