LiveActive security incident?Get immediate response
CVE Record

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

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.

HighCVSS 7.5Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

sqlparse 0.4.0 and 0.4.1 can be forced to spend excessive CPU when removing SQL comments. An attacker who can submit crafted SQL text to a service using that feature could cause denial of service. The issue is fixed in sqlparse 0.4.2.

Executive priority

Treat as high priority for services that accept user-controlled SQL and perform formatting. For internal-only tools without untrusted input, urgency is lower but still remediate through normal dependency management.

Technical view

The flaw is a Regular Expression Denial of Service in sqlparse comment stripping. The vulnerable regex can exponentially backtrack on SQL comments containing many repeated CRLF sequences. Sources state only sqlparse formatting with strip_comments=True, or sqlformat with --strip-comments, is affected.

Likely exposure

Exposure is likely where Python applications use sqlparse versions 0.4.0 or 0.4.1 and process untrusted SQL through comment-stripping formatting. General parsing or formatting without comment removal is not identified as affected in the provided sources.

Exploitation context

The CVE has CVSS 7.5 for network-reachable, unauthenticated availability impact, but the bundle does not cite active exploitation and KEV is false. Evidence supports denial-of-service risk, not confidentiality or integrity impact.

Researcher notes

The affected range and workaround are clear from the advisory. The provided evidence does not show exploitation in the wild. Validation should focus on the narrow affected feature, because the advisory says only comment-stripping formatting is impacted.

Mitigation direction

  • Upgrade sqlparse to version 0.4.2 or later.
  • Disable strip_comments=True where upgrade is not immediately possible.
  • Avoid sqlformat --strip-comments on untrusted SQL input.
  • Check downstream distribution advisories for packaged sqlparse updates.
  • Prioritize exposed services that format user-supplied SQL.

Validation and detection

  • Inventory Python dependencies for sqlparse 0.4.0 or 0.4.1.
  • Review code paths using sqlparse.format with strip_comments=True.
  • Review jobs or tooling invoking sqlformat with --strip-comments.
  • Confirm production packages resolve to sqlparse 0.4.2 or later.
  • Document whether untrusted users can reach comment-stripping functionality.
Prepared
Confidence
high
Sources
5

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · low confidence lookup

CWE-400: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2021-32839 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
7.5 (3.1)
Known Exploited
No
Published

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

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
4Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
7.5CVSS 3.1HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H3.93.6Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

7.5High
CVSS 3.1 vector shape for CVE-2021-32839Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

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

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
andialbrechtsqlparse>= 0.4.0, < 0.4.2Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.