<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:webfeeds="http://webfeeds.org/rss/1.0"><channel><title>Sqlparse (&lt;= 0.5.5) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/sqlparse--0.5.5/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Mon, 17 Aug 2026 18:46:25 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/sqlparse--0.5.5/feed.xml" rel="self" type="application/rss+xml"/><image><url>https://feed.craftedsignal.io/favicon-32x32.png</url><title>CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/</link><width>32</width><height>32</height></image><webfeeds:icon>https://feed.craftedsignal.io/favicon.svg</webfeeds:icon><item><title>SQLParse CPU Denial of Service via Algorithmic Complexity</title><link>https://feed.craftedsignal.io/briefs/2026-08-sqlparse-dos/</link><pubDate>Mon, 17 Aug 2026 18:46:25 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-08-sqlparse-dos/</guid><description>A complexity vulnerability in sqlparse &lt;= 0.5.5 allows attackers to trigger CPU exhaustion through deeply nested SQL structures, achieving significant amplification and causing denial of service in downstream applications.</description><content:encoded><![CDATA[<p>The Python library <code>sqlparse</code> (version 0.5.5 and earlier) is vulnerable to an algorithmic complexity denial-of-service (DoS) attack. The vulnerability exists within <code>TokenList.__init__</code>, which performs an eager, recursive flattening of the SQL subtree (via <code>str(self)</code>) during the construction of every token group.</p>
<p>When <code>sqlparse</code> processes input containing deeply nested structures such as parentheses, <code>CASE WHEN</code> chains, or nested subqueries, the parser performs work proportional to <code>O(n*d)</code> (where <code>n</code> is the number of tokens and <code>d</code> is the nesting depth). This results in a massive CPU amplification - approximately 5000x for a ~2 KB payload - that consumes significant CPU time before reaching the library's built-in depth and token caps. An attacker can exhaust worker pools in multi-threaded web applications or lock up single-threaded services by sending a small number of these crafted malicious SQL payloads. The issue affects any consumer of <code>sqlparse</code> that exposes the parser to unauthenticated user input, including formatters, debug toolbars, and metadata analysis tools.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker identifies a target application utilizing <code>sqlparse</code> to process user-supplied SQL queries (e.g., SQL formatters or database debug interfaces).</li>
<li>Attacker crafts a malicious 1-2 KB SQL payload containing high levels of nesting, such as <code>SELECT (((((...)))))</code> (2000+ levels) or deeply nested <code>CASE WHEN</code> branches.</li>
<li>Attacker sends multiple parallel HTTP POST requests containing the crafted payload to the vulnerable endpoint.</li>
<li>The application triggers <code>sqlparse.parse()</code> or <code>sqlparse.format()</code> upon receiving the input.</li>
<li>The library's <code>TokenList.__init__</code> is invoked recursively during grouping, triggering the <code>O(n*d)</code> flattening logic.</li>
<li>The system enters a high-CPU state while performing recursive flattening, effectively locking the worker process.</li>
<li>The application worker remains unresponsive for seconds to tens of seconds per request.</li>
<li>Concurrent requests exhaust the available worker pool, resulting in a denial-of-service condition for legitimate users.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation leads to resource exhaustion and service unavailability. Observations indicate that a single 2 KB payload can pin a CPU worker at 100% utilization for approximately 10 seconds. In environments with a limited worker pool, a small number of concurrent requests can result in total service outage. Downstream libraries, such as <code>sql-metadata</code>, also inherit this vulnerability, extending the impact to any tool using <code>sqlparse</code> for internal query analysis.</p>
<h2 id="recommendation">Recommendation</h2>
<ol>
<li>Immediately upgrade <code>sqlparse</code> to a version that implements the patch described in the advisory (replacing eager <code>str(self)</code> materialization with concatenation of cached values).</li>
<li>Implement request-size limits and payload-structure complexity heuristics at the WAF or reverse proxy level to detect and drop highly nested SQL patterns before they reach the application.</li>
<li>Ensure application-level timeouts are configured for all database-related processing functions to prevent worker-pool starvation from slow-running parser tasks.</li>
<li>Review internal usage of <code>sqlparse</code> in debug toolbars or log formatters to ensure untrusted user input is not passed directly to library entry points without sanitization or strict depth validation.</li>
</ol>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>dos</category><category>algorithmic-complexity</category><category>sqlparse</category><category>cve-2026-54284</category><category>denial-of-service</category><category>vulnerability</category></item></channel></rss>