CVE-2021-32839Sqlparse Project Sqlparse
High 7.5 No auth needed
Follow: this CVE · Sqlparse Project · Sqlparse Project Sqlparse We alert you by email or Slack (account required).
- Priority
- 60
- CVSS 3.1
- 7.5
- EPSS
- 2.3% probability of exploitation in 30 days · percentile 84
- Auth required
- No
- Published
- Sep 20, 2021
- Updated
- Jun 17, 2026
- Category
- Application · Cross-platform
- Weakness (CWE)
- CWE-400
- Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
What happens
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
- Apply the vendor's security update for Sqlparse.
- It can be exploited without authentication: if you cannot patch now, restrict Internet access to the affected service.
Affected packages
| Ecosystem | Package | Affected versions | Fixed in | How to upgrade |
|---|---|---|---|---|
| PyPI | sqlparse |
≥ 0.4.0 < 0.4.2 |
0.4.2 |
pip install "sqlparse>=0.4.2" |
| PyPI | sqlparse |
≥ 0.4.0 < 0.4.2 |
0.4.2 |
pip install "sqlparse>=0.4.2" |
Per OSV / GitHub Advisories (GHSA-p5w8-wqhj-9hhf, PYSEC-2021-333). Check the version in your lockfile before upgrading.
Affected products (CPE)
| Vendor | Product | Versions |
|---|---|---|
| sqlparse_project | sqlparse | ≥ 0.4.0 < 0.4.2 |
Official advisories
- python313-sqlparse-0.5.5-2.1 on GA media · SUSE · openSUSE-SU-2026:11221-1 · Jul 8, 2026 High
Vendor, CERT and distribution advisories that name this CVE. Original titles.
Official sources
References
Links published by the sources. Open them with care.
- github.com Patch Third Party Advisory
- github.com Third Party Advisory
- lists.debian.org