sqlparse: Generated Python and PHP snippets allow SQL string breakout through unescaped backslashes
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- Passive
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Code execution
- Confidentiality · integrity · availability
- None · None · None
- Fix status
- Partial Red Hat: 12 without a fix
Attack profile from CVSS 4.0 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-94.
Summary
sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, sqlparse/filters/output.py fails to escape existing backslashes before quotes in sqlparse.format output_format='python' and output_format='php' and the corresponding sqlformat -l modes, allowing crafted SQL to terminate the generated string and inject Python or PHP code when a downstream consumer executes or imports the generated source. This issue is fixed in version 0.6.0.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| andialbrecht | sqlparse | before 0.6.0 | 0.6.0 | Patch available | CNA |
| — | sqlparse (PyPI) | before 0.6.0 | 0.6.0 | Patch available | GHSA-3496-9g83-7v6x |
- sqlparse Vendorandialbrecht Affected before 0.6.0 Fixed in 0.6.0 Patch available CNA
- sqlparse (PyPI) Vendor— Affected before 0.6.0 Fixed in 0.6.0 Patch available GHSA-3496-9g83-7v6x
Remediation
- Fix · CNA sqlparse (andialbrecht) Fixed in 0.6.0
- Fix · GHSA-3496-9g83-7v6x sqlparse (PyPI) Fixed in 0.6.0 Advisory →
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Ansible Automation Platform 2 | Affected | No fix yet: Fix deferred |
| Red Hat Discovery 2 | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift AI (RHOAI) | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift Container Platform 4 | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift Container Platform 5 | Affected | No fix yet: Fix deferred |
| Red Hat OpenStack Platform 16.2 | Affected | No fix planned: Out of support scope |
| Red Hat OpenStack Platform 17.1 | Affected | No fix planned: Out of support scope |
| Red Hat OpenStack Platform 18.0 | Affected | No fix yet: Fix deferred |
| Red Hat Satellite 6 | Affected | No fix yet: Fix deferred |
| Red Hat Update Infrastructure 4 for Cloud Providers | Affected | No fix planned: Out of support scope |
| Red Hat Update Infrastructure 5 | Affected | No fix yet: Fix deferred |
| Self-service automation portal 2 | Affected | No fix yet: Fix deferred |
Timeline
- 2026-10-02 Threatist record created from CVE-2026-59894
- 2026-10-03 Alias added: GHSA-3496-9g83-7v6x
- 2026-11-06 Affected versions changed · Red Hat
References
More andialbrecht vulnerabilities
- TI-2026-39184 sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger CVSS 4.0HIGH 8.7
- TI-2026-42707 sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service) CVSS 3.1HIGH 7.5
- TI-2026-57940 sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption CVSS 4.0MEDIUM 5.1
- TI-2026-50099 sqlparse: Quadratic O(n²) DoS in group_comments CVSS 4.0HIGH 8.7
- TI-2026-76501 PHP code injection in sqlparse via output_format='php' CVSS 4.0HIGH 8.4
Sources
- CVE-2026-59894 · CVE Program
- CVE-2026-59894 · NVD
- FIRST EPSS
- GHSA-3496-9g83-7v6x · GitHub Advisory Database · CC BY 4.0
- CVE-2026-59894 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences