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



GHSA-JV2J-MQMW-XVV5

GHSA-jv2j-mqmw-xvv5: Stack Overflow Denial of Service in SurrealDB Query Engine

Amit Schendel
Amit Schendel
Senior Security Researcher

Jun 20, 2026·6 min read·23 visits

Executive Summary (TL;DR)

A stack overflow vulnerability in SurrealDB allows authenticated users to trigger an uncatchable process abort by submitting queries with thousands of chained binary operators. The issue is resolved in version 3.1.5 by introducing a parser-level recursion depth limit.

An authenticated denial-of-service vulnerability in SurrealDB allows remote attackers with query privileges to crash the server process. The issue arises from uncontrolled recursion during the compilation, serialization, or deallocation of exceptionally deep Abstract Syntax Trees (ASTs). While the iterative Pratt parser successfully handles long flat sequences of binary operators without triggering recursion limits, the resulting AST structure causes stack overflow in downstream recursive tree-walking components.

Vulnerability Overview

SurrealDB is a multi-model database engine written in Rust that processes queries through its custom query language, SurrealQL. Plaintext queries are processed by a syntactic analyzer that translates statements into an Abstract Syntax Tree (AST) before compiler lowering and execution. The primary attack surface resides in endpoints exposing query-execution capabilities, specifically the HTTP /sql and WebSocket /rpc endpoints.

This vulnerability, tracked under GHSA-jv2j-mqmw-xvv5, is classified under CWE-674 (Uncontrolled Recursion) and CWE-400 (Uncontrolled Resource Consumption). It allows an authenticated user with low privileges to crash the database engine by executing a query containing a highly nested or extremely long flat chain of binary operators (e.g., thousands of additions or logical comparisons).

The impact is a total denial of service (DoS) affecting the SurrealDB node. Because SurrealDB operates as a single-process server, a crash terminates all active client connections and transactions across all database instances, namespaces, and tenants hosted on the affected system.

Root Cause Analysis

The root cause of this vulnerability lies in an architectural mismatch between the iterative query-parsing phase and the subsequent recursive AST-processing phases. SurrealDB's syntax parser uses a Pratt parser to handle operator precedence when parsing flat sequences of expressions and operators. Pratt parsing is executed iteratively using loops to append binary operators directly onto the spine of the AST.

Because this parsing phase operates iteratively rather than recursively, it successfully avoids standard call-stack limits or query-recursion guards. The parser processes arbitrarily long expressions without exhausting the call stack, producing an AST of arbitrary depth. For example, a query containing 50,000 chained addition operations yields a binary AST structure with a depth of 50,000 levels.

After parsing, downstream components walk the resulting deep AST to lower it to execution bytecode, serialize it for logs, or deallocate it from memory. These components perform recursive tree-walking operations. In Rust, the default deallocation (Drop implementation) for nested heap structures recursively destroys child nodes. Walking a 50,000-deep tree requires 50,000 nested stack frames, which quickly exhausts the typical 2MB stack space allocated to thread execution, triggering an uncatchable operating system-level stack overflow and a process abort.

Code Analysis and Remediation

The vulnerable implementation allowed the Pratt parser to build arbitrary tree depths because it lacked checks against the resulting AST height. Downstream components relied on standard recursion, which is highly sensitive to excessive nested structures. This code block shows how the Pratt parser built expression nodes iteratively, neglecting to validate overall depth constraints:

// Vulnerable parser pattern
fn parse_expr(&mut self, precedence: Precedence) -> Result<Expression, Error> {
    let mut left = self.parse_primary()?;
    while precedence < self.peek_precedence() {
        // Iterative loop permits infinite chaining
        // of binary operators, producing nested AST nodes
        left = self.parse_infix(left)?;
    }
    Ok(left)
}

The security patch introduced in SurrealDB version 3.1.5 resolves this vulnerability by establishing a strict recursion-depth budget during expression parsing. The expr_recursion_limit parameter (configurable via SURREAL_MAX_EXPRESSION_PARSING_DEPTH) is enforced directly in the parser logic. This prevents the construction of over-deep ASTs, raising a syntax error before any recursive traversals can be executed:

