Description
sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, TokenList construction and string conversion in sqlparse/sql.py repeatedly flatten nested token subtrees constructed by group_parenthesis and group_case, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split() before depth and token limits terminate processing. This issue is fixed in version 0.6.0.
Published: 2026-08-17
Score: 8.7 High
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

sqlparse is a non-validating SQL parser for Python. Prior to version 0.6.0, the construction and string conversion of TokenList objects in sqlparse/sql.py flattened nested token subtrees generated by group_parenthesis and group_case. This flattening process is performed repeatedly during parse(), format(), and split() calls, producing a quadratic growth in CPU usage. An attacker can supply a specially crafted SQL statement that triggers this behavior, exhausting CPU resources and causing a denial of service before the parser’s depth or token limits are reached.

Affected Systems

The vulnerability affects the andialbrecht:sqlparse package for Python. Any installation of sqlparse with a version earlier than 0.6.0 is susceptible. The issue is fixed in version 0.6.0 and later; updating to 0.6.0 or a newer release removes the flaw.

Risk and Exploitability

The CVSS score of 8.7 indicates a high severity of the flaw. Because the problem manifests during normal parser usage, an attacker with ability to supply input to sqlparse—such as a web application that parses user-supplied SQL—can trigger it. The EPSS score is not available, and the vulnerability is not listed in CISA’s KEV catalog. The likely attack vector is by providing malicious SQL to any function that calls sqlparse.parse(), sqlparse.format(), or sqlparse.split().

Generated by OpenCVE AI on August 17, 2026 at 19:50 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the sqlparse package to version 0.6.0 or newer. The upstream patch eliminates the quadratic CPU consumption.
  • Validate or sanitize all SQL inputs before invoking sqlparse functions to reduce the likelihood of maliciously complex queries triggering the issue.
  • Apply process-level resource limits, such as ulimit or cgroups, to the Python processes that use sqlparse to constrain CPU usage and mitigate potential impact.

Generated by OpenCVE AI on August 17, 2026 at 19:50 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-pwgv-4x5q-6m9f sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger
History

Mon, 17 Aug 2026 20:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Mon, 17 Aug 2026 18:00:00 +0000

Type Values Removed Values Added
Description sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, TokenList construction and string conversion in sqlparse/sql.py repeatedly flatten nested token subtrees constructed by group_parenthesis and group_case, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split() before depth and token limits terminate processing. This issue is fixed in version 0.6.0.
Title sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger
Weaknesses CWE-1333
CWE-407
References
Metrics cvssV4_0

{'score': 8.7, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N'}


Subscriptions

No data.

cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-08-17T19:32:42.004Z

Reserved: 2026-06-12T17:46:37.292Z

Link: CVE-2026-54284

cve-icon Vulnrichment

Updated: 2026-08-17T19:32:22.175Z

cve-icon NVD

Status : Received

Published: 2026-08-17T18:17:11.400

Modified: 2026-08-17T20:16:44.217

Link: CVE-2026-54284

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-17T20:00:04Z

Weaknesses
  • CWE-1333

    Inefficient Regular Expression Complexity

  • CWE-407

    Inefficient Algorithmic Complexity