Symfony Vulnerable to SQL Injection in PdoAdapter::doClear() via Unsanitized $prefixGHSA-6qh9-h6wf-jgqc
Fix: symfony/symfony@ec50b79GHSA-6qh9-h6wf-jgqc is a SQL Injection vulnerability in symfony/cache. A fix is available for symfony/cache — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-6qh9-h6wf-jgqc.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
Real-World Exposure
symfony/cache🐘symfony/cache🐘symfony/cache🐘symfony/cache🐘symfony/symfony🐘symfony/symfony🐘symfony/symfony🐘symfony/symfonyReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.
Description
Description
Symfony\Component\Cache\Adapter\PdoAdapter is the PDO-backed cache adapter. Its clear($prefix) method (inherited from AbstractAdapterTrait) is documented to delete cache items whose key starts with $prefix.
In the non-versioning code path, the caller-supplied $prefix is concatenated into $namespace = $this->namespace.$prefix and passed to PdoAdapter::doClear(), which builds:
DELETE FROM <table> WHERE <id_col> LIKE '<namespace>%'
The value is interpolated directly into the SQL text and executed with PDO::exec(): $namespace is not bound. A caller able to influence $prefix can break out of the literal and inject SQL, expanding deletion scope from the intended prefix to arbitrary rows, or otherwise reshape query semantics.
Most applications don't expose clear($prefix) to untrusted input directly, but the contract of the method is to safely accept any prefix string, so the lack of escaping is a defect of the adapter itself.
Resolution
AbstractAdapterTrait::clear() now rejects any $prefix containing characters outside [-+.A-Za-z0-9]: when an invalid prefix is supplied, the method logs a warning and returns false instead of reaching the SQL layer. This blocks quotes, %, null bytes and other characters that would let an attacker break out of the LIKE literal.
The patch for this issue is available here for branch 5.4.
Credits
Symfony would like to thank secsys_codex for reporting the issue and Nicolas Grekas for fixing it.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐘Packagist | symfony/cache | all versions | 5.4.52composer require symfony/cache:^5.4.52 |
| 🐘Packagist | symfony/cache | ≥ 6.0.0&&< 6.4.40 | 6.4.40composer require symfony/cache:^6.4.40 |
| 🐘Packagist | symfony/cache | ≥ 7.0.0&&< 7.4.12 | 7.4.12composer require symfony/cache:^7.4.12 |
| 🐘Packagist | symfony/cache | ≥ 8.0.0&&< 8.0.12 | 8.0.12composer require symfony/cache:^8.0.12 |
| 🐘Packagist | symfony/symfony | all versions | 5.4.52composer require symfony/symfony:^5.4.52 |
| 🐘Packagist | symfony/symfony | ≥ 6.0.0&&< 6.4.40 | 6.4.40composer require symfony/symfony:^6.4.40 |
Affected Products
symfonysensiolabsDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for symfony/cache, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update symfony/cache to 5.4.52 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-6qh9-h6wf-jgqc is resolved across your whole dependency graph.
Workarounds
Until you can upgrade, make sure every query built from user input uses parameterised statements or a prepared-statement API rather than string concatenation, and reduce the database account's privileges so an injected query cannot read or alter data beyond what the feature needs.
Frequently Asked Questions
Is GHSA-6qh9-h6wf-jgqc in your dependencies?
Find it across Packagist, including transitive dependencies.