// Patched parser pattern
fn parse_expr(&mut self, precedence: Precedence, depth: u32) -> Result<Expression, Error> {
    // Enforce depth limit to prevent downstream stack overflow
    if depth > self.expr_recursion_limit {
        return Err(Error::MaxExpressionDepthExceeded);
    }
    let mut left = self.parse_primary(depth + 1)?;
    while precedence < self.peek_precedence() {
        left = self.parse_infix(left, depth + 1)?;
    }
    Ok(left)
}

This fix is complete because it addresses the issue at the ingestion layer, ensuring that no downstream compiler, serializer, or memory-cleanup operation ever encounters an AST that exceeds stack capacity.

Exploitation & Attack Methodology

To exploit this vulnerability, an attacker must have valid credentials with permission to execute arbitrary SurrealQL queries. The attack is performed by sending a single, malformed query consisting of a highly repetitive sequence of binary operators, such as addition (+) or logical operators (AND, OR). This payload can be transmitted via HTTP POST to the /sql endpoint or via persistent WebSocket frames to /rpc.

While the HTTP endpoint enforces a default 1 MiB body limit, a carefully crafted payload well below this limit can easily overflow the 2MB thread stack. The WebSocket /rpc endpoint is a highly reliable delivery vector because it often permits larger payloads. The attack sequence operates as follows:

No specialized tools are required. The following Python execution script demonstrates how a low-privileged authenticated session can trigger the crash:

import requests
 
url = "http://localhost:8000/sql"
headers = {"Accept": "application/json", "NS": "test", "DB": "test"}
# Generate deep operator chain
payload = "RETURN 1" + " + 1" * 45000 + ";"
 
try:
    response = requests.post(url, data=payload, headers=headers, auth=("user", "pass"))
    print("Status:", response.status_code)
except requests.exceptions.ConnectionError:
    print("[+] Success: Connection dropped. SurrealDB process terminated.")

Impact Assessment

The impact of this vulnerability is confined to service availability. Because the operating system terminates the process immediately following a stack overflow, the entire database engine halts. The vulnerability does not allow remote code execution or data extraction, nor does it result in database file corruption, since the crash occurs before transaction commit phases.

The CVSS v3.1 score is calculated as 6.5 (Medium). The score is limited by the requirement of valid credentials (PR:L). However, for multi-tenant SaaS environments or applications exposing raw query endpoints to low-privileged users, the impact is severe. An attacker can repeatedly execute the exploit to maintain a persistent state of denial of service, blocking all database transactions on the targeted host.

Remediation & Mitigation Guidance

The definitive fix for this vulnerability is upgrading SurrealDB to version 3.1.5 or later. If immediate upgrading is not possible, administrators should implement the following workarounds to reduce risk:

  1. Enable the --deny-arbitrary-query command-line capability flag. This restriction blocks ad-hoc user query execution, mitigating the risk from non-admin accounts.

  2. Implement ingress payload limitations on reverse proxies (e.g., NGINX or Envoy) to drop HTTP POST requests and WebSocket frames that exceed 50 KB, preventing large nested operator sequences from reaching the parser.

  3. Configure process supervision policies using systemd or Kubernetes restart policies. Ensure the database process restarts automatically on failure using configuration flags such as Restart=on-failure in the systemd service file.

Technical Appendix

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

Affected Systems

SurrealDB Server

Affected Versions Detail

Product
Affected Versions
Fixed Version
SurrealDB
SurrealDB
>= 3.0.0, < 3.1.53.1.5
AttributeDetail
CWE IDCWE-674, CWE-400
Attack VectorNetwork
CVSS v3.1 Score6.5 (Medium)
Exploit StatusProof-of-Concept
CISA KEV StatusNot Listed
ImpactDenial of Service (Process Abort)

