Regular Expression Denial of Service in sqlparse
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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
sqlparsePyPI | >= 0.4.0, < 0.4.2 | 0.4.2 |
Affected products
5- ghsa-coords4 versionspkg:pypi/sqlparsepkg:rpm/opensuse/python-sqlparse&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/python-sqlparse&distro=openSUSE%20Tumbleweedpkg:rpm/suse/python-sqlparse&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP3
>= 0.4.0, < 0.4.2+ 3 more
- (no CPE)range: >= 0.4.0, < 0.4.2
- (no CPE)range: < 0.4.2-3.3.1
- (no CPE)range: < 0.4.2-1.1
- (no CPE)range: < 0.4.2-3.3.1
- Range: >= 0.4.0, < 0.4.2
Patches
Vulnerability mechanics
References
7- github.com/advisories/GHSA-p5w8-wqhj-9hhfghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-32839ghsaADVISORY
- securitylab.github.com/advisories/GHSL-2021-107-andialbrecht-sqlparseghsaADVISORY
- github.com/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aebghsax_refsource_MISCWEB
- github.com/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhfghsax_refsource_CONFIRMWEB
- github.com/pypa/advisory-database/tree/main/vulns/sqlparse/PYSEC-2021-333.yamlghsaWEB
- lists.debian.org/debian-lts-announce/2024/12/msg00022.htmlghsaWEB
News mentions
0No linked articles in our index yet.