Denial of Service Vulnerability in sqlparse Package: CVE-2024-4340

sqlparse Updated 03 Oct 2025

Summary

30/04/2024
N/A
Yes i
High
7.5

UBUNTU-CVE-2024-4340: Passing a heavily nested list to sqlparse.parse() leads to a Denial of Service due to RecursionError. Affects sqlparse versions < 0.4.2-1ubuntu0.22.04.2. Fixed in 0.4.2-1ubuntu0.22.04.2. 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

The sqlparse package is a non-validating SQL parser for Python, designed to provide a simple interface for parsing SQL statements. It is widely used in applications that require SQL syntax analysis and formatting. The package is known for its ease of use and flexibility, allowing developers to manipulate SQL queries effectively. However, it is susceptible to a Denial of Service (DoS) vulnerability due to improper handling of deeply nested lists.

Vulnerability Detail

The vulnerability, identified as CVE-2024-4340, arises when a heavily nested list is passed to the sqlparse.parse() function. This can lead to a RecursionError, causing the application to crash and resulting in a Denial of Service. The issue stems from the way the parser processes nested structures, which can exhaust the call stack, especially with complex SQL queries. The potential ramifications include application downtime and service unavailability, impacting users and dependent systems.

How To Fix

Minimum fixed version

0.4.2-1ubuntu0.22.04.2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade sqlparse

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

Workaround

As a temporary workaround, avoid passing heavily nested lists to the sqlparse.parse() function until the package is updated. This can prevent the RecursionError from occurring.

Conclusion

In summary, CVE-2024-4340 is a significant vulnerability in the sqlparse package that can lead to Denial of Service. It is crucial to update to the latest patched versions to mitigate the risk and ensure application stability. Users are encouraged to monitor their dependencies and utilize tools like Vulert for real-time vulnerability alerts.

See every vulnerability recorded for sqlparse →

Share this vulnerability

FAQ

CVE-2024-4340 is a vulnerability in the sqlparse package that can lead to a Denial of Service due to RecursionError when processing deeply nested lists.

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

The primary consequence is a Denial of Service, which can cause application crashes and service unavailability for users.

You can update the sqlparse package using the command: sudo apt update && sudo apt upgrade sqlparse in your terminal.

Yes, updating to the patched versions of sqlparse (0.4.2-1ubuntu0.22.04.2 for Ubuntu 22.04 LTS or 0.4.4-1ubuntu0.1 for Ubuntu 24.04 LTS) will permanently fix the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for sqlparse.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

0.4.2-1ubuntu0.22.04.2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade sqlparse

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