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

GHSA-P3C2-WH5F-JWQM

GraphQL WebSocket upgrade omits frame and message size limits enabling memory amplification

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

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/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, automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Ojo con los rangos de versión, son traicioneros.Nivel de sospecha: ceja levantada.
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-P3C2-WH5F-JWQM divulgada · CVSS 7.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

The SurrealDB server's GraphQL WebSocket endpoint at `GET /graphql` upgrades incoming connections without applying any of the operator-configurable frame, message, or buffer size limits (`SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE`, `SURREAL_WEBSOCKET_READ_BUFFER_SIZE`, `SURREAL_WEBSOCKET_WRITE_BUFFER_SIZE`, `SURREAL_WEBSOCKET_MAX_WRITE_BUFFER_SIZE`) that are applied to the `/rpc` and `/sql` upgrade handlers. As a result the endpoint inherits the underlying tungstenite library's permissive defaults (16 MiB per frame, 64 MiB per message, unbounded write buffer) regardless of what the operator configured. For any deployment that has `DEFINE CONFIG GRAPHQL` set on at least one database, an unauthenticated network client that supplies the target namespace and database in request headers can hold up to 64 MiB of in-flight bytes per concurrent connection, exhausting server memory and degrading availability for every endpoint served by the same process.

Root Cause

The server exposes three WebSocket upgrade handlers under different HTTP routes. The handlers for `/rpc` and `/sql` explicitly propagate the shared `WEBSOCKET_*` capacity constants onto the axum `WebSocketUpgrade`, so the underlying tungstenite `WebSocketConfig` observes the operator's configured limits before any bytes are accepted from the socket. The GraphQL WebSocket handler does not perform any of those calls, so tungstenite falls back to its library defaults (max frame size 16 MiB, max message size 64 MiB, max write buffer `usize::MAX`) even when the operator has explicitly lowered `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE`. The security invariant that "operator-configured per-connection frame and buffer limits apply to every WebSocket endpoint the server exposes" is violated because the GraphQL upgrade builder never binds any of those constants.

The affected upgrade path is the `GET` handler registered in `server/src/ntw/graphql.rs`:

// server/src/ntw/graphql.rs:23-72 (relevant excerpt)
pub fn router() -> Router<Arc<RpcState>> {
    Router::new().route("/graphql", get(ws_handler).post_service(GraphQLService::new()))
}

async fn ws_handler(
    ws: WebSocketUpgrade,
    ...
) -> impl IntoResponse {
    // ... capability + session checks ...
    ws.protocols(ALL_WEBSOCKET_PROTOCOLS).on_upgrade(move |socket| async move {
        serve_graphql_ws(socket, schema, protocol, data).await;
    })
}

For contrast, the sibling handler at `server/src/ntw/sql.rs:105-115` binds all five limits before `on_upgrade`:

ws
    .max_frame_size(*WEBSOCKET_MAX_MESSAGE_SIZE)
    .max_message_size(*WEBSOCKET_MAX_MESSAGE_SIZE)
    .read_buffer_size(*WEBSOCKET_READ_BUFFER_SIZE)
    .write_buffer_size(*WEBSOCKET_WRITE_BUFFER_SIZE)
    .max_write_buffer_size(*WEBSOCKET_MAX_WRITE_BUFFER_SIZE)
    .on_failed_upgrade(...)
    .on_upgrade(move |socket| handle_socket(state, socket, sess))

The equivalent binding block is present at `server/src/ntw/rpc.rs:110-122` and absent from `server/src/ntw/graphql.rs`. The `cnf::WEBSOCKET_*` constants (and any operator override sourced from `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE`) are never referenced from the GraphQL upgrade file.

Impact

Any deployment that ships the default `graphql` feature and has configured at least one database with `DEFINE CONFIG GRAPHQL` is exposed. No credentials are required to reach the vulnerable upgrade: the server's auth middleware silently produces an anonymous session when neither `Authorization: Basic` nor `Authorization: Bearer` is presented, and the GraphQL schema generation path opens a raw read transaction without invoking `check_anon` or any related capability check. The attacker only needs the namespace and database names, which are typically application configuration rather than secrets.

Once upgraded, each connection can pin up to 64 MiB of in-flight bytes in the tungstenite per-message reassembly buffer, plus additional memory in the unbounded write buffer if the server produces responses. Because the write buffer bound is `usize::MAX` and no read-side limit is enforced, an attacker who maintains bandwidth across many concurrent connections drives the whole server process toward memory exhaustion. The demonstrated capability is availability degradation for every endpoint served by the same process (the `/rpc`, `/sql`, `/graphql`, HTTP query, and health routes all share the process address space). On memory-constrained deployments the process may be OOM-killed and restarted during the attack. Plausibly the operator's monitoring will see repeated restarts and per-endpoint latency spikes; no confidentiality or integrity impact is claimed.

