Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSupply SQL containing ${expr} payload
-
ExploitOutputPHPFilter embeds it unescaped in double-quoted string
-
ExecutionGenerated PHP snippet executed downstream
-
ImpactArbitrary PHP code runs in app context
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that the consuming application (1) calls sqlparse with output_format='php' (the OutputPHPFilter), a non-default and rarely used formatting mode; (2) passes attacker-influenced SQL text through that formatter; and (3) actually executes, includes, or eval()s the resulting PHP snippet. The injectable sink is a double-quoted PHP string, triggered specifically by unescaped '$' characters forming ${expr} or {${expr}} interpolation sequences. Limiting factors: the PHP output format is niche, no exploitation occurs unless the generated code is run as PHP (a pure parse-and-display pipeline is unaffected), and only versions through 0.6.0 are affected (fixed by PR #930). |
| Impact | Signals conflict sharply between nominal severity and realistic exploitability. The CVSS 4.0 base score of 8.4 (High) is driven by dual high impact (VC:H/VI:H) from arbitrary PHP code execution, but the same vector constrains real-world risk: AV:L means the flaw is not remotely reachable on its own, and UI:P reflects that exploitation only lands once the PHP snippet sqlparse generates is actually executed downstream. No EPSS score is provided in the input, so exploitation probability cannot be quantified - this is a data gap, not a low score. The CVE is NOT in CISA KEV and no public exploit code is referenced, so this is best treated as no public exploit identified at time of analysis; do not read the VulnCheck advisory as evidence of in-the-wild use. Practical risk is well below what 8.4 suggests because exploitation depends on a rare, non-default usage pattern (output_format='php') combined with an application that subsequently evaluates the generated code; absent that chain the bug is inert. Bottom line: a genuine code-injection defect worth patching, but a low-urgency, narrow-surface issue rather than a mass-exploitation priority. |
| Exploit ScenarioDerived | An application uses sqlparse's PHP output formatter (output_format='php') to turn user-submitted SQL into a PHP code snippet, then runs or includes that snippet. An attacker submits SQL text containing a ${expr} sequence, which OutputPHPFilter places unescaped inside a double-quoted PHP string, so when the generated snippet executes the embedded PHP expression is evaluated as code. No public proof-of-concept is referenced, though the vendor patch and regression tests publicly demonstrate the exact payload shapes. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Oct 19, 2026
PHP code injection in sqlparse through 0.6.0 can turn crafted SQL text into executable PHP when an application uses the non-default output_format='php' formatter and later runs the generated snippet. The flaw is CWE-94: OutputPHPFilter fails to escape literal dollar signs inside double-quoted PHP strings, so ${expr} or {${expr}} sequences can be interpreted as PHP interpolation. Although the nominal severity is high, exploitation requires a niche formatter plus execution of the generated PHP, and no public exploit was identified at time of analysis.
RemediationAI
Apply the upstream fix in PR #930 (https://github.com/andialbrecht/sqlparse/pull/930), which escapes literal dollar signs in PHP output, or upgrade to a vendor release that contains it; the available data does not confirm a tagged patched version, so patch status is best described as upstream fix available (PR/commit) with a released patched version not independently confirmed. If upgrading is not possible, avoid calling sqlparse.format(..., output_format='php') on untrusted SQL and never include, eval, or otherwise execute the generated PHP. As a compensating control, pre-escape '$' before formatting or post-process the generated snippet, accepting that this may alter displayed SQL and break intended PHP output; disabling the PHP output mode entirely avoids the sink but removes that feature. See the VulnCheck advisory at https://www.vulncheck.com/advisories/sqlparse-through-0.6.0-php-code-injection-via-output-format-php for vendor guidance.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in euvd
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
sqlparse is a Python SQL parser and formatter, not a PHP library; its optional OutputPHPFilter converts parsed SQL into PHP source by embedding token values in double-quoted PHP strings. The vulnerable implementation escaped backslashes and double quotes but not dollar signs. Because PHP double-quoted strings interpolate variables and support complex ${...} syntax, attacker-influenced SQL containing ${expr} or {${expr}} can escape the intended string-data context and inject PHP expressions. This is CWE-94 (Improper Control of Generation of Code), and the CPE cpe:2.3:a:andialbrecht:sqlparse:*:*:*:*:*:*:*:* identifies the sqlparse package. The upstream fix in PR #930 adds .replace('$', '\\$') to the output escaping chain so literal dollar signs are preserved rather than interpreted by PHP.
Know when Sqlparse gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N
Injected PHP only runs when the generated snippet is executed locally (AV:L, UI:R); no privileges are needed to supply the SQL (PR:N); arbitrary PHP code yields full C/I/A impact.
Primary rating from Vendor (VulnCheck).
CVSS VectorVendor: VulnCheck
DescriptionCVE.org
sqlparse through 0.6.0 contains a PHP code injection vulnerability that allows attackers to inject PHP expressions by supplying SQL text containing unescaped dollar signs. Attackers can embed ${expr} or {${expr}} sequences that OutputPHPFilter places in double-quoted strings, executing arbitrary PHP code when the generated snippet runs.
Articles & Coverage 1
Executive ViewAI
sqlparse through 0.6.0 has a high-severity code injection flaw in its non-default PHP output formatter that can cause crafted SQL to become executable PHP when an application later runs the generated snippet. Only applications using that formatter and executing generated PHP are exposed, but those that do could face arbitrary code execution, making inventory and remediation important. No public exploit identified at time of analysis, so leadership should focus on confirming exposure and applying the vendor update.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
Quadratic CPU consumption in sqlparse versions prior to 0.6.0 allows unauthenticated remote denial-of-service via crafte
CPU exhaustion via ReDoS in sqlparse affects all Python applications that pass caller-controlled SQL text to sqlparse.pa
Quadratic CPU exhaustion in sqlparse's reindentation path allows denial of service against any Python application that p
Quadratic CPU consumption in sqlparse's group_comments function (grouping.py) allows remote unauthenticated denial of se
sqlparse is a non-validating SQL parser module for Python. Rated high severity (CVSS 7.5), this vulnerability is remotel
sqlparse is a non-validating SQL parser module for Python. Rated high severity (CVSS 7.5), this vulnerability is remotel
Code injection in sqlparse prior to 0.6.0 allows attackers to escape generated Python and PHP source-code snippets by su
EUVD-2026-104399
GHSA-457h-p88w-wq8p
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB