Summary
Craft CMS contains a blind SQL injection flaw in sandbox-exposed navigation methods that accept element criteria. An authenticated control panel user may be able to use crafted criteria in a rendered template to infer database information through conditional query behavior.
Affected context
The issue affects Craft CMS 4.0.0 before 4.18.9 and 5.0.0 before 5.11.2. It occurs when sandbox-exposed getNext() or getPrev() methods pass criteria arrays to Craft::configure() without removing SQL-bearing properties such as orderBy and where.
Exploit preconditions
- Attack surface: Craft CMS control panel functionality involving sandboxed templates and element navigation
- Required access: An authenticated control panel account able to supply relevant input
- Trigger point: A crafted
elementIdsvalue is processed by a rendered template that invokesgetNext()orgetPrev() - Why exploitation is possible: SQL-bearing criteria can reach database query construction, potentially exposing a conditional SQL oracle under the Craft database account
Why this happens
The underlying flaw is improper neutralization of special elements in SQL commands, mapping to CWE-89: SQL Injection. The navigation methods accept arbitrary criteria and pass them into configuration without excluding properties that can influence SQL generation. As a result, attacker-controlled values may affect database query behavior rather than being limited to safe, validated criteria.
Potential impact
- An attacker could infer information from database responses through conditional behavior.
- Database contents available to the Craft database account may be exposed, depending on query access and deployment controls.
- Sensitive application or user data may be at risk if it can be reached through affected queries.
General mitigation guidance
Defensive approaches focus on preventing untrusted criteria from influencing SQL construction:
- Allowlist supported criteria and reject or discard SQL-bearing properties that are not required.
- Use parameterized query interfaces for values and avoid accepting caller-controlled SQL fragments.
- Validate and normalize inputs before they reach query-building or configuration APIs.
- Limit database account privileges to the minimum required by the application.
- Keep template and control panel access restricted to trusted users, reducing exposure of the input path.
How teams detect issues like this
Review query-building paths for arbitrary criteria arrays passed into configuration or database APIs, especially properties such as orderBy and where.
Static analysis and code review can flag user-controlled values reaching SQL construction without allowlisting or parameterization. Runtime monitoring may also look for unusual control panel requests and repeated database queries whose outcomes vary conditionally. Policy checks can require parameterized queries and explicit validation of query criteria.

