{"id":"CVE-2025-71395","aliases":["CVE-2025-71395","GHSA-3633-g6mg-p6qq"],"related":[],"kind":"vulnerability","state":"published","title":"SurrealDB before 2.2.2 Memory Exhaustion via string::replace","summary":"SurrealDB versions before 2.2.2 contain a memory exhaustion vulnerability in the string::replace function that fails to restrict resulting string length when using regex patterns. An authenticated attacker can craft a malicious query to exhaust server memory through unbounded string allocations, causing denial of service.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"SurrealDB versions before 2.2.2 contain a memory exhaustion vulnerability in the string::replace function that fails to restrict resulting string length when using regex patterns. An authenticated attacker can craft a malicious query to exhaust server memory through unbounded string allocations, causing denial of service.","source":"cvelist"},{"lang":"en","text":"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.\n\nThis issue was discovered and patched during an code audit and penetration test of SurrealDB by cure53. Using CVSSv4 definitions, the severity is High. \n\n### Impact\nAn authenticated user can crash the SurrealDB instance through memory exhaustion\n\n### Patches\nA patch has been created that enforces a limit on string length  `SURREAL_GENERATION_ALLOCATION_LIMIT`\n\n- Versions 2.0.5, 2.1.5, 2.2.2, and later are not affected by this issue\n\n### Workarounds\nAffected 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](https://surrealdb.com/docs/surrealdb/security/capabilities#functions) or the equivalent `SURREAL_CAPS_DENY_FUNC` environment variable.\n\n### References\n\n[SurrealQL Documentation - DB Functions (string::replace)](https://surrealdb.com/docs/surrealql/functions/database/string#stringreplace)\n[SurrealDB Documentation - Capabilities](https://surrealdb.com/docs/surrealdb/security/capabilities#functions)\n[SurrealDB Documentation - Environment Variables](https://surrealdb.com/docs/surrealdb/cli/env)\n[#5619 ](https://github.com/surrealdb/surrealdb/pull/5619)\n[#5638 ](https://github.com/surrealdb/surrealdb/pull/5638)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Las versiones de SurrealDB anteriores a la 2.2.2 contienen una vulnerabilidad de agotamiento de memoria en la función string::replace que no restringe la longitud de la cadena resultante al usar patrones de expresiones regulares. Un atacante autenticado puede crear una consulta maliciosa para agotar la memoria del servidor a través de asignaciones de cadenas ilimitadas, causando denegación de servicio.","source":"nvd"}],"published":"2025-04-11T14:08:03.000Z","modified":"2026-10-29T21:17:06.190Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-789"],"affected":[{"ranges":[{"type":"semver","introduced":"2.2.0","fixed":"2.2.2","status":"affected"},{"type":"semver","version":"2.2.2","status":"unaffected"}],"vendor":"surrealdb","product":"surrealdb","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"2.1.0","fixed":"2.1.5","status":"affected"},{"type":"semver","version":"2.1.5","status":"unaffected"}],"vendor":"surrealdb","product":"surrealdb","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","fixed":"2.0.5","status":"affected"},{"type":"semver","version":"2.0.5","status":"unaffected"}],"vendor":"surrealdb","product":"surrealdb","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"2.2.0","status":"affected","fixed":"2.2.2"}],"ecosystem":"crates.io","package":"surrealdb","purl":"pkg:cargo/surrealdb","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"2.1.0","status":"affected","fixed":"2.1.5"}],"ecosystem":"crates.io","package":"surrealdb","purl":"pkg:cargo/surrealdb","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.0.5"}],"ecosystem":"crates.io","package":"surrealdb","purl":"pkg:cargo/surrealdb","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.0.5"},{"status":"affected","introduced":"2.1.0","fixed":"2.1.5"},{"status":"affected","introduced":"2.2.0","fixed":"2.2.2"}],"vendor":"surrealdb","product":"surrealdb","cpe":"cpe:2.3:a:surrealdb:surrealdb:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/surrealdb/surrealdb/security/advisories/GHSA-3633-g6mg-p6qq","tags":["vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/surrealdb-before-memory-exhaustion-via-string-replace","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/surrealdb/surrealdb/pull/5619","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/surrealdb/surrealdb/pull/5638","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/surrealdb/surrealdb","tags":["package"],"sources":["ghsa"]}],"credits":["cure53"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-07-22T19:09:25.666Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-71395","url":"https://www.cve.org/CVERecord?id=CVE-2025-71395","licence":"CVE Terms of Use","modified":"2026-10-29T21:15:22.098Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3633-g6mg-p6qq","url":"https://github.com/advisories/GHSA-3633-g6mg-p6qq","licence":"CC-BY-4.0","modified":"2026-07-19T03:56:48.028Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-71395","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-71395","licence":"Public domain","modified":"2026-10-29T21:17:06.190Z"}],"updatedAt":"2026-11-25T22:59:12.404Z","epss":{"score":0.00335,"percentile":0.28762,"date":"2026-12-01T12:00:22.000Z"}}