Description
sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, sqlparse.format(sql, reindent=True) and sqlformat --reindent route attacker-controlled parenthesized tuple lists through ReindentFilter._get_offset() in sqlparse/filters/reindent.py, where _flatten_up_to_token() repeatedly rebuilds and joins the statement prefix. Thousands of offset calculations walk an expanding token tree, producing quadratic CPU consumption for inputs that remain below MAX_GROUPING_TOKENS and causing request delays, reduced throughput, or worker starvation. This issue is fixed in version 0.6.0.
Published: 2026-09-01
Score: 5.1 Medium
EPSS: < 1% Very Low
KEV: No
Impact: Denial of Service
Action: Apply Patch
AI Analysis

Impact

sqlparse is a non‑validating Python SQL parser. Prior to version 0.6.0, its format function with the reindent argument or the sqlformat command would route attacker‑controlled parenthesized tuple lists through ReindentFilter._get_offset(). The ReindentFilter repeatedly rebuilds and joins the statement prefix, producing a near‑cubic CPU consumption for inputs that remain below MAX_GROUPING_TOKENS. This excessive CPU usage can lead to request delays, reduced throughput, or worker starvation, effectively delivering a denial‑of‑service to services that rely on the library. The weakness is an example of inefficient algorithmic complexity (CWE‑407).

Affected Systems

All installations of the andialbrecht:sqlparse package with a version earlier than 0.6.0 are vulnerable, including any Python applications that import or depend on sqlparse. The vulnerability is fixed in release 0.6.0 and later, so any users of older releases on any platform that runs Python are impacted.

Risk and Exploitability

The CVSS score of 5.1 indicates moderate severity, but the lack of an exploitable code path outside resource exhaustion means typical scanners cannot demonstrate remote code execution; instead the threat space is the potential for local or remote users to supply malicious SQL strings. EPSS is unavailable, and the issue is not currently listed in CISA KEV, suggesting no publicly available exploit code. Nevertheless, any public‑facing service that processes user‑provided SQL statements with sqlparse and uses reindent=True remains at risk if the attacker can craft large or complex tuple lists, since the attack can be performed without authentication and will exhaust CPU resources, compromising availability.

Generated by OpenCVE AI on September 2, 2026 at 03:02 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade sqlparse to version 0.6.0 or newer.
  • Configure application code to avoid passing untrusted input to sqlparse.format with reindent=True; instead use default formatting or remove the flag.
  • Enforce size limits or validate SQL statements to reject excessively large or complex tuple lists before they reach the formatter, and monitor CPU usage for signs of resource exhaustion.

Generated by OpenCVE AI on September 2, 2026 at 03:02 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-cfqr-cjx5-5jcm sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption
History

Wed, 02 Sep 2026 08:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Wed, 02 Sep 2026 02:30:00 +0000

Type Values Removed Values Added
First Time appeared Andialbrecht
Andialbrecht sqlparse
Vendors & Products Andialbrecht
Andialbrecht sqlparse

Tue, 01 Sep 2026 22:00:00 +0000

Type Values Removed Values Added
Description sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, sqlparse.format(sql, reindent=True) and sqlformat --reindent route attacker-controlled parenthesized tuple lists through ReindentFilter._get_offset() in sqlparse/filters/reindent.py, where _flatten_up_to_token() repeatedly rebuilds and joins the statement prefix. Thousands of offset calculations walk an expanding token tree, producing quadratic CPU consumption for inputs that remain below MAX_GROUPING_TOKENS and causing request delays, reduced throughput, or worker starvation. This issue is fixed in version 0.6.0.
Title sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption
Weaknesses CWE-407
References
Metrics cvssV4_0

{'score': 5.1, 'vector': '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'}


Subscriptions

Andialbrecht Sqlparse
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-09-01T19:12:52.039Z

Reserved: 2026-09-01T16:17:43.078Z

Link: CVE-2026-84305

cve-icon Vulnrichment

Updated: 2026-09-01T19:12:47.744Z

cve-icon NVD

Status : Deferred

Published: 2026-09-01T19:17:30.887

Modified: 2026-09-09T21:09:13.080

Link: CVE-2026-84305

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-02T03:15:04Z

Weaknesses
  • CWE-407

    Inefficient Algorithmic Complexity