CVE-2021-32839 json
Regular Expression Denial of Service in sqlparse
published 2021-09-10 5 y ago modified 2026-07-08 4 mo ago also GHSA-p5w8-wqhj-9hhf , PYSEC-2021-333 , EUVD-2021-0250
- cvss
- 7.5
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 2.3%
- EPSS 2.3% chance of exploitation in 30 days, percentile 83%
- public exploits
- 0
- none known
Summary
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.
Patch / fix
- pypi sqlparse 0.4.2
- sqlparse_project sqlparse 0.4.2
- sqlparse Debian 14, Debian 13, Debian 12 0.4.2-1
debian advisories DEBIAN-CVE-2021-32839
- sqlparse Ubuntu 22.04 LTS 0.4.1-1ubuntu1
ubuntu advisories UBUNTU-CVE-2021-32839
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- foreman satellite utils 6.11, satellite capsule 6.11, satellite 6.11 3.1.1.21-2.el7sat
- foreman satellite utils 6.11, satellite capsule 6.11, satellite 6.11 3.1.1.21-2.el8sat
- libsolv satellite capsule 6.11, satellite 6.11 0.7.22-1.el7pc
- libsolv satellite capsule 6.11, satellite 6.11 0.7.22-1.el8pc
- candlepin satellite 6.11 4.1.13-1.el7sat
- candlepin satellite 6.11 4.1.13-1.el8sat
- satellite satellite utils 6.11, satellite capsule 6.11, satellite 6.11 6.11.0-2.el7sat
- satellite satellite utils 6.11, satellite capsule 6.11, satellite 6.11 6.11.0-2.el8sat
red hat advisories RHSA-2022:5498
- python-sqlparse SLE Module for Basesystem 15 SP3 0.4.2-3.3.1
suse advisories SUSE-SU-2021:3857-1
- python-sqlparse openSUSE Tumbleweed 0.5.5-2.1
- python-sqlparse openSUSE Tumbleweed 0.4.2-1.1
- python-sqlparse openSUSE Tumbleweed 0.5.0-1.1
- python-sqlparse openSUSE Leap 15.3 0.4.2-3.3.1
opensuse advisories openSUSE-SU-2026:11221-1openSUSE-SU-2024:11581-1openSUSE-SU-2024:13938-1openSUSE-SU-2021:3857-1
- libdb Rocky Linux 8 5.3.28-42.el8_4
rocky linux advisories RLSA-2022:5498
- py3-sqlparse Alpine 3.24, Alpine 3.23, Alpine 3.22 +8 more 0.4.2-r0
alpine advisories ALPINE-CVE-2021-32839
Alpine secdb © Alpine Linux, from https://secdb.alpinelinux.org via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- python-sqlparse Arch Linux 0.4.2-1
arch linux advisories AVG-2401
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2021-32839 updated cvss 7.5
python-sqlparse: ReDoS via regular expression in StripComments filter
-
Red Hat Ansible Automation Platform 1.2 sqlparse, python-sqlparseaffected: workaround, no fix available “As mitigation, 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.”
-
Red Hat Ansible Tower 3 sqlparse Red Hat OpenStack Platform 10 (Newton) python-sqlparse Red Hat OpenStack Platform 13 (Queens) python-sqlparseaffected: workaround, no fix planned “As mitigation, 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.”
-
Red Hat Satellite 6.11 for RHEL 8 python-sqlparse 0.4.2-2.el8pcfixed: vendor fix “As mitigation, 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.” RHSA-2022:5498
-
Red Hat OpenStack Platform 16.1 python3-sqlparse Red Hat OpenStack Platform 16.2 python3-sqlparse Red Hat Satellite 6.11 for RHEL 7 tfm 7.0-1.el7sat, gofer 2.12.5-7.el7sat, katello 4.3.0-3.el7sat, libsolv 0.7.22-1.el7pc, libcomps 0.1.18-1.el7pc, libsolv0 0.6.34-4.el7sat, +638 more Red Hat Satellite 6.11 for RHEL 8 libdb 5.3.28-42.el8_4, katello 4.3.0-3.el8sat, libsolv 0.7.22-1.el8pc, libcomps 0.1.18-1.el8pc, python-idna 3.3-1.el8pc, python-pbr 5.6.0-1.el8pc, +628 morenot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
Exploit prediction
2.34% chance of exploitation in the next 30 days, higher than 83% of all scored CVEs (FIRST EPSS, 2026-11-08).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 2.0 | 5.0 | AV:N/AC:L/Au:N/C:N/I:N/A:P |
| GitHub | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| pypi | sqlparse | >=0.4.0, <0.4.2 |
0.4.2 |
Affected products
- andialbrecht sqlparse
Classification
- Weakness
-
- CWE-400 Uncontrolled Resource Consumption
References
-
github.com
/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aeb
web, patch, third-party-advisory
-
github.com
/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhf
web, third-party-advisory, advisory
-
lists.debian.org
/debian-lts-announce/2024/12/msg00022.html
web
-
nvd.nist.gov
/vuln/detail/CVE-2021-32839
advisory
-
github.com
/andialbrecht/sqlparse
package
-
github.com
/pypa/advisory-database/tree/main/vulns/sqlparse/PYSEC-2021-333.yaml
web
-
securitylab.github.com
/advisories/GHSL-2021-107-andialbrecht-sqlparse
advisory
Sources
- CVE List CVE-2021-32839
- GitHub Advisory GHSA-p5w8-wqhj-9hhf
- NVD CVE-2021-32839
- OSV PYSEC-2021-333
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.