Skip to content
Noroxi
NVD / CVE Program· CNA GitHub_M

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

HighCVSS 7.5 · v3.1—No exploit Fix available

Noroxi assessment

Priority: Monitor (action score 31/100)

  • The sources we track (CISA KEV, Exploit-DB, Metasploit, Nuclei, GitHub) show no public exploit code or exploitation in the wild.
  • Probability of exploitation in the next 30 days: 2.3% (FIRST EPSS); higher than 83.8% of all records.
  • Anyone who can reach it over the internet can trigger it. No account or password is required. No user action is required. No special conditions are required; it is repeatable.
  • Fixed version: py3-sqlparse (Alpine:v3.14) 0.4.2-r0; sqlparse (Debian:11) 0.4.1-1+deb11u1; sqlparse (Debian:12) 0.4.2-1.

Low priority for now. Upgrade to py3-sqlparse (Alpine:v3.14) 0.4.2-r0; sqlparse (Debian:11) 0.4.1-1+deb11u1; sqlparse (Debian:12) 0.4.2-1 or later.

Generated automatically from the record's data: CVSS (NVD and CNA), CISA KEV and SSVC, FIRST EPSS, exploit sources, fixed versions. How we calculate it

Primary sources: NVD · CVE.org · FIRST EPSS

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
Sep 20, 2021
Updated
Jun 16, 2026
EPSS
2.3% · 83th percentile

Report tools

JSON

Action score

31

Monitor

Low priority for now.

CVSS
30 / 40 · 7.5 / 10
CISA KEV
0 / 30 · Not listed
EPSS
1 / 30 · 2.3%

CNA vs NVD score

NVD
—
CNA · GitHub_M
7.5
NVD has not scored this yet; the score shown is the CNA’s.

The score given by the assigning authority versus NVD’s independent score. A gap means the severity is contested.

Get told when this record changes

  • Not in KEV: no record of exploitation in the wild
  • No public exploit code on record
  • A fix has been released

If any of these changes, we'll tell you in the daily email digest.

Follow CVE-2021-32839

When you'll hear from us

  • when it enters CISA KEV
  • when exploit code appears or is weaponized
  • when the record is updated (including a fixed version)
  • when EPSS rises 20 points in a week

One daily email digest (06:00 UTC); connect a webhook for KEV listings and weaponized exploits every 10 minutes on paid plans, on the hour on the free plan.

Your free account also gets you

  • CVE alerts: add the products and versions you run, get the new CVEs that affect them
  • Uptime monitoring: 1 site, instant email when it goes down
  • Add your domain: subdomains and takeover risk scanned every week (1 domain)
  • 10 scans an hour on the security tools, at most 30 a day (3 a day without an account), an API key and MCP
  • All your scans in one panel: findings, what changed in the last scan, a report per domain or per client (PDF, share link)
All free tools
Is your version affected? Check it

Noroxi analysis

What does it mean in your environment?

The assessment above is generated automatically from the record's data; it doesn't know your environment. Our team verifies on your systems whether this vulnerability is actually exploitable and which mitigation is enough.

We use this product, ask for help

Affected systems

Is your version affected?

Pick the product and type the version you run. It's compared with this record's version ranges in your browser; the version isn't sent anywhere.

VendorProduct
sqlparse projectsqlparse

Versions reported by the vendor

Affected version ranges reported by the assigning authority (GitHub_M). Independent of NVD's CPE analysis and usually ahead of it.

  • andialbrecht sqlparse

    • >= 0.4.0, < 0.4.2affected

Affected versions

NVD version ranges (for catalog products). Add the product to your stack with a version and matching uses these.

  • sqlparse project sqlparse0.4.0 and later · before 0.4.2

Package-level exposure

OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.

EcosystemPackageAffected rangeFix
Alpine:v3.14py3-sqlparsebefore 0.4.2-r00.4.2-r0
Debian:11sqlparsebefore 0.4.1-1+deb11u10.4.1-1+deb11u1
Debian:12sqlparsebefore 0.4.2-10.4.2-1
openSUSE:Leap 15.3python-sqlparsebefore 0.4.2-3.3.10.4.2-3.3.1
openSUSE:Tumbleweedpython-sqlparsebefore 0.5.5-2.10.5.5-2.1
openSUSE:Tumbleweedpython-sqlparsebefore 0.5.0-1.10.5.0-1.1
openSUSE:Tumbleweedpython-sqlparsebefore 0.4.2-1.10.4.2-1.1
PyPIsqlparsefrom 0.4.0 · before 0.4.20.4.2
Red Hat:satellite_capsule:6.11::el7foremanbefore 0:3.1.1.21-2.el7sat0:3.1.1.21-2.el7sat
Red Hat:satellite_capsule:6.11::el7libsolvbefore 0:0.7.22-1.el7pc0:0.7.22-1.el7pc
Red Hat:satellite_capsule:6.11::el7satellitebefore 0:6.11.0-2.el7sat0:6.11.0-2.el7sat
Red Hat:satellite_capsule:6.11::el8foremanbefore 0:3.1.1.21-2.el8sat0:3.1.1.21-2.el8sat
Red Hat:satellite_capsule:6.11::el8libsolvbefore 0:0.7.22-1.el8pc0:0.7.22-1.el8pc
Red Hat:satellite_capsule:6.11::el8python-djangobefore 0:3.2.13-1.el8pc0:3.2.13-1.el8pc
Red Hat:satellite_capsule:6.11::el8python-lxmlbefore 0:4.7.1-1.el8pc0:4.7.1-1.el8pc
Red Hat:satellite_capsule:6.11::el8python-sqlparsebefore 0:0.4.2-2.el8pc0:0.4.2-2.el8pc
Red Hat:satellite_capsule:6.11::el8python38-djangobefore 0:3.2.13-1.el8pc0:3.2.13-1.el8pc
Red Hat:satellite_capsule:6.11::el8satellitebefore 0:6.11.0-2.el8sat0:6.11.0-2.el8sat
Red Hat:satellite:6.11::el7candlepinbefore 0:4.1.13-1.el7sat0:4.1.13-1.el7sat
Red Hat:satellite:6.11::el7tfm-rubygem-actionpackbefore 0:6.0.4.7-1.el7sat0:6.0.4.7-1.el7sat
Red Hat:satellite:6.11::el7tfm-rubygem-pumabefore 0:5.6.2-1.el7sat0:5.6.2-1.el7sat
Red Hat:satellite:6.11::el7tfm-rubygem-puma-debuginfobefore 0:5.6.2-1.el7sat0:5.6.2-1.el7sat
Red Hat:satellite:6.11::el7tfm-rubygem-sidekiqbefore 0:5.2.10-1.el7sat0:5.2.10-1.el7sat
Red Hat:satellite:6.11::el8candlepinbefore 0:4.1.13-1.el8sat0:4.1.13-1.el8sat

