---
id: CVE-2025-71397
title: >-
  SurrealDB before 2.0.5, 2.1.x before 2.1.5, and 2.2.x before 2.2.2 allows
  authenticated users with OWNER or EDITOR permissions (at the root, namespace,
  or database level) to define custom database functions via DEFINE FUNCTION
  using nest…
summary: >-
  SurrealDB before 2.0.5, 2.1.x before 2.1.5, and 2.2.x before 2.2.2 allows
  authenticated users with OWNER or EDITOR permissions (at the root, namespace,
  or database level) to define custom database functions via DEFINE FUNCTION
  using nest…
severity: none
cwe:
  - CWE-835
published: '2026-07-18'
updated: '2026-07-18'
source: NVD
sourceUrl: 'https://nvd.nist.gov/vuln/detail/CVE-2025-71397'
references:
  - url: >-
      https://github.com/surrealdb/surrealdb/security/advisories/GHSA-pxw4-94j3-v9pf
    label: disclosure@vulncheck.com
  - url: >-
      https://www.vulncheck.com/advisories/surrealdb-before-cpu-exhaustion-via-nested-for-loops
    label: disclosure@vulncheck.com
tags:
  - nvd
ingestedAt: '2026-07-19T05:29:21.300Z'
epss: 0.00551
epssPercentile: 0.43686
---

## Overview

SurrealDB before 2.0.5, 2.1.x before 2.1.5, and 2.2.x before 2.2.2 allows authenticated users with OWNER or EDITOR permissions (at the root, namespace, or database level) to define custom database functions via DEFINE FUNCTION using nested FOR loops. Although a single loop's iteration count is constrained, nesting multiple loops (e.g., each with 1,000,000 iterations) is not, so an attacker can execute a function that consumes all server CPU time. Configured timeouts do not stop the execution, rendering the server unresponsive to other queries and connections until it is manually restarted.

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.
