cve.bz

CVE-2021-32839 sqlparse project sqlparse: Uncontrolled Resource Consumption

7.5 highEPSS 2.3%Fix available

High (7.5) in sqlparse project sqlparse. EPSS 2.3% estimated probability of exploitation activity in the next 30 days. Fixed in sqlparse 0.4.2.

On this page
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.

Severity

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
EPSS
2.3% (unchanged from 2.3% a week ago; 2.3% 30 days ago) estimated probability of exploitation activity in the next 30 days; 84th percentile. Scored 2026-11-22. A forecast for this CVE across the internet, not for your own systems.
CWE
CWE-400 Uncontrolled Resource Consumption
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2021-32839 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2021-32839?via=ask-ai-copy and https://cve.bz/cve/CVE-2021-32839?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2021-32839 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
sqlparse_project:sqlparsefrom 0.4.0 before 0.4.2

Packages (OSV)

AdvisoryEcosystemPackageAffectedFixed in
GHSA-p5w8-wqhj-9hhfPyPIsqlparse>=0.4.0 <0.4.20.4.2
PYSEC-2021-333PyPIsqlparse>=0.4.0 <0.4.20.4.2

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian11sqlparse0.4.1-1+deb11u1DLA-4000-1
Debian12, 13, 14sqlparse0.4.2-1DEBIAN-CVE-2021-32839
Ubuntu22.04:LTSsqlparse0.4.1-1ubuntu1UBUNTU-CVE-2021-32839
Red Hatsatellite:6.11::el7candlepin0:4.1.13-1.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el7tfm-rubygem-actionpack0:6.0.4.7-1.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el7tfm-rubygem-puma, tfm-rubygem-puma-debuginfo0:5.6.2-1.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el7tfm-rubygem-sidekiq0:5.2.10-1.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el7, satellite_capsule:6.11::el7libsolv0:0.7.22-1.el7pcRHSA-2022:5498
Red Hatsatellite:6.11::el7, satellite_capsule:6.11::el7, satellite_utils:6.11::el7foreman0:3.1.1.21-2.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el7, satellite_capsule:6.11::el7, satellite_utils:6.11::el7satellite0:6.11.0-2.el7satRHSA-2022:5498
Red Hatsatellite:6.11::el8candlepin0:4.1.13-1.el8satRHSA-2022:5498
Red Hatsatellite:6.11::el8rubygem-actionpack0:6.0.4.7-1.el8satRHSA-2022:5498
Red Hatsatellite:6.11::el8rubygem-puma, rubygem-puma-debuginfo, rubygem-puma-debugsource0:5.6.2-1.el8satRHSA-2022:5498
Red Hatsatellite:6.11::el8rubygem-sidekiq0:5.2.10-1.el8satRHSA-2022:5498
Red Hatsatellite:6.11::el8, satellite_capsule:6.11::el8libsolv0:0.7.22-1.el8pcRHSA-2022:5498
5 more for Red Hat in the JSON and on Red Hat's page.
SUSELinux Enterprise Module for Basesystem 15 SP3python-sqlparse0.4.2-3.3.1SUSE-SU-2021:3857-1
openSUSELeap 15.3python-sqlparse0.4.2-3.3.1openSUSE-SU-2021:3857-1
openSUSETumbleweedpython-sqlparse0.4.2-1.1openSUSE-SU-2024:11581-1
openSUSETumbleweedpython-sqlparse0.5.0-1.1openSUSE-SU-2024:13938-1
openSUSETumbleweedpython-sqlparse0.5.5-2.1openSUSE-SU-2026:11221-1
Rocky Linux8libdb0:5.3.28-42.el8_4RLSA-2022:5498
Alpinev3.14, v3.15, v3.16 and 8 morepy3-sqlparse0.4.2-r0ALPINE-CVE-2021-32839

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Red Hat Security Data © Red Hat, Inc., CC BY 4.0; SUSE security data, CC BY 4.0; Rocky Linux's errata, BSD-3-Clause; the Alpine secdb, CC BY-SA 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Red Hat · SUSE · openSUSE · Alpine.

Red Hat

Red Hat rates this Moderate.

Red Hat's mitigation

As mitigation, 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.

ProductPackageStateAdvisory
Red Hat Satellite 6.11 for RHEL 8python-sqlparse-0:0.4.2-2.el8pcFixed 2022-07-05RHSA-2022:5498
Red Hat Ansible Automation Platform 1.2python-sqlparseAffected
Red Hat Ansible Automation Platform 1.2sqlparseAffected
Red Hat Ansible Tower 3sqlparseOut of support scope
Red Hat OpenStack Platform 10 (Newton)python-sqlparseOut of support scope
Red Hat OpenStack Platform 13 (Queens)python-sqlparseOut of support scope
Red Hat OpenStack Platform 16.1python-sqlparseNot affected
Red Hat OpenStack Platform 16.2python-sqlparseNot affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2021-32839.

Attack patterns (CAPEC)

  • CAPEC-147 XML Ping of the Death Likelihood: Low · Severity: Medium
  • CAPEC-227 Sustained Client Engagement
  • CAPEC-492 Regular Expression Exponential Blowup

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits.

References

Check your stackJSON