Skip to main content

sqlparse CVE-2026-84305

| EUVDEUVD-2026-69421 MEDIUM
Inefficient Algorithmic Complexity (CWE-407)
2026-09-01 GitHub_M GHSA-cfqr-cjx5-5jcm
5.1
CVSS 4.0 · Vendor: GitHub_M
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft SQL with large IN-tuple list below 10,000-token cap
  2. Delivery
    Submit to any endpoint calling format(reindent=True)
  3. Exploit
    Grouping phase completes, entering reindentation
  4. Execution
    ReindentFilter._get_offset() walks full prefix O(N) per group
  5. Persist
    O(N²) CPU consumed per request
  6. Impact
    Concurrent 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.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.1% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

sqlparse < 0.6.0

Affected Packages

pypi sqlparse fix: 0.6.0

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

Vendor (GitHub_M) PRIMARY 5.1 MEDIUM
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
vuln.today AI 5.3 MEDIUM

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.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
SUSE 4.0 MEDIUM
AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Red Hat 6.2 MEDIUM

Primary rating from Vendor (GitHub_M).

CVSS VectorVendor: GitHub_M

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

1
Patch available
Sep 01, 2026 - 20:03 EUVD

DescriptionCVE.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
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 33 pypi packages depend on sqlparse (18 direct, 15 indirect)

Ecosystem-wide dependent count for version 0.6.0.

Threat Intelligence Overview

EPSS Score
0.1%
Top 97% exploitable
Prevalence
Medium
popular Python SQL utility library, not universally deployed
Threat Intel
1
1 source
Exploit
POC
Public exploit code exists
Data Quality
8 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA Vendor GitHub VulDB

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.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC Yes
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
Poc
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

46
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +26
PoC: +20
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Vendor 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

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy