Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessCraft SQL with large IN-tuple list below 10,000-token cap
-
DeliverySubmit to any endpoint calling format(reindent=True)
-
ExploitGrouping phase completes, entering reindentation
-
ExecutionReindentFilter._get_offset() walks full prefix O(N) per group
-
PersistO(N²) CPU consumed per request
-
ImpactConcurrent requests starve available workers
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V2 - Validation and Business Logic Algorithmic complexity limits
|
| Exploitation Conditions | Exploitation requires that the target application call sqlparse.format() with the reindent=True parameter (or invoke the sqlformat --reindent CLI flag) on attacker-controlled SQL input. The reindent=True flag is opt-in and not the default - applications that use sqlparse only for parsing, or that format SQL without reindentation, are not affected. The attacker must craft SQL containing parenthesized tuple structures (IN (...) lists or INSERT ... VALUES (...) lists) sized below the MAX_GROUPING_TOKENS threshold of 10,000 to bypass the grouping cap and reach the vulnerable path. No authentication or special privilege is required at the library level; the limiting factor is whether the calling application exposes the reindent formatting path to untrusted input. Services that use sqlparse internally for log formatting or diagnostics on user-supplied queries are the most plausible real-world targets. |
| Impact | The provided CVSS 4.0 vector (AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L) scores 5.1 and uses AV:L, which reflects library-level invocation context. However, the realistic exploitation path in most deployments is through a web service that accepts attacker-controlled SQL and passes it to sqlparse.format(reindent=True), making the effective attack vector network-accessible and the score conservative. No KEV listing, no public exploit code, and a low-to-medium EPSS profile are consistent with a library-level DoS that requires application-layer exposure. Real-world risk depends entirely on whether an application exposes the reindent formatting path to untrusted input - SQL IDEs, query formatters, and API gateways are the primary concern. The availability impact is limited (VA:L in CVSS 4.0, A:L in 3.1) - worker starvation rather than full service crash - and CPU contention self-resolves once the request completes or times out. The 'Information Disclosure' tag in the input is incorrect for this vulnerability; no confidentiality impact exists. Patch is available and straightforward. |
| Exploit ScenarioDerived | An attacker submits a crafted SQL string containing a large parenthesized IN tuple list - for example, SELECT a FROM t WHERE (col1, col2) IN ((0,0),(1,2),...) with several hundred to ~1,950 tuples - sized to remain below the MAX_GROUPING_TOKENS=10,000 cap, ensuring it clears the grouping phase and enters the reindentation path. The application passes this string to sqlparse.format(sql, reindent=True), triggering O(N²) CPU consumption in ReindentFilter._get_offset(). Repeating this request from multiple threads or connections causes progressive CPU saturation, increasing latency for all concurrent users and potentially starving worker processes. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Sep 01, 2026
Quadratic CPU exhaustion in sqlparse's reindentation path allows denial of service against any Python application that passes attacker-controlled SQL to sqlparse.format() with reindent=True. The ReindentFilter._get_offset() method formerly rebuilt the full statement prefix from the token tree's root on every call, resulting in O(N²) CPU growth when processing parenthesized tuple lists - such as large IN (...) or INSERT INTO ... VALUES (...) expressions. A ~12 KB crafted SQL payload can pin a CPU worker for seconds, enabling request delays, throughput reduction, or worker starvation in any service that exposes this formatting path. No public exploit has been identified at time of analysis, and the fix is available in sqlparse 0.6.0.
RemediationAI
Upgrade sqlparse to version 0.6.0 or later, which replaces the O(N²) prefix-rebuild walk with an O(N) backwards walk in ReindentFilter._get_offset(). The fix is confirmed in the tagged release at https://github.com/andialbrecht/sqlparse/releases/tag/0.6.0 and the commit at https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b. If immediate upgrade is not possible, the most effective compensating control is to avoid passing untrusted SQL to sqlparse.format() with reindent=True - switching to reindent=False eliminates the vulnerable code path entirely with no semantic impact on parsing correctness (only indentation formatting is affected). Applications can also enforce a per-request CPU timeout or SQL length limit upstream of the sqlparse call to cap worst-case latency, though these controls add operational overhead and do not eliminate the root cause.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
sqlparse (CPE: cpe:2.3:a:andialbrecht:sqlparse:*:*:*:*:*:*:*:*) is a widely-used non-validating Python SQL parser. The vulnerability lies in sqlparse/filters/reindent.py within ReindentFilter._get_offset(), which computed column offsets for pretty-printing. The prior implementation called _flatten_up_to_token() on each group in the token tree, walking the entire statement from its start every time - an O(N) operation called once per group, making the overall complexity O(N²) in the number of groups (CWE-407: Insufficient Algorithmic Complexity). CWE-1333 (Inefficient Regular Expression Complexity) is cited in the upstream changelog as a companion CWE, reflecting the same class of super-linear complexity. The vulnerability is only reachable via the opt-in reindent=True parameter of sqlparse.format(); the default parsing path is not affected. Attackers must keep input below MAX_GROUPING_TOKENS (10,000) to bypass the grouping cap and enter the expensive reindentation path. The commit fix replaced the prefix-rebuild walk with a backwards token walk that stops at the nearest line break, restoring O(N) behavior.
Know when Sqlparse gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
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
Network vector reflects typical web-app exposure; no auth required at library level; only partial availability impact from CPU saturation, no C or I impact.
AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Primary rating from Vendor (GitHub_M).
CVSS VectorVendor: GitHub_M
Lifecycle Timeline
1DescriptionCVE.org
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.
Blast Radius
ecosystem impact- 33 pypi packages depend on sqlparse (18 direct, 15 indirect)
Ecosystem-wide dependent count for version 0.6.0.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Quadratic CPU consumption in sqlparse versions prior to 0.6.0 allows unauthenticated remote denial-of-service via crafte
CPU exhaustion via ReDoS in sqlparse affects all Python applications that pass caller-controlled SQL text to sqlparse.pa
Quadratic CPU consumption in sqlparse's group_comments function (grouping.py) allows remote unauthenticated denial of se
PHP code injection in sqlparse through 0.6.0 can turn crafted SQL text into executable PHP when an application uses the
sqlparse is a non-validating SQL parser module for Python. Rated high severity (CVSS 7.5), this vulnerability is remotel
sqlparse is a non-validating SQL parser module for Python. Rated high severity (CVSS 7.5), this vulnerability is remotel
Code injection in sqlparse prior to 0.6.0 allows attackers to escape generated Python and PHP source-code snippets by su
Same weakness CWE-407 – Inefficient Algorithmic Complexity
View allVendor StatusVendor
SUSE
Severity: Moderate| Product | Status |
|---|---|
| SUSE Linux Enterprise Desktop 15 SP7 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP7 | Affected |
| SUSE Linux Enterprise Module for Python 3 15 SP7 | Affected |
| SUSE Linux Enterprise Server 15 SP7 | Affected |
| SUSE Linux Enterprise Server 16.0 | Affected |
| SUSE Linux Enterprise Server 16.1 | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP7 | Affected |
| SUSE Linux Enterprise Server for SAP applications 16.0 | Affected |
| SUSE Linux Enterprise Server for SAP applications 16.1 | Affected |
| openSUSE Leap 16.0 | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP5 | Affected |
| SUSE Linux Enterprise Module for Public Cloud 15 SP4 | Affected |
| SUSE Linux Enterprise Module for Public Cloud 15 SP5 | Affected |
| SUSE Linux Enterprise Module for Python 3 15 SP6 | Affected |
| SUSE Linux Enterprise Server 15 SP4 | Affected |
| SUSE Linux Enterprise Server 15 SP5 | Affected |
| SUSE Linux Enterprise Server 15 SP6 | Affected |
| SUSE Linux Enterprise Server 15 SP6-LTSS | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP4 | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP5 | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP6 | Affected |
| SUSE CaaS Platform 4.0 | Affected |
| SUSE Enterprise Storage 6 | Affected |
| SUSE Enterprise Storage 7 | Affected |
| SUSE Linux Enterprise Desktop 15 SP1 | Affected |
| SUSE Linux Enterprise Desktop 15 SP2 | Affected |
| SUSE Linux Enterprise Desktop 15 SP6 | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP1 | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP1-ESPOS | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP1-LTSS | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP2 | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP2-ESPOS | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP2-LTSS | Affected |
| SUSE Linux Enterprise High Performance Computing 15 SP4 | Affected |
| SUSE Linux Enterprise Module for Basesystem 15 SP1 | Affected |
| SUSE Linux Enterprise Module for Basesystem 15 SP2 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP1 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP2 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP3 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP4 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP5 | Affected |
| SUSE Linux Enterprise Module for Package Hub 15 SP6 | Affected |
| SUSE Linux Enterprise Module for Public Cloud 15 SP6 | Affected |
| SUSE Linux Enterprise Real Time 15 SP2 | Affected |
| SUSE Linux Enterprise Server 15 SP1 | Affected |
| SUSE Linux Enterprise Server 15 SP1-BCL | Affected |
| SUSE Linux Enterprise Server 15 SP1-LTSS | Affected |
| SUSE Linux Enterprise Server 15 SP2 | Affected |
| SUSE Linux Enterprise Server 15 SP2-BCL | Affected |
| SUSE Linux Enterprise Server 15 SP2-LTSS | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP1 | Affected |
| SUSE Linux Enterprise Server for SAP Applications 15 SP2 | Affected |
| SUSE Manager Proxy 4.0 | Affected |
| SUSE Manager Proxy 4.1 | Affected |
| SUSE Manager Proxy 4.3 | Affected |
| SUSE Manager Retail Branch Server 4.0 | Affected |
| SUSE Manager Retail Branch Server 4.1 | Affected |
| SUSE Manager Retail Branch Server 4.3 | Affected |
| SUSE Manager Server 4.0 | Affected |
| SUSE Manager Server 4.1 | Affected |
| SUSE Manager Server 4.3 | Affected |
| openSUSE Leap 15.3 | Affected |
| openSUSE Leap 15.5 | Affected |
| openSUSE Leap 15.6 | Affected |
EUVD-2026-69421
GHSA-cfqr-cjx5-5jcm
NVD
CVE.org
EPSS
Vulnrichment
VulDB
Exploit-DB