Operator mitigation of the previously published advisory GHSA-65rj-r9fh-jp2v by lowering `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE` does not protect the GraphQL WebSocket endpoint, because that variable is never plumbed into this upgrade. Operators who believed they had bounded all WebSocket exposure by setting that variable retain a false sense of coverage until the endpoint is explicitly denied via `--deny-http graphql` or blocked at a reverse proxy.

Proof of Concept

Prerequisites and setup:

- A running SurrealDB server built with the default `graphql` feature (in the current
  release channel, this is the standard `surrealdb-server` build).
- At least one namespace and database, with GraphQL enabled on that database:
    DEFINE NAMESPACE test;
    DEFINE DATABASE test;
    USE NS test DB test;
    DEFINE CONFIG GRAPHQL AUTO;
- Optional negative control: start the server with a lowered per-connection limit,
  for example `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE=1048576` (1 MiB). This value is
  enforced on `/rpc` and `/sql` but is not applied to `/graphql`.

Reproduction steps:

  1. Start the server with the lowered environment variable and the GraphQL-enabled namespace/database.
  2. From an unauthenticated client, open a WebSocket to `/rpc` and send a text frame larger than the configured 1 MiB limit. The connection is closed with a WebSocket protocol error because `/rpc` enforces the configured limit.
  3. Open a WebSocket to `/graphql` supplying the `surreal-ns: test` and `surreal-db: test` headers and `Sec-WebSocket-Protocol: graphql-transport-ws`. Send a frame between 1 MiB and 64 MiB.
  4. Compare behavior: the GraphQL connection accepts the oversized frame (the server allocates memory up to the tungstenite defaults) while the `/rpc` connection did not.

Minimal client (Python, `websockets` >= 12):

import asyncio
import websockets

TARGET_HOST = "127.0.0.1:8000"
NS, DB = "test", "test"
FRAME_MB = 8  # any value below 64; 8 MiB comfortably clears the 1 MiB /rpc limit

async def send_oversized(path: str, subprotocol: str) -> None:
    uri = f"ws://{TARGET_HOST}{path}"
    payload = b"a" * (FRAME_MB * 1024 * 1024)
    async with websockets.connect(
        uri,
        subprotocols=[subprotocol],
        additional_headers={"surreal-ns": NS, "surreal-db": DB},
        max_size=None,
    ) as ws:
        try:
            await ws.send(payload)
            print(f"{path}: accepted {FRAME_MB} MiB frame")
        except websockets.ConnectionClosedError as exc:
            print(f"{path}: rejected ({exc.code} {exc.reason})")

async def main() -> None:
    await send_oversized("/rpc",     "json")
    await send_oversized("/graphql", "graphql-transport-ws")

asyncio.run(main())

Expected behavior when the server is started with `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE=1048576`:

/rpc: rejected (1009 Message Too Big)
/graphql: accepted 8 MiB frame

This differential outcome is predicted directly from the source-level evidence: `/rpc` reflects the operator-configured 1 MiB limit; `/graphql` accepts any frame up to the tungstenite default of 64 MiB per message and 16 MiB per frame, independent of the operator's configuration. Runtime execution of this reproduction is not required to establish the primitive; the definitive evidence is the absence of the five configuration calls on the `/graphql` upgrade builder (see Bypass Evidence).

Attack Chain

  1. Exposure: The `surrealdb-server` default build enables the `graphql` feature (declared as a default feature in `server/Cargo.toml`), which mounts the GraphQL router at `GET /graphql` (`server/src/ntw/graphql.rs:23-25`). An unauthenticated network client with reachability to the server can request this route.
  2. Control: The attacker controls the request headers (`surreal-ns`, `surreal-db`, `Sec-WebSocket-Protocol`) and, after upgrade, every subsequent WebSocket frame's opcode, size, and payload. Frame size and the total number of concurrent connections are attacker-chosen.
  3. Path: `SurrealAuthLayer::check_auth` accepts the request without an `Authorization` header and returns an anonymous `Session`. The handler `ws_handler` validates the capability `RouteTarget::GraphQL` (default `allow_http: Targets::All`), verifies that `session.ns` and `session.db` are set, and calls `datastore.graphql_schema(&session)` which reaches `GraphQLSchemaCache::get_schema` and then `generate_schema`. Both open raw read transactions and never invoke `check_anon`, `check_auth`, or any capability-based authorization check, so schema generation succeeds for anonymous sessions on any database with `DEFINE CONFIG GRAPHQL` present. Control returns to `ws_handler:69`, which invokes `WebSocketUpgrade::on_upgrade` without configuring frame or buffer capacity.
  4. Guard: The invariant "operator-configured per-connection frame and buffer limits apply to every WebSocket endpoint" is not enforced here. The corresponding `/rpc` and `/sql` handlers bind five limit constants before `on_upgrade`; the GraphQL upgrade omits all five. There is no additional application-layer size cap in `serve_graphql_ws`, and `async_graphql`'s WebSocket driver does not impose an independent per-frame or per-message ceiling.
  5. Primitive: The upgrade completes with tungstenite defaults: 16 MiB per frame, 64 MiB per reassembled message, and `usize::MAX` for `max_write_buffer_size`. Every accepted frame is buffered in server memory before being handed to the application layer.
  6. Result: An attacker sustaining bandwidth across concurrent connections holds an amount of memory equal to the sum of in-flight buffers across all sockets, unbounded by any operator configuration and limited only by the tungstenite defaults and TCP transport. The demonstrated capability is process-wide memory pressure that degrades availability for every endpoint served by the same server process, up to and including OOM-kill on memory-constrained deployments.

