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.
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
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Alpine:v3.20 | py3-sqlparse | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine:v3.21 | py3-sqlparse | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine:v3.22 | py3-sqlparse | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine:v3.23 | py3-sqlparse | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine:v3.24 | py3-sqlparse | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Debian:12 | sqlparse | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| Debian:13 | sqlparse | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| Debian:14 | sqlparse | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| PyPI | sqlparse | 0.4.2 | PYSEC-2021-333 |
| PyPI | sqlparse | 0.4.2 | GHSA-p5w8-wqhj-9hhf |
| Rocky Linux:8 | libdb | 0:5.3.28-42.el8_4 | RLSA-2022:5498 |
| Ubuntu:22.04:LTS | sqlparse | 0.4.1-1ubuntu1 | UBUNTU-CVE-2021-32839 |
Affected products (as reported)
| Vendor | Product | Versions |
|---|---|---|
| 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