CVE-2021-32839Regular Expression Denial of Service in sqlparse
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.
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
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.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 22.04 | sqlparse | Fixed | 0.4.1-1ubuntu1 | UBUNTU-CVE-2021-32839 |
| Ubuntu 16.04 | sqlparse | Fix pending | ||
| Ubuntu 14.04 | sqlparse | Fix pending | ||
| Debian 14 | sqlparse | Fixed | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| Debian 13 | sqlparse | Fixed | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| Debian 12 | sqlparse | Fixed | 0.4.2-1 | DEBIAN-CVE-2021-32839 |
| Rocky Linux 8 | libdb | Fixed | 0:5.3.28-42.el8_4 | RLSA-2022:5498 |
| Alpine Linux 3.24 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.23 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.22 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.21 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.20 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.19 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.18 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.17 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.16 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.15 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| Alpine Linux 3.14 | py3-sqlparse | Fixed | 0.4.2-r0 | ALPINE-CVE-2021-32839 |
| PyPI library | sqlparse | Fixed | 0.4.2 | GHSA-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.
- andialbrecht sqlparse: affected: >= 0.4.0, < 0.4.2
References
- https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhf
- https://github.com/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aeb
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.