Bypass Evidence

The previously published advisory GHSA-65rj-r9fh-jp2v (patched in `surrealdb-server` 3.1.0) addressed the same class of issue on the `/sql` upgrade path by adding the five WebSocket capacity configuration calls to `server/src/ntw/sql.rs` and by placing capability checks before `on_upgrade`. The GraphQL upgrade handler at `server/src/ntw/graphql.rs` was not modified by that fix, so the operator-facing invariant "the configured maximum WebSocket message size applies to every WebSocket endpoint" continued to be violated on this endpoint after that advisory was patched.

Comparative source evidence at the reviewed source revision `18971ffba781a796c0ad3897bb4b82432c241e4c` and against the crates.io `surrealdb-server` 3.3.0 tarball:

server/src/ntw/rpc.rs:110-122
    ws.protocols(PROTOCOLS)
      .max_frame_size(*cnf::WEBSOCKET_MAX_MESSAGE_SIZE)
      .max_message_size(*cnf::WEBSOCKET_MAX_MESSAGE_SIZE)
      .read_buffer_size(*cnf::WEBSOCKET_READ_BUFFER_SIZE)
      .write_buffer_size(*cnf::WEBSOCKET_WRITE_BUFFER_SIZE)
      .max_write_buffer_size(*cnf::WEBSOCKET_MAX_WRITE_BUFFER_SIZE)
      .on_failed_upgrade(...)
      .on_upgrade(...);            // 5 limit calls present

server/src/ntw/sql.rs:105-115
    ws.max_frame_size(*WEBSOCKET_MAX_MESSAGE_SIZE)
      .max_message_size(*WEBSOCKET_MAX_MESSAGE_SIZE)
      .read_buffer_size(*WEBSOCKET_READ_BUFFER_SIZE)
      .write_buffer_size(*WEBSOCKET_WRITE_BUFFER_SIZE)
      .max_write_buffer_size(*WEBSOCKET_MAX_WRITE_BUFFER_SIZE)
      .on_failed_upgrade(...)
      .on_upgrade(...);            // 5 limit calls present

server/src/ntw/graphql.rs:69
    ws.protocols(ALL_WEBSOCKET_PROTOCOLS)
      .on_upgrade(...);            // 0 limit calls

A text search for the constant identifier `WEBSOCKET_` inside `server/src/ntw/graphql.rs` returns no matches, and the file does not import `cnf::WEBSOCKET_MAX_MESSAGE_SIZE` or any related symbol. Diffing the crates.io `surrealdb-server` 3.3.0 archive against the reviewed source shows only an unrelated module path rename around `RouteTarget`; the missing configuration is identical in both.

Attempts made to invalidate the finding:

  • Inspected `axum::extract::WebSocketUpgrade` to check whether axum imposes an independent size cap when `max_message_size` is not set. It does not; axum forwards the tungstenite `WebSocketConfig` as configured, and an unconfigured builder uses tungstenite's defaults verbatim.
  • Inspected `async_graphql`'s WebSocket driver (`async_graphql::http::WebSocket`) to check whether the GraphQL library caps message size before allocation. It consumes already-decoded `Message` values; it does not participate in frame or message reassembly and therefore cannot bound tungstenite's allocation.
  • Inspected `serve_graphql_ws` (`server/src/ntw/graphql.rs:87-123`) for any application-layer size gate. The stream pipeline uses `take_while(|res| res.is_ok())`, `filter_map` on `Text` / `Binary` variants, and `map(Message::into_data)`, none of which observe or limit payload size.
  • Inspected `SurrealAuthLayer::check_auth` (`server/src/ntw/auth.rs`) to confirm that anonymous requests are not rejected before reaching the GraphQL handler. `Authorization: Basic` and `Authorization: Bearer` are extracted with `if let Ok(...)` and silently skipped when absent; the function returns `Ok(session)` with an anonymous `Session` in that case.
  • Considered whether "GraphQL must be configured" is a hard reachability gate that removes the finding. It narrows the population of deployments but does not add per-request complexity for a target deployment, and the previously published advisory GHSA-65rj-r9fh-jp2v adopted a similar deployment-precondition posture without downgrading the class.

