Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. surrealdb
  4. ›
  5. GHSA-pxw4-94j3-v9pf

GHSA-pxw4-94j3-v9pf: SurrealDB CPU exhaustion via custom functions result in total DoS

April 11, 2025

SurrealDB allows authenticated users with OWNER or EDITOR permissions at the root, database or namespace levels to define their own database functions using the DEFINE FUNCTION statement

A custom database function comprises a name together with a function body. In the function body, the user programs the functionality of the function in terms of SurrealQL. The language includes a FOR keyword, used to implement for-loops.

Whilst the parser and interpreter constrain the number of iterations for a single for-loop, nesting several for-loops with a large number of iterations is possible. Thus, an attacker could define a function that comprises several nested for-loops with an iteration count of 1.000.000 each.

Executing the function will consume all the CPU time of the server, timeouts configured will not break the CPU consumption, and the function execution monopolizes all CPU time of the SurrealDB server, effectively preventing the server from executing functions, queries, commands of other users, or allowing further connections being established to the server.

Terminating the stuck server requires manual intervention which forces a quit on the server process, as the server application is not responsive any longer.

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 high, matched by our CVSS v4 assessment.

References

  • github.com/advisories/GHSA-pxw4-94j3-v9pf
  • github.com/surrealdb/surrealdb
  • github.com/surrealdb/surrealdb/pull/5597
  • github.com/surrealdb/surrealdb/security/advisories/GHSA-pxw4-94j3-v9pf

Code Behaviors & Features

Detect and mitigate GHSA-pxw4-94j3-v9pf with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 2.0.5, all versions starting from 2.1.0 before 2.1.5, all versions starting from 2.2.0 before 2.2.2

Fixed versions

  • 2.2.2
  • 2.1.5
  • 2.0.5

Solution

Upgrade to versions 2.0.5, 2.1.5, 2.2.2 or above.

Weakness

  • CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')

Source file

cargo/surrealdb/GHSA-pxw4-94j3-v9pf.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:16 +0000.