+7

Other highest-scoring records for the same primary product.

  • CVE-2023-30608Parser contains an inefficient regular expression in sqlparse
    30Monitor

Remediation

Which version to upgrade to

Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.

Product / packageFixed versionSource
alpine:py3-sqlparse0.4.2-r0 · Alpine:v3.14Package registry (OSV)
debian:sqlparse0.4.2-1 · Debian:12Package registry (OSV)
opensuse:python-sqlparse0.4.2-3.3.1 · openSUSE:Leap 15.3Package registry (OSV)
PyPI:sqlparse0.4.2Package registry (OSV)
red hat:candlepin0:4.1.13-1.el7sat · Red Hat:satellite:6.11::el7Package registry (OSV)
red hat:foreman0:3.1.1.21-2.el7sat · Red Hat:satellite_capsule:6.11::el7Package registry (OSV)
red hat:libsolv0:0.7.22-1.el7pc · Red Hat:satellite_capsule:6.11::el7Package registry (OSV)
red hat:python-django0:3.2.13-1.el8pc · Red Hat:satellite_capsule:6.11::el8Package registry (OSV)
red hat:python-lxml0:4.7.1-1.el8pc · Red Hat:satellite_capsule:6.11::el8Package registry (OSV)
red hat:python-sqlparse0:0.4.2-2.el8pc · Red Hat:satellite_capsule:6.11::el8Package registry (OSV)
red hat:python38-django0:3.2.13-1.el8pc · Red Hat:satellite_capsule:6.11::el8Package registry (OSV)
red hat:rubygem-puma0:5.6.2-1.el8sat · Red Hat:satellite:6.11::el8Package registry (OSV)
red hat:satellite0:6.11.0-2.el7sat · Red Hat:satellite_capsule:6.11::el7Package registry (OSV)
red hat:tfm-rubygem-actionpack0:6.0.4.7-1.el7sat · Red Hat:satellite:6.11::el7Package registry (OSV)
red hat:tfm-rubygem-puma0:5.6.2-1.el7sat · Red Hat:satellite:6.11::el7Package registry (OSV)
red hat:tfm-rubygem-sidekiq0:5.2.10-1.el7sat · Red Hat:satellite:6.11::el7Package registry (OSV)
rocky linux:libdb0:5.3.28-42.el8_4 · Rocky Linux:8Package registry (OSV)
suse:python-sqlparse0.4.2-3.3.1 · SUSE:Linux Enterprise Module for Basesystem 15 SP3Package registry (OSV)

Exploit status

No known public exploit

No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.

Research context

For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.

Timeline

From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.

No dated events beyond publication.

Patch and commit links

Commit, PR and diff links among the references. A starting point for patch-diffing and variant hunting; fixes, not exploits.

Not on record for this CVE: EPSS history · researcher credit · variant or chain candidate · public bounty program.

Technical details

Attack conditions

  • Anyone who can reach it over the internet can trigger it.
  • No account or password is required.
  • No user action is required.
  • No special conditions are required; it is repeatable.

If successful

Confidentiality
none
Integrity
none
Availability
high · the service can be disrupted
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality impact
None
Integrity impact
None
Availability impact
High

CVSS vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

nvd-secondary

Root cause

Code that parses nested structures sets no depth or size limit. A small input can turn into a disproportionate processing load.

A representative example of this vulnerability class. Not the vendor's source code; it shows the faulty pattern and its fix.

Vulnerable

ts
function expand(node) {  return node.children.map(expand);}

Fixed

ts
const MAX_DEPTH = 32;function expand(node, depth = 0) {  if (depth > MAX_DEPTH) throw new Error("too deep");  return node.children.map((c) => expand(c, depth + 1));}

Attack context

MITRE CAPEC attack patterns and ATT&CK techniques for this weakness class (CWE). A starting point for detection rules and threat hunting.

References

All records