No attempt disproved the finding. The endpoint is reachable, the limit is missing, and the operator-configured mitigation for GHSA-65rj-r9fh-jp2v does not apply here.

Affected Versions

  • Ecosystem: `crates.io` (Rust)
  • Package: `surrealdb-server`
  • Confirmed affected range: `<= 3.3.0`
  • Latest release checked: `surrealdb-server` 3.3.0 on `crates.io`, published 2026-09-24
  • Fix status: not fixed. The current published stable release ships the vulnerable code, and no upstream fix for the `/graphql` upgrade path has been landed at the reviewed source revision `18971ffba781a796c0ad3897bb4b82432c241e4c` (workspace declared version `3.3.0-nightly`).

The `surrealdb-server` 3.3.0 archive fetched from `crates.io/api/v1/crates/surrealdb-server/3.3.0/download` contains `src/ntw/graphql.rs` with the same missing configuration at the `on_upgrade` call site as the reviewed source. Earlier `3.x` releases inherit the same code path and are also vulnerable; the previously published advisory GHSA-65rj-r9fh-jp2v (fixed in 3.1.0) added the missing configuration only to `/rpc` and `/sql`, so releases `>= 3.1.0` remain affected on the GraphQL endpoint. The exact introduction version of the GraphQL WebSocket handler cannot be resolved from the shallow checkout used for this review; the upper bound of the confirmed affected range is taken from the current published stable release. The related SDK crate `surrealdb` (also at 3.3.0 on `crates.io`) is not the affected package; the vulnerable server code resides in the `surrealdb-server` workspace member.

Suggested Fix

Apply the same operator-configurable frame, message, and buffer limits to the `/graphql` upgrade that already protect `/rpc` and `/sql`, so that the invariant "every WebSocket endpoint honors `SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE` and its siblings" holds. Concretely, in `server/src/ntw/graphql.rs` bind all five capacity constants on the `WebSocketUpgrade` builder before calling `on_upgrade` (`max_frame_size`, `max_message_size`, `read_buffer_size`, `write_buffer_size`, `max_write_buffer_size`), sourcing values from `crate::cnf::WEBSOCKET_MAX_MESSAGE_SIZE`, `crate::cnf::WEBSOCKET_READ_BUFFER_SIZE`, `crate::cnf::WEBSOCKET_WRITE_BUFFER_SIZE`, and `crate::cnf::WEBSOCKET_MAX_WRITE_BUFFER_SIZE`, matching the pattern already present in `server/src/ntw/rpc.rs` and `server/src/ntw/sql.rs`. Also add the same `on_failed_upgrade` diagnostic used by the sibling handlers so that upgrade rejections are observable.

The remediation must additionally cover every alternate WebSocket upgrade path that shares the same code path expectation: any future WebSocket endpoint should either receive the same block or should be routed through a shared helper that applies the constants, so this class of regression cannot recur when a new WebSocket route is added. Consider extracting the five configuration calls into a shared `configure_ws_limits(ws)` helper in `server/src/ntw/mod.rs` (or an equivalent internal module) and requiring every upgrade site to use it.

Interim mitigations available without a code change:

  • Deny the route with `--deny-http graphql` (or the equivalent capability configuration) when the deployment does not require GraphQL over WebSocket.
  • At a reverse proxy in front of the SurrealDB server, refuse `GET /graphql` requests that carry `Upgrade: websocket`, or apply per-connection frame size and read buffer limits to that route.
  • Restrict network reachability of `/graphql` to trusted clients via ingress or firewall rules.

None of these workarounds substitute for the code fix, because they change the deployment topology rather than restoring parity with the operator-configured limits.

---

Reported by zx (GitHub: @manus-pi).

Patches

A patch has been created that applies frame and message size limits to the GraphQL WebSocket upgrade, bounding the memory an unauthenticated connection can consume.

  • Version 4.0.0 and later are not affected by this issue.
References
  • `fix(server): GraphQL WebSocket omits frame and message size limits` (commit `b80f46b313`)

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:N
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
10.0/ 10Muy alto
Vector 10.0 (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-p3c2-wh5f-jwqm

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