Advisory

GHSA-3633-g6mg-p6qq

Also known as: CVE-2025-71395

Summary

SurrealDB memory exhaustion via string::replace using regex

Details

An authenticated user can craft a query using the string::replace function that uses a Regex to perform a string replacement. As there is a failure to restrict the resulting string length, this enables an attacker to send a string::replace function to the SurrealDB server exhausting all the memory of the server due to string allocations. This eventually results in a Denial-of-Service situation for the SurrealDB server.

This issue was discovered and patched during an code audit and penetration test of SurrealDB by cure53. Using CVSSv4 definitions, the severity is High.

Impact
An authenticated user can crash the SurrealDB instance through memory exhaustion

Patches
A patch has been created that enforces a limit on string length SURREAL_GENERATION_ALLOCATION_LIMIT

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

Workarounds
Affected users who are unable to update may want to limit the ability of untrusted clients to run the string::replace function in the affected versions of SurrealDB using the --deny-functions flag described within Capabilities or the equivalent SURREAL_CAPS_DENY_FUNC environment variable.

References

SurrealQL Documentation - DB Functions (string::replace)
SurrealDB Documentation - Capabilities
SurrealDB Documentation - Environment Variables
#5619
#5638

Severity

High Basis: The source's own band: HIGH

Dates

Published
2025-04-11 14:08 UTC
Modified
2026-07-19 03:56 UTC

Affected packages and fixes

surrealdb

crates.io · All systems

Affected

  • introduced 2.2.0, fixed 2.2.2 (semver)

Fixed versions

2.2.2

Fix

  • Fixed version 2.2.2
    cargo update -p surrealdb --precise 2.2.2

surrealdb

crates.io · All systems

Affected

  • introduced 2.1.0, fixed 2.1.5 (semver)

Fixed versions

2.1.5

Fix

  • Fixed version 2.1.5
    cargo update -p surrealdb --precise 2.1.5

surrealdb

crates.io · All systems

Affected

  • introduced 0, fixed 2.0.5 (semver)

Fixed versions

2.0.5

Fix

  • Fixed version 2.0.5
    cargo update -p surrealdb --precise 2.0.5

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences