Vulnerabilities in pkg:pypi/sqlparse
PACKAGECVE-2026-84305 is a MODERATE reindentation of tuple lists causes vulnerability (CWE-407: Inefficient Algorithmic Complexity) affecting sqlparse libraries in the PyPI ecosystem. The issue involves reindentation of tuple lists causes near-cap quadratic cpu consumption. Remediation is available by upgrading affected packages to version 0.6.0.
pkg:pypi/sqlparse
Vulnerability advisories affecting package pkg:pypi/sqlparse. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-cfqr-cjx5-5jcm | CVE-2026-84305 | MODERATE | sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption |
| GHSA-prg7-hcfm-mfcr | CVE-2026-59893 | HIGH | sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service) |
| GHSA-pwgv-4x5q-6m9f | CVE-2026-54284 | HIGH | sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger |
| GHSA-f2ff-p2ww-7p4p | CVE-2026-71491 | HIGH | sqlparse: Quadratic O(n²) DoS in group_comments |
| GHSA-3496-9g83-7v6x | CVE-2026-59894 | MODERATE | sqlparse: Generated Python and PHP snippets allow SQL string breakout through unescaped backslashes |
| GHSA-27jp-wm6q-gp25 | - | MODERATE | sqlparse: formatting list of tuples leads to denial of service |
| GHSA-rrm6-wvj7-cwh2 | CVE-2023-30608 | MODERATE | sqlparse contains a regular expression that is vulnerable to Regular Expression Denial of Service |
| GHSA-p5w8-wqhj-9hhf | CVE-2021-32839 | HIGH | StripComments filter contains a regular expression that is vulnerable to ReDOS (Regular Expression Denial of Service) |
| GHSA-2m57-hf25-phgg | CVE-2024-4340 | HIGH | sqlparse parsing heavily nested list leads to Denial of Service |
| GHSA-62qf-jcq8-8gxw | - | HIGH | Duplicate Advisory: sqlparse parsing heavily nested list leads to Denial of Service |
CVE-2026-84305 at a Glance
How to Fix CVE-2026-84305
To remediate this vulnerability, upgrade all affected sqlparse dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install sqlparse>=0.6.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show sqlparse
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-84305, inspect your installed packages using pip:
pip show sqlparse
Analyze the terminal output to locate any version of sqlparse in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.6.0), your application is affected.
Note: The pip show sqlparse command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-407: Inefficient Algorithmic Complexity, where an algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached. In sqlparse, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-84305 Affected sqlparse Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sqlparse
|
PyPI |
< 0.6.0
|
0.6.0
|
References
Frequently Asked Questions
What is CVE-2026-84305?
Which sqlparse versions are affected?
What version fixes CVE-2026-84305?
Is sqlparse affected?
What CWE is associated with CVE-2026-84305?
How can I check PyPI dependencies for CVE-2026-84305?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-cfqr-cjx5-5jcm",
"modified" : "2026-09-01T21:20:11Z",
"published" : "2026-09-01T21:20:11Z",
"aliases" : [ "CVE-2026-84305" ],
"summary" : "sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption",
"details" : "### Summary\n\nWhen SQL is formatted with reindentation enabled, `ReindentFilter` repeatedly rebuilds prefixes of the current statement to calculate token offsets. An attacker who controls SQL sent to this opt-in formatting path can supply a parenthesized tuple list that remains just below the grouping-token cap. Thousands of offset calculations then traverse an expanding token tree, causing multi-second CPU consumption from an input of roughly 16 KB and degrading service availability.\n\n### Details\n\n`ReindentFilter._get_offset()` joins the tokens returned by `_flatten_up_to_token()` to calculate the current output position. Each call begins by flattening the current statement from its start and walks until the target token. Tuple-list reindentation invokes this calculation repeatedly as it processes many parenthesized values, so later calls redo an increasingly large amount of prior work.\n\nThe vulnerable path is reached through `sqlparse.format(sql, reindent=True)` and `sqlformat --reindent`. A carefully sized tuple list completes grouping below the configured token cap and then enters the expensive reindentation path; a slightly larger input may instead be rejected quickly by the cap.\n\nRelevant code locations:\n\n- `sqlparse/formatter.py:170` — enabling `ReindentFilter`\n- `sqlparse/filters/reindent.py:30` — repeated flattening from the statement start\n- `sqlparse/filters/reindent.py:44` — prefix joining for offset calculation\n- `sqlparse/filters/reindent.py:216` — tuple-list processing path\n\n### PoC\n\nA complete validated reproduction is attached as [reindent_tuple_list_cpu_dos-poc.zip](https://github.com/user-attachments/files/29410152/reindent_tuple_list_cpu_dos-poc.zip). The archive contains `reproduction/` at its root, uses Git and Docker, and compares two same-shape tuple-list inputs formatted with reindentation enabled.\n\nExtract the archive beside this report, then run:\n\n```console\n./reproduction/run.sh\n```\n\nObserved result:\n\nThe 600-tuple baseline completed in 0.649 seconds, while the below-cap 1,425-tuple input completed in 4.999 seconds. The run emitted `EVOHUNT_REINDENT_DOS_VERIFIED` and completed successfully.\n\nVerification method:\n\nThe verification helper formats two same-shape tuple-list payloads with `reindent=True` and fails unless the larger payload completes successfully, takes at least 2.0 seconds, and takes at least 4x the baseline.\n\nLimitations:\n\nNo reproduction blocker was recorded. Timing varies by host, and exploitation requires the reindentation option or corresponding CLI mode to be enabled.\n\n### Impact\n\nThis is a CPU resource-exhaustion vulnerability in workflows that reindent attacker-controlled SQL. A small crafted tuple-list input can occupy a worker for several seconds, enabling request delays, reduced throughput, or worker starvation when payloads are processed repeatedly or concurrently.\n\nThe affected reindentation behavior is opt-in, and sqlparse itself does not provide network exposure; reachability depends on the consuming application or CLI workflow. The demonstrated effect is CPU consumption in a single formatting call, not process termination, code execution, or confidentiality or integrity impact.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "sqlparse"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.6.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.5.5"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-cfqr-cjx5-5jcm"
}, {
"type" : "WEB",
"url" : "https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/andialbrecht/sqlparse"
}, {
"type" : "WEB",
"url" : "https://github.com/andialbrecht/sqlparse/releases/tag/0.6.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-407" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-01T21:20:11Z",
"nvd_published_at" : null
}
}