// For flags

CVE-2021-32839

Regular Expression Denial of Service in sqlparse

Severity Score

7.5
*CVSS v3.1

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

-
*SSVC
Descriptions

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
' 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.

sqlparse es un módulo analizador de SQL no comprobable para Python. En las versiones 0.4.0 y 0.4.1 de sqlparse, se presenta una vulnerabilidad de Denegación de Servicio por Expresión regular en sqlparse. La expresión regular puede causar un retroceso exponencial en las cadenas que contienen muchas repeticiones de "\r
" en los comentarios SQL. Sólo la función de formato que elimina los comentarios de las sentencias SQL esta afectada por esta expresión regular. Como solución, no use la función sqlformat.format con la palabra clave strip_comments=True o el indicador de línea de comandos --strip-comments cuando use la herramienta de línea de comandos sqlformat. Este problema ha sido corregido en sqlparse versión 0.4.2

A resource-consumption flaw was found in python-sqlparse. The formatter function that strips comments from SQL contains a regular expression that is vulnerable to Regular Expression Denial of Service (ReDoS). A network attacker could craft an SQL comment containing numerous repetitions of '\r
' that could cause exponential backtracking and cause the system to hang.

*Credits: N/A
CVSS Scores
Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
Attack Vector
Network
Attack Complexity
Low
Authentication
None
Confidentiality
None
Integrity
None
Availability
Partial
* Common Vulnerability Scoring System
SSVC
  • Decision:-
Exploitation
-
Automatable
-
Tech. Impact
-
* Organization's Worst-case Scenario
Timeline
  • 2021-05-12 CVE Reserved
  • 2021-09-20 CVE Published
  • 2024-06-05 EPSS Updated
  • 2024-08-03 CVE Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
  • ---------- First Exploit
CWE
  • CWE-400: Uncontrolled Resource Consumption
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Sqlparse Project
Search vendor "Sqlparse Project"
Sqlparse
Search vendor "Sqlparse Project" for product "Sqlparse"
>= 0.4.0 < 0.4.2
Search vendor "Sqlparse Project" for product "Sqlparse" and version " >= 0.4.0 < 0.4.2"
-
Affected