CVE-2021-32839

Regular Expression Denial of Service in sqlparse

HIGH
7.5
CVSS Score
Published: September 20, 2021 at 05:10 PM UTC
Updated: June 17, 2026 at 03:53 AM UTC
2 products affected across 2 vendorsSqlparseSqlparse

Using sqlparse by andialbrecht?

Get instant alerts when new vulnerabilities affect sqlparse - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
HIGH7.5
Exploit prediction
EPSS 2%

Description

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.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

0.4.0 ≤ v < 0.4.2
Affected range stops below 0.4.2, so it looks safe — our inference, not a vendor statement
v < 0.4.2
Affected range stops below 0.4.2, so it looks safe — our inference, not a vendor statement

Remediation

No guide yet

No remediation guidance has been written for this CVE yet. What the record does show:

CVSS

7.5HIGHGitHub_M
Attack Vector
NETWORK
Complexity
LOW
Privileges
NONE
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
NONE
Integrity
NONE
Availability
HIGH
Vector?

Quick Info

StatusMODIFIED
CWE
CWE-400

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card