CVE-2021-32839
HIGH 7.5CVSS 3.1StripComments filter contains a regular expression that is vulnerable to ReDOS (Regular Expression Denial of Service)
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.
- Published
- 20 Sep 2021
- Last modified
- 8 Jul 2026
- Assigned by
- security-advisories@github.com
- NVD status
- Modified
- Weakness
- CWE-400
- Also known as
- GHSA-p5w8-wqhj-9hhfPYSEC-2021-333
- Sources
- NVDJSONOSV GHSA-p5w8-wqhj-9hhfJSONOSV PYSEC-2021-333JSON
Scores
| Source | Scored by | Version | Score | Vector / decision |
|---|---|---|---|---|
| OSV | GitHub | CVSS 4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N | |
| NVD | security-advisories@github.com (Secondary) | CVSS 3.1 | HIGH 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| OSV | GitHub | CVSS 3.1 | HIGH 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | nvd@nist.gov (Primary) | CVSS 2.0 | MEDIUM 5.0 | AV:N/AC:L/Au:N/C:N/I:N/A:P |
Affected
| Source | Vendor / ecosystem | Product / package | Affected versions | Fixed in |
|---|---|---|---|---|
| NVD | sqlparse_project | sqlparsecpe:2.3:a:sqlparse_project:sqlparse:*:*:*:*:*:*:*:* |
>= 0.4.0, < 0.4.2 | 0.4.2 |
| OSV | PyPI | sqlparse | >= 0.4.0, < 0.4.2 | 0.4.2 |
References
- https://github.com/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aeb · Patch, Third Party Advisory, WEB, FIX
- https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhf · Third Party Advisory, WEB, ADVISORY
- https://lists.debian.org/debian-lts-announce/2024/12/msg00022.html · WEB
- https://nvd.nist.gov/vuln/detail/CVE-2021-32839 · ADVISORY
- https://github.com/andialbrecht/sqlparse · PACKAGE
- https://github.com/pypa/advisory-database/tree/main/vulns/sqlparse/PYSEC-2021-333.yaml · WEB
- https://securitylab.github.com/advisories/GHSL-2021-107-andialbrecht-sqlparse · ADVISORY
History
- 25 Nov 2026 20:33 UTC · NVD: first stored (published 20 Sep 2021)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 20 Sep 2021)
- 25 Nov 2026 20:12 UTC · OSV: first stored (published 10 Sep 2021)