CVE-2021-32839: Regular Expression Denial of Service in sqlparse
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
- CWE
- CWE-400
Report tools
Action score
31
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.
Is your version affected? Check itNoroxi 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 helpAffected 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.
| Vendor | Product | CPE |
|---|---|---|
| sqlparse project | sqlparse | cpe:2.3:a:sqlparse_project:sqlparse |
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.
| Ecosystem | Package | Affected range | Fix |
|---|---|---|---|
| Alpine:v3.14 | py3-sqlparse | before 0.4.2-r0 | 0.4.2-r0 |
| Debian:11 | sqlparse | before 0.4.1-1+deb11u1 | 0.4.1-1+deb11u1 |
| Debian:12 | sqlparse | before 0.4.2-1 | 0.4.2-1 |
| openSUSE:Leap 15.3 | python-sqlparse | before 0.4.2-3.3.1 | 0.4.2-3.3.1 |
| openSUSE:Tumbleweed | python-sqlparse | before 0.5.5-2.1 | 0.5.5-2.1 |
| openSUSE:Tumbleweed | python-sqlparse | before 0.5.0-1.1 | 0.5.0-1.1 |
| openSUSE:Tumbleweed | python-sqlparse | before 0.4.2-1.1 | 0.4.2-1.1 |
| PyPI | sqlparse | from 0.4.0 · before 0.4.2 | 0.4.2 |
| Red Hat:satellite_capsule:6.11::el7 | foreman | before 0:3.1.1.21-2.el7sat | 0:3.1.1.21-2.el7sat |
| Red Hat:satellite_capsule:6.11::el7 | libsolv | before 0:0.7.22-1.el7pc | 0:0.7.22-1.el7pc |
| Red Hat:satellite_capsule:6.11::el7 | satellite | before 0:6.11.0-2.el7sat | 0:6.11.0-2.el7sat |
| Red Hat:satellite_capsule:6.11::el8 | foreman | before 0:3.1.1.21-2.el8sat | 0:3.1.1.21-2.el8sat |
| Red Hat:satellite_capsule:6.11::el8 | libsolv | before 0:0.7.22-1.el8pc | 0:0.7.22-1.el8pc |
| Red Hat:satellite_capsule:6.11::el8 | python-django | before 0:3.2.13-1.el8pc | 0:3.2.13-1.el8pc |
| Red Hat:satellite_capsule:6.11::el8 | python-lxml | before 0:4.7.1-1.el8pc | 0:4.7.1-1.el8pc |
| Red Hat:satellite_capsule:6.11::el8 | python-sqlparse | before 0:0.4.2-2.el8pc | 0:0.4.2-2.el8pc |
| Red Hat:satellite_capsule:6.11::el8 | python38-django | before 0:3.2.13-1.el8pc | 0:3.2.13-1.el8pc |
| Red Hat:satellite_capsule:6.11::el8 | satellite | before 0:6.11.0-2.el8sat | 0:6.11.0-2.el8sat |
| Red Hat:satellite:6.11::el7 | candlepin | before 0:4.1.13-1.el7sat | 0:4.1.13-1.el7sat |
| Red Hat:satellite:6.11::el7 | tfm-rubygem-actionpack | before 0:6.0.4.7-1.el7sat | 0:6.0.4.7-1.el7sat |
| Red Hat:satellite:6.11::el7 | tfm-rubygem-puma | before 0:5.6.2-1.el7sat | 0:5.6.2-1.el7sat |
| Red Hat:satellite:6.11::el7 | tfm-rubygem-puma-debuginfo | before 0:5.6.2-1.el7sat | 0:5.6.2-1.el7sat |
| Red Hat:satellite:6.11::el7 | tfm-rubygem-sidekiq | before 0:5.2.10-1.el7sat | 0:5.2.10-1.el7sat |
| Red Hat:satellite:6.11::el8 | candlepin | before 0:4.1.13-1.el8sat | 0:4.1.13-1.el8sat |
+7
Same product
sqlparse project: all recordsOther highest-scoring records for the same primary product.
- CVE-2023-30608Parser contains an inefficient regular expression in sqlparse30Monitor
Remediation
Which version to upgrade to
Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.
| Product / package | Fixed version | Source |
|---|---|---|
| alpine:py3-sqlparse | 0.4.2-r0 · Alpine:v3.14 | Package registry (OSV) |
| debian:sqlparse | 0.4.2-1 · Debian:12 | Package registry (OSV) |
| opensuse:python-sqlparse | 0.4.2-3.3.1 · openSUSE:Leap 15.3 | Package registry (OSV) |
| PyPI:sqlparse | 0.4.2 | Package registry (OSV) |
| red hat:candlepin | 0:4.1.13-1.el7sat · Red Hat:satellite:6.11::el7 | Package registry (OSV) |
| red hat:foreman | 0:3.1.1.21-2.el7sat · Red Hat:satellite_capsule:6.11::el7 | Package registry (OSV) |
| red hat:libsolv | 0:0.7.22-1.el7pc · Red Hat:satellite_capsule:6.11::el7 | Package registry (OSV) |
| red hat:python-django | 0:3.2.13-1.el8pc · Red Hat:satellite_capsule:6.11::el8 | Package registry (OSV) |
| red hat:python-lxml | 0:4.7.1-1.el8pc · Red Hat:satellite_capsule:6.11::el8 | Package registry (OSV) |
| red hat:python-sqlparse | 0:0.4.2-2.el8pc · Red Hat:satellite_capsule:6.11::el8 | Package registry (OSV) |
| red hat:python38-django | 0:3.2.13-1.el8pc · Red Hat:satellite_capsule:6.11::el8 | Package registry (OSV) |
| red hat:rubygem-puma | 0:5.6.2-1.el8sat · Red Hat:satellite:6.11::el8 | Package registry (OSV) |
| red hat:satellite | 0:6.11.0-2.el7sat · Red Hat:satellite_capsule:6.11::el7 | Package registry (OSV) |
| red hat:tfm-rubygem-actionpack | 0:6.0.4.7-1.el7sat · Red Hat:satellite:6.11::el7 | Package registry (OSV) |
| red hat:tfm-rubygem-puma | 0:5.6.2-1.el7sat · Red Hat:satellite:6.11::el7 | Package registry (OSV) |
| red hat:tfm-rubygem-sidekiq | 0:5.2.10-1.el7sat · Red Hat:satellite:6.11::el7 | Package registry (OSV) |
| rocky linux:libdb | 0:5.3.28-42.el8_4 · Rocky Linux:8 | Package registry (OSV) |
| suse:python-sqlparse | 0.4.2-3.3.1 · SUSE:Linux Enterprise Module for Basesystem 15 SP3 | Package 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
Weakness class (CWE)
CWE-400 · Uncontrolled Resource ConsumptionCVSS 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.
The bug in code
The whole CWE-400 classA representative example of this vulnerability class. Not the vendor's source code; it shows the faulty pattern and its fix.
Vulnerable
function expand(node) {
return node.children.map(expand);
}Fixed
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.
Change log (1)
- Fix✗ → ✓
For records you follow, these changes also arrive as notifications. →
References
Show all references (2 more)Show less
Vendor advisories and official records. Exploit/PoC links are deliberately left out.