# CVE-2026-59894: sqlparse: Generated Python and PHP snippets allow SQL string breakout through unescaped backslashes

- Severity: Medium 6.2 (CVSS:4.0, scored by GitHub_M) `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:L`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.13%, higher than 2% of CVEs (2026-12-01)
- Published: 2026-08-17T17:14:22.314Z
- Modified: 2026-10-23T16:10:00.313Z
- Also known as: GHSA-3496-9g83-7v6x, PYSEC-2026-3696
- Weaknesses: CWE-94
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- andialbrecht sqlparse: < 0.6.0
- sqlparse (PyPI): before 0.6.0

## Every score

- GitHub_M: CVSS:4.0 6.2 Medium `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:L`
- GitHub: CVSS:4.0 Medium `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:L`
- PyPA Advisory Database: CVSS:4.0 `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:L`

## References

- <https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-3496-9g83-7v6x> (web)
- <https://github.com/andialbrecht/sqlparse/commit/53ff44b53e27cff78259acc1af015506fea60f63> (web)
- <https://github.com/andialbrecht/sqlparse> (package)
- <https://pypi.org/project/sqlparse> (package)
- <https://github.com/advisories/GHSA-3496-9g83-7v6x> (advisory)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-59894> (advisory)

## Sources

- CVE List: [CVE-2026-59894](https://www.cve.org/CVERecord?id=CVE-2026-59894), CVE Terms of Use, modified 2026-08-17
- GitHub Advisory Database: [GHSA-3496-9g83-7v6x](https://github.com/advisories/GHSA-3496-9g83-7v6x), CC-BY-4.0, modified 2026-09-10
- NVD: [CVE-2026-59894](https://nvd.nist.gov/vuln/detail/CVE-2026-59894), Public domain, modified 2026-10-23
- PyPA Advisory Database: [PYSEC-2026-3696](https://osv.dev/vulnerability/PYSEC-2026-3696), CC-BY-4.0, modified 2026-08-19

---

Page: https://cve.day/CVE-2026-59894 · Whole record: https://cve.day/CVE-2026-59894.json · Rebuilt by cve.day 2026-11-25T22:59:33.371Z
