CVE-2021-32839

Regular Expression Denial of Service in sqlparse

Published Sep 20, 2021 CVSS 3.1 · 7.5 High EPSS 2.3% KEV · Not listed
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.

Remediation

No solution or workaround provided in the CVE record

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4000-1 sqlparse security update
EUVD EUVD EUVD-2021-0250 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.
Github GHSA Github GHSA GHSA-p5w8-wqhj-9hhf StripComments filter contains a regular expression that is vulnerable to ReDOS (Regular Expression Denial of Service)
Ubuntu USN Ubuntu USN USN-5085-1 SQL parse vulnerability
Weaknesses

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Nov 3, 2025, 9:44 PM
Reserved
May 12, 2021, 12:00 AM
Status
Modified
Published
Sep 20, 2021, 5:15 PM
Modified
Jun 17, 2026, 3:53 AM
Severity
Moderate
Public date
Sep 10, 2021, 12:00 AM