CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-59893

CVE-2026-59893: Regular Expression Denial of Service in sqlparse Lexer

Alon Barad
Alon Barad
Software Engineer

Aug 17, 2026·6 min read·126 visits

Executive Summary (TL;DR)

sqlparse prior to 0.6.0 is vulnerable to O(N^2) CPU exhaustion (ReDoS) when processing SQL strings with unmatched PostgreSQL dollar-quoted tags or unclosed multiline comments.

A high-severity Regular Expression Denial of Service (ReDoS) vulnerability in the sqlparse Python library prior to version 0.6.0 allows unauthenticated remote attackers to trigger CPU exhaustion and application denial of service via crafted SQL inputs containing unmatched dollar-quoted literals or unclosed multiline comments.

Vulnerability Overview

The sqlparse library is a widely deployed, non-validating SQL parser module for Python, commonly used to tokenize, format, and split SQL queries. Because it handles raw SQL strings from potentially untrusted sources, it is an entry point for processing external inputs in database administration tools, ORMs, and query sanitization engines.

A critical vulnerability, classified as CVE-2026-59893, is present in the core lexical analyzer of sqlparse prior to version 0.6.0. The vulnerability belongs to the Regular Expression Denial of Service (ReDoS) category, tracked under CWE-1333. The issue arises from inefficient regular expression evaluation when handling block-style SQL constructs, such as PostgreSQL-style dollar-quoted literals and standard SQL multiline comments.

An unauthenticated remote attacker can exploit this vulnerability by submitting a crafted SQL string containing numerous unmatched opening delimiters. Processing this payload causes the regex engine to perform quadratic backtracking, leading to high CPU utilization. This resource exhaustion results in a complete Denial of Service of the application performing the SQL parsing.

Root Cause Analysis

