Summary
A SQL injection vulnerability in Symfony's PdoAdapter::doClear() allows untrusted prefix values to be embedded directly into a dynamically constructed DELETE query.
When an attacker can control the $prefix parameter, they may break out of the intended LIKE clause and manipulate query semantics or the scope of cache-key deletion.
Affected context
This vulnerability appears in applications using Symfony's cache component with the PDO-based adapter, where cache clear operations rely on a caller-supplied $prefix.
Risk is present when the prefix originates from, or can be influenced by, user input or external configuration rather than being fully hard-coded.
The issue manifests in environments where the database user for the cache connection has privileges that allow broad DELETE operations on the cache table or other related tables.
Exploit preconditions
- Attack surface: Cache-clearing functionality calling
PdoAdapter::doClear()with a dynamic$prefix. - Required access: Ability to influence or control the value of
$prefix(e.g., via request parameters, headers, configuration, or multi-tenant identifiers). - Trigger point: Execution of the DELETE query inside
doClear()that concatenates$prefixinto a LIKE clause without binding or escaping. - Why exploitation is possible: The
$prefixvalue is embedded directly into the SQL string, allowing crafted input to escape the literal context and alter WHERE conditions or deletion scope.
Why this happens
The underlying bug is a classical SQL injection issue mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command.
Instead of using parameterized queries or safely escaped placeholders, PdoAdapter::doClear() builds a DELETE statement that includes the $prefix variable inline in the SQL.
This design trusts the prefix and treats it as a benign fragment of a LIKE pattern, but when the prefix is attacker-controlled, meta-characters and additional SQL can change query semantics and affect which rows are deleted.
Potential impact
- Cache entries for other prefixes may be deleted, impacting isolation between tenants or components.
- Application behavior can be disrupted by targeted removal of critical cached data.
- Depending on schema and query construction, an attacker could manipulate WHERE conditions to broaden deletion scope.
- In misconfigured environments, the issue could contribute to more serious data integrity problems if cache tables share a database with sensitive application data.
General mitigation guidance
Effective mitigation focuses on eliminating direct string concatenation in SQL and reducing trust in dynamic prefixes.
Recommended patterns include:
- Using parameterized queries and bound parameters for all dynamic values, including prefixes used in LIKE clauses.
- Applying strict validation and normalization to prefix values, restricting them to expected character sets and formats.
- Designing cache schemas and database roles so that the cache adapter operates with least-privilege and cannot affect non-cache data.
- Encapsulating cache-key generation so that user input cannot directly become a prefix without canonicalization and safety checks.
How teams detect issues like this
Detection commonly involves:
- Static analysis rules that flag SQL construction via string concatenation, particularly around cache or utility components.
- Code review practices that require parameterized queries for any variable included in SQL, and scrutiny of helper methods like
doClear(). - Application security testing that exercises cache-clear endpoints with crafted prefix values to confirm they cannot alter query semantics.
- Policy enforcement in CI pipelines, using linters or SAST tools configured to detect non-parameterized SQL usage in data access layers.

