CVE-2025-71393
JSON

6.0medium

SurrealDB before 2.2.2 Memory Exhaustion via Nested Functions

Severity
6.0medium CVSS:4.0 by VulnCheck
Exploit likelihood
0.34% (higher than 29% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-m7rc-8w7m-r9qr

Description

SurrealDB before 2.2.2 with scripting enabled fails to properly enforce recursion limits when native functions contain embedded JavaScript that issues new queries. Authenticated attackers can bypass the recursion limit by chaining native and JavaScript function calls to trigger infinite recursion and exhaust server memory.

Affected

Product or packageVersionsReported by
surrealdb surrealdbfrom 2.2.0 before 2.2.2, from 2.1.0 before 2.1.5, before 2.0.5
Not affected: 2.2.2, 2.1.5, 2.0.5
CVE List, NVD
surrealdb (crates.io)from 2.2.0 before 2.2.2, from 2.1.0 before 2.1.5, before 2.0.5GitHub Advisory Database

All scores

VulnCheck6.0medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-674

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

SurrealDB before 2.2.2 with scripting enabled fails to properly enforce recursion limits when native functions contain embedded JavaScript that issues new queries. Authenticated attackers can bypass the recursion limit by chaining native and JavaScript function calls to trigger infinite recursion and exhaust server memory.

GitHub Advisory Database

In order to prevent DoS situations due to infinite recursions, SurrealDB implements a limit of nested calls for both native functions and embedded JavaScript functions.

However, in SurrealDB instances with embedded scripting functions enabled, it was found that this limit can be circumvented by utilizing both at the same time. If a native function contains JavaScript which issues a new query that calls that function, the recursion limit is not triggered.

Once executed, SurrealDB will follow the path of infinite recursions until the system runs out of memory, prior to the recursion limit being triggered.

This vulnerability can only affect SurrealDB servers explicitly enabling the scripting capability with --allow-scripting or --allow-all and equivalent environment variables SURREAL_CAPS_ALLOW_SCRIPT=true and SURREAL_CAPS_ALLOW_ALL=true.

This issue was discovered and patched during an code audit and penetration test of SurrealDB by cure53, the severity defined within cure53's preliminary finding is Medium, matched by our CVSS v4 assessment.

Impact

For SurrealDB instances with embedded scripting functions enabled, this attack could be used to perform a DoS attack on the server by an authenticated user.

Patches

A patch has been created that further limits scripting function call limit recursion depth and disallows multiple calls to surreadb.query() to run in parallel in a scripting function.

  • Versions 2.0.5, 2.1.5, 2.2.2 and later are not affected by this issue.
Workarounds

Deny execution of embedded scripting functions through the configuration of capabilities by starting SurrealDB with the --deny-scripting flag or the equivalent environment variable SURREAL_CAPS_DENY_SCRIPT=true. This has a usability implication, although scripting functions are disabled by default.

References

SurrealDB Documentation - Capabilities SurrealQL Documentation - Scripting Functions

NVD (es)

SurrealDB anterior a 2.2.2 con scripting habilitado no aplica correctamente los límites de recursión cuando las funciones nativas contienen JavaScript incrustado que emite nuevas consultas. Atacantes autenticados pueden eludir el límite de recursión encadenando llamadas a funciones nativas y JavaScript para desencadenar recursión infinita y agotar la memoria del servidor.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-71393 changed 2026-10-29CVE Terms of Use
GitHub Advisory DatabaseGHSA-m7rc-8w7m-r9qr changed 2026-07-19CC-BY-4.0
NVDCVE-2025-71393 changed 2026-10-29Public domain