Read the docs
TI-2021-12504 Aliases CVE-2021-32839GHSA-p5w8-wqhj-9hhf

Regular Expression Denial of Service in sqlparse

Priority LOW 37CWE-400Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
None
Attack complexity
Low
Impact type
Denial of service
Confidentiality · integrity · availability
None · None · High
Fix status
Partial Red Hat: 1 fixed, 4 without a fix

Attack profile from CVSS 3.1 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-400.

Summary

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.

Why it matters now

EPSS 0.02339 83rd percentileScored 2026-11-07
Fix Partial sqlparse (andialbrecht): 0.4.2sqlparse (PyPI): 0.4.2Red Hat: 1 advisoryRed Hat: 1 fixed, 4 without a fix

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
andialbrechtsqlparse0.4.0 to before 0.4.20.4.2Patch availableCNA
—sqlparse (PyPI)0.4.0 to before 0.4.20.4.2Patch availableGHSA-p5w8-wqhj-9hhf
  • sqlparse Vendorandialbrecht Affected 0.4.0 to before 0.4.2 Fixed in 0.4.2 Patch available CNA
  • sqlparse (PyPI) Vendor— Affected 0.4.0 to before 0.4.2 Fixed in 0.4.2 Patch available GHSA-p5w8-wqhj-9hhf

CPE configurations NVD · 1

CPEVersionsRoleVendor
cpe:2.3:a:sqlparse_project:sqlparse:*:*:*:*:*:*:*:*0.4.0 to before 0.4.2VulnerableSqlparse Project
  • cpe:2.3:a:sqlparse_project:sqlparse:*:*:*:*:*:*:*:* Versions 0.4.0 to before 0.4.2 Vulnerable ·Sqlparse Project

Remediation

  • Fix · CNA sqlparse (andialbrecht) Fixed in 0.4.2
  • Fix · GHSA-p5w8-wqhj-9hhf sqlparse (PyPI) Fixed in 0.4.2 Advisory →

Red Hat 1 advisory

  • RHSA-2022:5498 Released 2022-07-05 · Red Hat rating Moderate
    Satellite 6.11 Release
    • Red Hat Satellite 6.11 for RHEL 7 candlepin-4.1.13-1.el7sat, foreman-3.1.1.21-2.el7sat, libsolv-0.7.22-1.el7pc +4
    • Red Hat Satellite 6.11 for RHEL 8 candlepin-4.1.13-1.el8sat, foreman-3.1.1.21-2.el8sat, libsolv-0.7.22-1.el8pc +8

Vendor assessments

Red Hat

Red Hat rating: Moderate. Red Hat's page for this CVE →

ProductStatusPlan or fix
Red Hat Ansible Automation Platform 1.2AffectedNo fix yet
Red Hat Ansible Tower 3AffectedNo fix planned: Out of support scope
Red Hat OpenStack Platform 10 (Newton)AffectedNo fix planned: Out of support scope
Red Hat OpenStack Platform 13 (Queens)AffectedNo fix planned: Out of support scope
Red Hat Satellite 6.11 for RHEL 8Fixed RHSA-2022:5498
Not affected: 4 products
  • Red Hat OpenStack Platform 16.1
  • Red Hat OpenStack Platform 16.2
  • Red Hat Satellite 6.11 for RHEL 7
  • Red Hat Satellite 6.11 for RHEL 8

Timeline

  1. 2026-10-02 Threatist record created from CVE-2021-32839
  2. 2026-10-03 Alias added: GHSA-p5w8-wqhj-9hhf

References

  • TI-2026-39184 sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger CVSS 4.0HIGH 8.7
  • TI-2026-42707 sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service) CVSS 3.1HIGH 7.5
  • TI-2026-57940 sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption CVSS 4.0MEDIUM 5.1
  • TI-2026-50099 sqlparse: Quadratic O(n²) DoS in group_comments CVSS 4.0HIGH 8.7
  • TI-2026-76501 PHP code injection in sqlparse via output_format='php' CVSS 4.0HIGH 8.4
  • TI-2026-42708 sqlparse: Generated Python and PHP snippets allow SQL string breakout through unescaped backslashes CVSS 4.0MEDIUM 6.2

Sources