CVEfocus › CVE database › CVE-2021-32839

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

CVSS 7.5 HighEPSS 2.3% (higher than 84% of CVEs)Published 2021-09-20Updated 2025-11-03Assigner: GitHub_M

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.

CWE-400

What to do

Fixed builds are available from Alpine, Debian, PyPI, Rocky Linux, Ubuntu: see the table below for the fixed version per release.

Ubuntu has not shipped a fix for every release yet.

Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.

curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \
  -H "Content-Type: text/plain" --data-binary @inventory.txt

Vendor status at a glance

17Fixed
2Fix pending

Status by vendor and release

From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.

ReleasePackageStatusFixed versionAdvisory
Ubuntu 22.04sqlparseFixed0.4.1-1ubuntu1UBUNTU-CVE-2021-32839
Ubuntu 16.04sqlparseFix pending
Ubuntu 14.04sqlparseFix pending
Debian 14sqlparseFixed0.4.2-1DEBIAN-CVE-2021-32839
Debian 13sqlparseFixed0.4.2-1DEBIAN-CVE-2021-32839
Debian 12sqlparseFixed0.4.2-1DEBIAN-CVE-2021-32839
Rocky Linux 8libdbFixed0:5.3.28-42.el8_4RLSA-2022:5498
Alpine Linux 3.24py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.23py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.22py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.21py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.20py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.19py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.18py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.17py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.16py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.15py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
Alpine Linux 3.14py3-sqlparseFixed0.4.2-r0ALPINE-CVE-2021-32839
PyPI librarysqlparseFixed0.4.2GHSA-p5w8-wqhj-9hhf

What the vendor says

As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.

References

About this page

Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.