Vulnerability in sqlparse (CVE-2026-59893)
Summary
Vulnerability in sqlparse (CVE-2026-59893). Risk of unauthorized operations or information disclosure. Exploitable via SQL_REGEX. Mitigation: upgrade to 0.6.0 or later.
Original description
The description as published by the source.
Summary
sqlparse contains a Regular Expression Denial of Service (ReDoS) vulnerability in its dollar-quoted SQL literal lexer. The regex pattern at sqlparse/keywords.py:33 uses a backreference (\1) to match closing dollar-quote delimiters, causing O(n²) CPU complexity when processing inputs containing many unique, unmatched dollar-quote opening sequences. An attacker who can supply arbitrary SQL text to any application using sqlparse can trigger sustained CPU exhaustion, resulting in a denial of service. No authentication or special privileges are required.
Scope note: the same regex shape — a lazy dot-all quantifier terminated by a delimiter, applied at every input position by the lexer loop — is also present in the two multiline-comment patterns. Those are covered by this advisory and by the same fix; see "Additional affected pattern: multiline comments" below.
Details
The vulnerable regex is defined in sqlparse/keywords.py as part of SQL_REGEX:
# sqlparse/keywords.py:33
(r'((?<![\w\"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),
This pattern first captures a dollar-quote delimiter (e.g., $tag$) into group 1, then attempts to match any characters ([\s\S]*?) up to the same delimiter again via backreference \1. When no matching closing delimiter exists, the regex engine exhausts the remaining input before concluding there is no match. For a sequence of N unique unmatched openers, each opener triggers a full scan of the re…
Source: GitHub Security Advisories (Global) NVD GitHub Advisory
Auto-generated summary
Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.
A vulnerability tracked as CVE-2026-59893 has been found in sqlparse.
Attackers can target a specific entry point like SQL_REGEX over the network to misuse the product.
Risk of unauthorized operations or information disclosure. CVSS score: 7.5/10.
What to do: upgrade sqlparse to 0.6.0 or later.
If unsure, ask your IT team or search "sqlparse CVE-2026-59893" on the vendor's site.
CVE-2026-59893 (sqlparse) — CWE-1333 / CVSS v3 7.5
Attack vector: remote (network-reachable) / unauthenticated / no user interaction
Attack surface: SQL_REGEX / _SQL_REGEX / c923da9 / re.finditer
Patched: 0.6.0 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.
A vulnerability (CWE-1333) exists in sqlparse. Attackers reach the vulnerable code path via SQL_REGEX without authentication.
Check the vendor advisory for the affected versions of sqlparse. Attack surface: SQL_REGEX / _SQL_REGEX / c923da9 / re.finditer.
Severity: High (CVSS 7.5/10). Risk of unauthorized operations or information disclosure.
Update to 0.6.0.
Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.
Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'sqlparse' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.
Response actions
Concrete steps and command examples for SOC/SRE teams to execute in order
-
1Identify exposure identify
grep -r 'sqlparse' . | grep -v node_modulesリポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で
sqlparseを grep し、稼働しているサービス・バージョンを把握する。 -
2Apply patch patch
Upgrade sqlparse to 0.6.0ステージング環境で 0.6.0 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。
-
3Post-deployment verification verify
Confirm patched version is live in productionパッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。
Affected packages
References
- web github.com
- web security-advisories@github.com
- web github.com