The underlying root cause resides in the regular expression patterns defined in sqlparse/keywords.py that identify block-style delimiters. The expression used for dollar-quoted literals is defined with a lazy dot-all quantifier: ((?<![\w"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1. This pattern matches any characters up to the matching closing delimiter backreference.

Similarly, multiline comments are identified using the patterns /\*\+[\s\S]*?\*/ and /\*[\s\S]*?\*/. When these expressions are evaluated against an input string containing unmatched opening delimiters, the lazy match [\s\S]*? continues consuming characters until it reaches the end of the text. Because there is no matching closing delimiter, the match fails, forcing the regex engine to backtrack.

The issue is amplified by the main lexer loop in sqlparse/lexer.py. The loop evaluates each regular expression sequentially at every character position in the input string. Consequently, for $N$ unmatched opening delimiters, the engine scans the remaining string of length $N, N-1, N-2, \dots, 1$, resulting in a quadratic processing complexity of $O(N^2)$.

Code Analysis

Prior to version 0.6.0, the lexer evaluated the vulnerable regular expressions directly during sequential scanning. Because there was no pre-filtering, every unique opener triggered a complete scan of the remaining string. The following snippet shows the vulnerable configuration within sqlparse/keywords.py:

# sqlparse/keywords.py (Prior to 0.6.0)
SQL_REGEX = [
    (r'/\*\+[\s\S]*?\*/', tokens.Comment.Multiline.Hint),
    (r'/\*[\s\S]*?\*/',    tokens.Comment.Multiline),
    # ...
    (r'((?<![\w"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),
]

The security patch implemented in commit d1d80602741f77ec78e5a04ce4719244cf32352e removes these backtracking patterns from the SQL_REGEX list. Instead, a new linear-time pre-scanning function, find_delimited_spans, is used to identify blocks. This function processes delimiters using non-backtracking patterns and pairs them left-to-right using an iterative stack model.

# sqlparse/keywords.py (Patched in 0.6.0)
_DOLLAR_QUOTE_DELIM = re.compile(r'\$(?:[_A-ZÀ-Ü]\w*)?\$', re.IGNORECASE | re.UNICODE)
_COMMENT_OPEN = re.compile(r'/\*(?!\+)')
_COMMENT_CLOSE = re.compile(r'\*/')
 
def find_delimited_spans(text):
    # Pre-scans and resolves delimiters in a single pass
    occurrences.sort(key=lambda occ: occ.start)
    spans = resolve_paired_delimiters(occurrences)
    return {start: (end, ttype) for start, end, ttype in spans}

The lexer loop in sqlparse/lexer.py was also modified to check the pre-scanned delimited_spans dictionary before executing any active regex checks. If the current position matches a pre-resolved span, the parser yields the complete token and skips the entire block using the consume utility, avoiding redundant evaluations.

Exploitation Methodology

Exploiting CVE-2026-59893 requires sending a SQL payload with a large number of unclosed delimiters. For dollar-quoted literals, the payload must consist of unique tags to prevent intermediate matching. For example, $a0$x $a1$x $a2$x ... $aN$x represents a structure where each identifier is treated as a unique, unmatched delimiter.

Similarly, a comment payload can be crafted by repeating unclosed comments separated by non-comment characters, such as /*x /*x /*x ... /*x. Without the space or letter separator, contiguous comment sequences can trigger quick-fail rules; spacing forces full validation at each index.

Because the processing occurs on the main thread during tokenization, a single HTTP request containing a relatively small payload can consume excessive CPU time. In single-threaded Python application frameworks, this blocks the entire service worker, preventing other network requests from being processed.

> [!WARNING] > Attackers can automate concurrent submissions of these payloads to completely exhaust multiple server workers, resulting in a persistent denial of service.

Impact Assessment

The impact of CVE-2026-59893 is focused entirely on application availability. The CVSS 3.1 base score is 7.5, reflecting a High severity rating. The vector is CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.

Because sqlparse is widely integrated across Python frameworks, the vulnerability has broad system-level exposure. It impacts dependent tools like Django Debug Toolbar, query formatters, and database synchronization scripts. In cloud environments with auto-scaling enabled, exploitation can lead to increased infrastructure costs as new instances are continuously provisioned to handle the artificially inflated CPU demand.

There is no potential for confidentiality loss or integrity compromise, as the bug does not allow arbitrary code execution or memory corruption. However, the ease of crafting the payload and the prevalence of the library make this a high-priority vulnerability for security teams to address.

Remediation and Mitigation

The primary remediation for CVE-2026-59893 is to upgrade sqlparse to version 0.6.0 or later. This release replaces the backtracking regex patterns with a linear-time pre-scanning and pairing algorithm. To execute the upgrade, update requirements files or run the upgrade command directly:

pip install --upgrade sqlparse>=0.6.0

If upgrading is not immediately possible, you can implement input validation to restrict the maximum length of user-supplied SQL strings. Setting a maximum threshold of 10,000 characters prevents payloads from containing enough delimiters to cause severe CPU degradation.

Web application firewalls can also be configured with rules to identify and block requests containing multiple unmatched comment markers or dollar-sign symbols. Additionally, wrapping calls to sqlparse APIs in secondary threads or processes with timeout handlers ensures that runaway execution can be safely terminated.

Official Patches

Andi AlbrechtOfficial patch resolving ReDoS in lexer.

Fix Analysis (1)

Technical Appendix

CVSS Score
7.5/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Affected Systems

sqlparse (Python module)

Affected Versions Detail

Product
Affected Versions
Fixed Version
sqlparse
Andi Albrecht
< 0.6.00.6.0
AttributeDetail
CWE IDCWE-1333
Attack VectorNetwork (AV:N)
CVSS v3.1 Score7.5 (High)
Exploit StatusProof-of-Concept Available
Affected ComponentLexer Engine (sqlparse/keywords.py)
Vulnerability ClassRegular Expression Denial of Service (ReDoS)

MITRE ATT&CK Mapping

T1499.003Endpoint Denial of Service: System CPU Exhaustion
Impact
CWE-1333
Inefficient Regular Expression Complexity

The product uses a regular expression with an inefficient complexity that can be exploited to cause a denial of service via resource exhaustion.

Known Exploits & Detection

GitHub Security AdvisoryAdvisory containing PoC reproduction steps for unmatched dollar-quote tokens and multiline comments.

Vulnerability Timeline

Patch committed to official repository
2026-07-01
GitHub Advisory Published
2026-08-17
CVE Assigned and Published
2026-08-17

References & Sources

  • [1]GitHub Commit Fix
  • [2]GitHub Security Advisory
  • [3]CVE Official Record

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 7 hours ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
4 views•10 min read
•about 8 hours ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
5 views•12 min read
•about 9 hours ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
5 views•12 min read
•about 10 hours ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
4 views•10 min read
•about 11 hours ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
9 views•10 min read
•about 12 hours ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
5 views•9 min read