Vulnerability · Published Sep 20, 2021 · Assigned by GitHub_M

CVE-2021-32839Regular Expression Denial of Service in sqlparse

High 7.5

In plain English

A high-severity uncontrolled resource consumption in sqlparse from andialbrecht. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 2.3% (higher than 84% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.5High
Exploit odds (30 days)2.3%top 16.3% of all CVEs
Exploited in the wildNo reportsnot in CISA KEV
Attack toolingNoneno public tooling known

Official 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 packages & fixed versions

EcosystemPackageFixed inAdvisory
Alpine:v3.20py3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839
Alpine:v3.21py3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839
Alpine:v3.22py3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839
Alpine:v3.23py3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839
Alpine:v3.24py3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839
Debian:12sqlparse0.4.2-1DEBIAN-CVE-2021-32839
Debian:13sqlparse0.4.2-1DEBIAN-CVE-2021-32839
Debian:14sqlparse0.4.2-1DEBIAN-CVE-2021-32839
PyPIsqlparse0.4.2PYSEC-2021-333
PyPIsqlparse0.4.2GHSA-p5w8-wqhj-9hhf
Rocky Linux:8libdb0:5.3.28-42.el8_4RLSA-2022:5498
Ubuntu:22.04:LTSsqlparse0.4.1-1ubuntu1UBUNTU-CVE-2021-32839

Affected products (as reported)

VendorProductVersions
andialbrecht sqlparse >= 0.4.0, < 0.4.2

Weakness: CWE-400 · Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

References