CVE-2026-54284: sqlparse CPU DoS Vulnerability Due to Inefficient Token Grouping

sqlparse Updated 19 Aug 2026

Summary

19/08/2026
Yes i
High
8.7

CVE-2026-54284: sqlparse ships hard limits (MAX_GROUPING_DEPTH=100, MAX_GROUPING_TOKENS=10000) intended to bound parsing work on attacker-supplied SQL, but the path that *reaches* those limits is itself O(n*depth) per token-group constr... Affects sqlparse versions < 0.6.0. Fixed in 0.6.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

sqlparse is a non-validating SQL parser for Python that provides a way to parse, format, and split SQL statements. It is widely used in various applications, including web services and database management tools. The package is designed to handle SQL queries efficiently, but it has a vulnerability that can lead to excessive CPU consumption when processing deeply nested SQL statements.

Vulnerability Detail

The vulnerability arises from the implementation of the TokenList class in sqlparse, specifically in the init method. When constructing token groups, the method calls super().init(None, str(self)), which triggers a costly operation that flattens the entire subtree of tokens. This results in a time complexity of O(n*depth) for each token group, where n is the number of tokens and depth is the nesting level. Attackers can exploit this by sending specially crafted SQL payloads with deep nesting, causing significant CPU load and potentially leading to denial of service (DoS) conditions. The vulnerability affects sqlparse version 0.5.5 and earlier, with a CVSS score of 8.7 indicating a high severity.

How To Fix

Latest published version: 0.6.0 as of 23 Oct 2026

pip install --upgrade "sqlparse==0.6.0"

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid processing SQL queries that contain deeply nested structures, such as excessive parentheses or CASE statements. Additionally, implement rate limiting on SQL parsing requests to mitigate the impact of potential DoS attacks.

Conclusion

The sqlparse vulnerability CVE-2026-54284 poses a significant risk due to its potential for CPU DoS attacks through deeply nested SQL queries. It is crucial for users of sqlparse to update to the latest version to mitigate this risk and ensure the stability of their applications.

See every vulnerability recorded for sqlparse →

Share this vulnerability

FAQ

The vulnerability can lead to significant CPU consumption, causing slowdowns or crashes in applications that rely on sqlparse for SQL parsing.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

sqlparse versions 0.5.5 and earlier are affected by this vulnerability.

If an immediate update is not possible, consider implementing rate limiting and avoiding deeply nested SQL queries as a temporary measure.

Yes, a patch is available in sqlparse version 0.6.0 and later, which addresses the performance issue.

Related vulnerabilities

Recent vulnerabilities recorded for sqlparse.

How To Fix

Latest published version: 0.6.0 as of 23 Oct 2026

pip install --upgrade "sqlparse==0.6.0"

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback