Skip to content
Heist/ feed
Back to feed
High

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-32839

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-32839
Confirmed fixed CVEs
Not specified
Updated in this feed
31 Oct 2026, 11:17 UTC · Revision 1

Source evidence

CVE-2021-32839

core-osv · Original source

Published 20 Sept 2021, 17:15 UTC

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.

osv:CVE-2021-32839
Complete source record
{
  "id": "f25a9eac6bcded464a172adbfe975af214258551d5d64ed02109505792a3d59d",
  "url": "https://osv.dev/vulnerability/CVE-2021-32839",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-32839",
    "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.",
    "evidence": "osv:CVE-2021-32839",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2021-32839",
      "aliases": [
        "CVE-2021-32839",
        "GHSA-p5w8-wqhj-9hhf",
        "PYSEC-2021-333"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/andialbrecht/sqlparse",
              "type": "GIT",
              "events": [
                {
                  "introduced": "982ecdf1ef1b3224ca0c4a8f3e7a50bbb59df559"
                },
                {
                  "fixed": "b1f76f6fa9763ee0f1d3a3870f05565abf1314e8"
                },
                {
                  "fixed": "8238a9e450ed1524e40cb3a8b0b3c00606903aeb"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:sqlparse_project:sqlparse:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0.4.0"
                      },
                      {
                        "fixed": "0.4.2"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "8238a9e450ed1524e40cb3a8b0b3c00606903aeb"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "0.4.1",
            "0.4.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-32839.json"
          }
        }
      ],
      "modified": "2026-10-20T10:53:46.461470412Z",
      "provider": "osv",
      "references": [
        "https://lists.debian.org/debian-lts-announce/2024/12/msg00022.html",
        "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-p5w8-wqhj-9hhf",
        "https://github.com/andialbrecht/sqlparse/commit/8238a9e450ed1524e40cb3a8b0b3c00606903aeb"
      ],
      "provider_metadata": {}
    },
    "related_cves": [
      {
        "value": "CVE-2021-32839",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 384606,
  "published_at": "2021-09-20T17:15:09.067+00:00"
}