MITRE ATT&CK Mapping

T1499.004Endpoint Denial of Service: Application Exhaustion
Impact
T1078Valid Accounts
Initial Access
CWE-674
Uncontrolled Recursion

The software directs the execution flow using recursion, but does not limit the number of recursive steps, leading to stack consumption and process termination.

References & Sources

  • [1]GitHub Security Advisory GHSA-jv2j-mqmw-xvv5
  • [2]SurrealDB GitHub Repository
  • [3]SurrealQL Operators Documentation

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

•39 minutes ago•CVE-2026-72695
8.1

CVE-2026-72695: Authenticated Path Traversal and Arbitrary File Deletion in Grav CMS MediaUploadTrait

A path traversal vulnerability exists in Grav CMS versions prior to 2.0.16. The flaw occurs within the file validation mechanisms of the MediaUploadTrait, enabling authenticated users with media management privileges to bypass sandbox limitations. This allows the deletion of arbitrary files on the filesystem, which can result in denial of service or remote code execution.

Amit Schendel
Amit Schendel
1 views•7 min read
•about 2 hours ago•CVE-2026-74907
5.9

CVE-2026-74907: Directory Traversal in Grav CMS Pre-Boot Static Asset Server

An unauthenticated directory traversal vulnerability exists in Grav CMS prior to version 2.0.15. Due to an insecure string-based containment check (str_starts_with) in the pre-boot static asset server, attackers can read files in sibling directories sharing a prefix with the configured asset path when plugin-asset-map.php is enabled.

Amit Schendel
Amit Schendel
4 views•7 min read
•about 3 hours ago•CVE-2026-75828
9.3

CVE-2026-75828: Stored Cross-Site Scripting (XSS) via Security Filter Bypass in Grav CMS

CVE-2026-75828 is a critical stored cross-site scripting (XSS) vulnerability in the getgrav Grav CMS before version 2.0.15. The vulnerability resides in the detectXss() security filter mechanism, where parser-differential mismatches between the regular-expression-based server-side validation and browser HTML5 tokenization allow authenticated editors to bypass event-handler detection and inject arbitrary JavaScript execution vectors.

Amit Schendel
Amit Schendel
6 views•4 min read
•about 4 hours ago•CVE-2026-75827
8.8

CVE-2026-75827: Grav Arbitrary File Write & Remote Code Execution

An arbitrary file write and remote code execution vulnerability exists in Grav CMS before version 2.0.15. The vulnerability is caused by using an incomplete denylist validation approach for bare PHP functions in the Blueprint dynamic-data compiler, allowing authenticated users with page-editing or blueprint-configuration privileges to execute arbitrary functions such as error_log.

Alon Barad
Alon Barad
6 views•4 min read
•about 5 hours ago•CVE-2026-75834
5.4

CVE-2026-75834: Input Sanitization Bypass leading to Stored XSS in Grav CMS

CVE-2026-75834 is a stored Cross-Site Scripting (XSS) vulnerability in Grav CMS core, caused by a design flaw in its input validation wrapper Security::detectXss(). Regular expressions using the PCRE UTF-8 /u modifier fail-open when encountering invalid UTF-8 sequences or when the PCRE JIT stack limit is exhausted, allowing authenticated users with page-editing privileges to save malicious HTML and scripts.

Alon Barad
Alon Barad
6 views•6 min read
•about 6 hours ago•CVE-2026-75837
9.1

CVE-2026-75837: Privilege Escalation in Grav CMS via Missing Blueprint Validation

CVE-2026-75837 is a critical privilege escalation vulnerability affecting the Grav Flat-File Content Management System (CMS) in versions prior to 2.0.14. Due to a missing security guard on the access field within the core Flex group blueprint configuration file (system/blueprints/user/group.yaml), a delegated administrative operator can submit a crafted payload to elevate their permissions to super-administrator, which can then be leveraged to achieve remote code execution.

Alon Barad
Alon Barad
5 views•8 min read