Live threats

All CVEs / Sqlparse Project

CVE-2021-32839Sqlparse Project Sqlparse

High 7.5 No auth needed

Priority
60
CVSS 3.1
7.5
EPSS
2.3%
probability of exploitation in 30 days · percentile 84
Auth required
No
Published
Sep 20, 2021
Updated
Jun 17, 2026
Category
Application · Cross-platform
Weakness (CWE)
CWE-400
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

What happens

sqlparse is a non-validating SQL parser module for Python. In sqlparse versions 0.4.0 and 0.4.1 there is a regular Expression Denial of Service in sqlparse vulnerability. The regular expression may cause exponential backtracking on strings containing many repetitions of '\r\n' in SQL comments. Only the formatting feature that removes comments from SQL statements is affected by this regular expression. As a workaround don't use the sqlformat.format function with keyword strip_comments=True or the --strip-comments command line flag when using the sqlformat command line tool. The issues has been fixed in sqlparse 0.4.2.

Original NVD text.

What to do

  1. Apply the vendor's security update for Sqlparse.
  2. It can be exploited without authentication: if you cannot patch now, restrict Internet access to the affected service.

Affected packages

EcosystemPackageAffected versionsFixed inHow to upgrade
PyPI sqlparse ≥ 0.4.0 < 0.4.2 0.4.2 pip install "sqlparse>=0.4.2"
PyPI sqlparse ≥ 0.4.0 < 0.4.2 0.4.2 pip install "sqlparse>=0.4.2"

Per OSV / GitHub Advisories (GHSA-p5w8-wqhj-9hhf, PYSEC-2021-333). Check the version in your lockfile before upgrading.

Affected products (CPE)

VendorProductVersions
sqlparse_projectsqlparse≥ 0.4.0 < 0.4.2

Official advisories

Vendor, CERT and distribution advisories that name this CVE. Original titles.

Official sources

References

Links published by the sources. Open them with care.