CVE-2026-84305: sqlparse: Reindentation of tuple lists causes near-cap quadratic CPU consumption

Published Sep 1, 2026
·
Updated

sqlparse is a non-validating SQL parser module for Python. Prior to 0.6.0, sqlparse.format(sql, reindent=True) and sqlformat --reindent route attacker-controlled parenthesized tuple lists through ReindentFilter.getoffset() in sqlparse/filters/reindent.py, where flattenuptotoken() repeatedly rebuilds and joins the statement prefix. Thousands of offset calculations walk an expanding token tree, producing quadratic CPU consumption for inputs that remain below MAXGROUPINGTOKENS and causing request delays, reduced throughput, or worker starvation. This issue is fixed in version 0.6.0.

Affected Software

1 affected component
pypi/sqlparse<0.6.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade sqlparse to a version that resolves this vulnerability.

    Fixed in 0.6.0

Event History

Sep 1, 2026
CVE Published
via MITRE·06:33 PM
Data Sourced
via MITRE·06:33 PM
DescriptionWeakness

Frequently Asked Questions

1

Who is realistically exposed to this issue?

Applications that use sqlparse to format attacker-controlled SQL with sqlparse.format(sql, reindent=True), or expose the sqlformat command with the --reindent option, are exposed. The impact is CPU exhaustion that can delay requests, reduce throughput, or starve workers.

2

What input or access does an attacker need?

An attacker needs to supply SQL that reaches reindentation and contains parenthesized tuple lists engineered to trigger many offset calculations. The described inputs can remain below MAX_GROUPING_TOKENS.

3

Are default sqlparse parsing operations affected?

The issue is specifically described in the reindentation paths: sqlparse.format(sql, reindent=True) and sqlformat --reindent. The provided information does not identify other parsing or formatting configurations as affected.

4

What should be done if upgrading cannot happen immediately?

Avoid applying reindentation to attacker-controlled SQL by disabling reindent=True and not exposing sqlformat --reindent to untrusted input. Upgrade to sqlparse 0.6.0 when possible.

5

How can teams determine whether they may already be affected?

Review application code and operational tooling for sqlparse.format calls that set reindent=True and for sqlformat invocations using --reindent on untrusted SQL. Review performance incidents for high CPU, request delays, reduced throughput, or worker starvation associated with formatting inputs containing large parenthesized tuple lists.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203