mediumVulnerability

CVE-2026-84305

### Summary When SQL is formatted with reindentation enabled, `ReindentFilter` repeatedly rebuilds prefixes of the current statement to calculate token offsets. An attacker who controls SQL sent to this opt-in formatting path can supply a parenthesized tuple list that remains just below the grouping-token cap. Thousands of offset calculations then traverse an expanding token tree, causing multi-second CPU consumption from an input of roughly 16 KB and degrading service availability. ### Details `ReindentFilter._get_offset()` joins the tokens returned by `_flatten_up_to_token()` to calculate the current output position. Each call begins by flattening the current statement from its start and walks until the target token. Tuple-list reindentation invokes this calculation repeatedly as it processes many parenthesized values, so later calls redo an increasingly large amount of prior work. The vulnerable path is reached through `sqlparse.format(sql, reindent=True)` and `sqlformat --reindent`. A carefully sized tuple list completes grouping below the configured token cap and then enters the expensive reindentation path; a slightly larger input may instead be rejected quickly by the cap. Relevant code locations: - `sqlparse/formatter.py:170` — enabling `ReindentFilter` - `sqlparse/filters/reindent.py:30` — repeated flattening from the statement start - `sqlparse/filters/reindent.py:44` — prefix joining for offset calculation - `sqlparse/filters/reindent.py:216` — tuple-list processing path ### PoC A complete validated reproduction is attached as [reindent_tuple_list_cpu_dos-poc.zip](https://github.com/user-attachments/files/29410152/reindent_tuple_list_cpu_dos-poc.zip). The archive contains `reproduction/` at its root, uses Git and Docker, and compares two same-shape tuple-list inputs formatted with reindentation enabled. Extract the archive beside this report, then run: ```console ./reproduction/run.sh ``` Observed result: The 600-tuple baseline completed in 0.

Properties

ghsa_id
GHSA-cfqr-cjx5-5jcm
severity
medium
summary
sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption
cve_id
CVE-2026-84305
is_ghsa_only
false
ghsa_published
2026-09-01T21:20:11Z
source_url
https://github.com/advisories/GHSA-cfqr-cjx5-5jcm
ghsa_updated
2026-09-01T21:21:22Z

Related Entities (4)

VULNERABLE_TO (1)

[Software]pip/sqlparse

AFFECTS (1)

[Software]pip/sqlparse

HAS_WEAKNESS (1)

[Weakness]Inefficient Algorithmic Complexity

REPORTED_BY (1)

[Source]GitHub Advisory Database

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-84305 — Ninja Signal Threat Intelligence | Ninja Signal