Summary
Craft CMS has an unauthenticated SQL injection vulnerability in its element search endpoint because an attribute parameter is incorporated into a query unsafely. A remote attacker may be able to read or modify database contents and could alter user records to gain administrator access.
Affected context
The vulnerability affects Craft CMS 4.0.0 before 4.18.9 and 5.0.0 before 5.11.2. It occurs in the element search endpoint when the attribute parameter is used to build a database query without adequate sanitization, in a configuration where emulated PDO prepares permit stacked statements.
Exploit preconditions
- Attack surface: Craft CMS element search endpoint
- Required access: No authentication is required, according to the vulnerability description
- Trigger point: Processing a search request that uses the
attributeparameter - Why exploitation is possible: The parameter is concatenated into a query, and emulated PDO prepares may allow stacked statements
Why this happens
The application constructs SQL using an externally supplied parameter rather than safely separating query structure from data. This is an SQL injection flaw, mapped to CWE-89, and the use of emulated prepares that allow stacked statements can increase the range of possible database operations.
Potential impact
- An attacker may read sensitive data from the database
- An attacker could modify or overwrite database records
- User account data may be altered to enable administrator access
- Application data integrity and confidentiality may be compromised
General mitigation guidance
Defensive patterns include using parameterized queries that keep user-controlled values separate from SQL syntax and disabling emulated prepares where they weaken statement handling. Where query structure cannot be parameterized, such as dynamic identifiers, accept only values from a strict allowlist. Limit database account privileges to the operations the application requires, and avoid exposing sensitive database behavior through unauthenticated endpoints.
How teams detect issues like this
- Use static analysis to identify SQL construction through string concatenation or interpolation of request parameters.
- Review database access code for dynamic identifiers, unsafe query builders, and reliance on emulated prepares.
- Apply code-review and CI policies that require parameter binding for user-controlled values.
- Monitor for unexpected database errors, unusual stacked statements, and unauthorized changes to user or administrator records.

