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

- Severity: High 7.5 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 2.34%, higher than 84% of CVEs (2026-12-01)
- Published: 2021-09-10T17:56:06.000Z
- Modified: 2026-07-08T06:29:57.075Z
- Also known as: GHSA-p5w8-wqhj-9hhf, PYSEC-2021-333
- Weaknesses: CWE-400
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- andialbrecht sqlparse: >= 0.4.0, < 0.4.2
- sqlparse (PyPI): from 0.4.0 before 0.4.2; from 1499cffcd7c4d635b4297b44d48fb4fe94cf988e before 8238a9e450ed1524e40cb3a8b0b3c00606903aeb
- sqlparse_project sqlparse: from 0.4.0 before 0.4.2

## Every score

- GitHub_M: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:4.0 High `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: CVSS:2.0 5.0 Medium `AV:N/AC:L/Au:N/C:N/I:N/A:P`

## References

- <https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhf> (advisory, third-party-advisory, web)
- <https://github.com/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aeb> (fix, patch, third-party-advisory, web)
- <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)

## Sources

- CVE List: [CVE-2021-32839](https://www.cve.org/CVERecord?id=CVE-2021-32839), CVE Terms of Use, modified 2025-11-03
- GitHub Advisory Database: [GHSA-p5w8-wqhj-9hhf](https://github.com/advisories/GHSA-p5w8-wqhj-9hhf), CC-BY-4.0, modified 2026-07-08
- NVD: [CVE-2021-32839](https://nvd.nist.gov/vuln/detail/CVE-2021-32839), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2021-333](https://osv.dev/vulnerability/PYSEC-2021-333), CC-BY-4.0, modified 2023-11-08

---

Page: https://cve.day/CVE-2021-32839 · Whole record: https://cve.day/CVE-2021-32839.json · Rebuilt by cve.day 2026-11-25T22:58:04.082Z
