sqlparse — security advisory
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.
- Products
- sqlparse
- Affected versions
- 0.1.13-2ubuntu2, 0.1.18-1, 0.1.18-1ubuntu0.1~esm1, 0.2.2-1, 0.2.4-0.1, 0.2.4-0.1ubuntu0.1, 0.2.4-0.1ubuntu0.1+esm1, 0.2.4-1, 0.2.4-1build1, 0.2.4-2, 0.2.4-3, 0.2.4-3ubuntu0.1, 0.2.4-3ubuntu0.1+esm1, 0.4.1-1ubuntu1, 0.4.2-1, 0.4.2-1ubuntu0.22.04.1, 0.4.2-1ubuntu0.22.04.2, 0.4.2-1ubuntu0.22.04.3, 0.4.2-1ubuntu1, 0.4.4-1, 0.4.4-1ubuntu0.1, 0.4.4-1ubuntu0.2, 0.5.3-1, 0.5.4-1, 0.5.4-1ubuntu0.1, 0.5.5-2, 0.5.5-2ubuntu1
- Fixed versions
- Not specified
- CVEs
- CVE-2026-59894
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 31 Oct 2026, 02:48 UTC · Revision 1
Source evidence
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.
osv:UBUNTU-CVE-2026-59894
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
sqlparse
Fixed versions: Not specified
Complete source record
{
"id": "07b1baa8d3dcd6a2122de5c5b8c37663a432b78363b9b9a51510d133a3c6323b",
"url": "https://osv.dev/vulnerability/UBUNTU-CVE-2026-59894",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "UBUNTU-CVE-2026-59894",
"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.",
"evidence": "osv:UBUNTU-CVE-2026-59894",
"products": [
{
"name": {
"value": "sqlparse",
"evidence": "/affected/0/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.1.13-2ubuntu2",
"evidence": "/affected/0/versions"
},
{
"value": "0.1.18-1",
"evidence": "/affected/0/versions"
},
{
"value": "0.1.18-1ubuntu0.1~esm1",
"evidence": "/affected/0/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/1/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.2.2-1",
"evidence": "/affected/1/versions"
},
{
"value": "0.2.4-0.1",
"evidence": "/affected/1/versions"
},
{
"value": "0.2.4-0.1ubuntu0.1",
"evidence": "/affected/1/versions"
},
{
"value": "0.2.4-0.1ubuntu0.1+esm1",
"evidence": "/affected/1/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/2/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.2.4-1",
"evidence": "/affected/2/versions"
},
{
"value": "0.2.4-1build1",
"evidence": "/affected/2/versions"
},
{
"value": "0.2.4-2",
"evidence": "/affected/2/versions"
},
{
"value": "0.2.4-3",
"evidence": "/affected/2/versions"
},
{
"value": "0.2.4-3ubuntu0.1",
"evidence": "/affected/2/versions"
},
{
"value": "0.2.4-3ubuntu0.1+esm1",
"evidence": "/affected/2/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/3/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.4.1-1ubuntu1",
"evidence": "/affected/3/versions"
},
{
"value": "0.4.2-1",
"evidence": "/affected/3/versions"
},
{
"value": "0.4.2-1ubuntu0.22.04.1",
"evidence": "/affected/3/versions"
},
{
"value": "0.4.2-1ubuntu0.22.04.2",
"evidence": "/affected/3/versions"
},
{
"value": "0.4.2-1ubuntu0.22.04.3",
"evidence": "/affected/3/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/4/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.4.2-1ubuntu1",
"evidence": "/affected/4/versions"
},
{
"value": "0.4.4-1",
"evidence": "/affected/4/versions"
},
{
"value": "0.4.4-1ubuntu0.1",
"evidence": "/affected/4/versions"
},
{
"value": "0.4.4-1ubuntu0.2",
"evidence": "/affected/4/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/5/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.5.4-1",
"evidence": "/affected/5/versions"
},
{
"value": "0.5.5-2",
"evidence": "/affected/5/versions"
},
{
"value": "0.5.5-2ubuntu1",
"evidence": "/affected/5/versions"
}
]
},
{
"name": {
"value": "sqlparse",
"evidence": "/affected/6/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "0.5.3-1",
"evidence": "/affected/6/versions"
},
{
"value": "0.5.4-1",
"evidence": "/affected/6/versions"
},
{
"value": "0.5.4-1ubuntu0.1",
"evidence": "/affected/6/versions"
}
]
}
],
"severity": "medium",
"structured": {
"id": "UBUNTU-CVE-2026-59894",
"aliases": [
"UBUNTU-CVE-2026-59894"
],
"metrics": [
{
"type": "CVSS_V4",
"score": "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"
},
{
"type": "Ubuntu",
"score": "medium"
}
],
"affected": [
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=esm-infra-legacy%2Fxenial",
"ecosystem": "Ubuntu:Pro:16.04:LTS"
},
"versions": [
"0.1.13-2ubuntu2",
"0.1.18-1",
"0.1.18-1ubuntu0.1~esm1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.1.18-1ubuntu0.1~esm1"
},
{
"binary_name": "python-sqlparse",
"binary_version": "0.1.18-1ubuntu0.1~esm1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.1.18-1ubuntu0.1~esm1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.1.18-1ubuntu0.1~esm1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=esm-infra%2Fbionic",
"ecosystem": "Ubuntu:Pro:18.04:LTS"
},
"versions": [
"0.2.2-1",
"0.2.4-0.1",
"0.2.4-0.1ubuntu0.1",
"0.2.4-0.1ubuntu0.1+esm1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1+esm1"
},
{
"binary_name": "python-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1+esm1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1+esm1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.2.4-0.1ubuntu0.1+esm1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=esm-infra%2Ffocal",
"ecosystem": "Ubuntu:Pro:20.04:LTS"
},
"versions": [
"0.2.4-1",
"0.2.4-1build1",
"0.2.4-2",
"0.2.4-3",
"0.2.4-3ubuntu0.1",
"0.2.4-3ubuntu0.1+esm1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.2.4-3ubuntu0.1+esm1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.2.4-3ubuntu0.1+esm1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.2.4-3ubuntu0.1+esm1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=jammy",
"ecosystem": "Ubuntu:22.04:LTS"
},
"versions": [
"0.4.1-1ubuntu1",
"0.4.2-1",
"0.4.2-1ubuntu0.22.04.1",
"0.4.2-1ubuntu0.22.04.2",
"0.4.2-1ubuntu0.22.04.3"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.4.2-1ubuntu0.22.04.3"
},
{
"binary_name": "sqlformat",
"binary_version": "0.4.2-1ubuntu0.22.04.3"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=noble",
"ecosystem": "Ubuntu:24.04:LTS"
},
"versions": [
"0.4.2-1ubuntu1",
"0.4.4-1",
"0.4.4-1ubuntu0.1",
"0.4.4-1ubuntu0.2"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.4.4-1ubuntu0.2"
},
{
"binary_name": "sqlformat",
"binary_version": "0.4.4-1ubuntu0.2"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=stonking",
"ecosystem": "Ubuntu:26.10"
},
"versions": [
"0.5.4-1",
"0.5.5-2",
"0.5.5-2ubuntu1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.5.5-2ubuntu1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.5.5-2ubuntu1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse?arch=source&distro=resolute",
"ecosystem": "Ubuntu:26.04:LTS"
},
"versions": [
"0.5.3-1",
"0.5.4-1",
"0.5.4-1ubuntu0.1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2026/UBUNTU-CVE-2026-59894.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.5.4-1ubuntu0.1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.5.4-1ubuntu0.1"
}
]
}
}
],
"modified": "2026-10-17T12:59:14.244143260Z",
"provider": "osv",
"upstream": [
"CVE-2026-59894"
],
"references": [
"https://ubuntu.com/security/CVE-2026-59894",
"https://www.cve.org/CVERecord?id=CVE-2026-59894",
"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-3496-9g83-7v6x"
]
},
"related_cves": [
{
"value": "CVE-2026-59894",
"evidence": "/upstream"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 359506,
"published_at": "2026-08-17T18:17:00+00:00"
}