GHSA-3RCM-C653-WGMR
Re-RELATE on an Existing Edge Echoes Stored in/out Endpoints Despite SELECT Restrictions in SurrealDB
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-3RCM-C653-WGMR divulgada · CVSS 4.3 (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 |
Summary
`RELATE a->edge:existing->b` against an already-stored edge runs the update path and compares the supplied endpoints with the stored ones. On mismatch, the `InOverride`/`OutOverride` error embeds the stored endpoint record id — taken from `self.initial.doc.pick(&IN/OUT)` — although the message wording ("which does not match the existing field value") implies the caller-supplied value is echoed. Each mismatched RELATE therefore returns one true endpoint of a hidden edge directly, with no brute force: one query for `in`, one (with a matching `in`) for `out`. Graph structure the caller's SELECT permissions deny is disclosed verbatim, for both row-level (`PERMISSIONS FOR select NONE` on the edge table) and field-level (`DEFINE FIELD in/out ... PERMISSIONS FOR select NONE`) restrictions. Verified on the official v3.3.0 Docker image (2026-09-24, current release) and by source review on main `18971ffb` (2026-09-04).
Details
The edge-endpoint override check runs in `surrealdb/core/src/doc/alter.rs::default_record_data` (`InOverride`/`OutOverride` arms at v3.3.0 lines 279/296, errors at `doc/error.rs:50-59`; `alter.rs:244` and `err/mod.rs:629` on HEAD), reached from `doc/relate.rs::relate_update`:
match (self.initial.doc.as_ref().pick(&IN), self.is_new()) {
(Value::RecordId(id), false) if id == *l => { /* unchanged */ }
(_, true) => { /* new edge: supplied value stored */ }
(v, _) => bail!(DocError::InOverride { value: v.to_sql() }) // v = STORED endpoint
}`v` binds from the initial (stored) document and is formatted into the client-visible error without any permission check on `in`/`out` of the stored edge, although the read path demonstrably filters these fields for the same principal (`SELECT in, out FROM <edge>` returns nothing). The newer `RecordExists` guard (the GHSA-f82j-v89j-mf86 fix) does not preempt this path; the caller needs UPDATE permission on the edge, which is exactly what makes the boundary crossing specific — write yes, read no. The message semantics are also inverted relative to the code (it names the stored value), making the error misleading even in normal operation.
Proof of concept
Environment: official `surrealdb/surrealdb:latest` image (v3.3.0) on 127.0.0.1:16451, root bootstraps the schema, record user `alice` created by the PoC. All data synthetic. The attached archive automates every step and removes its container on exit.
Schema: edge table `wrote` with `PERMISSIONS FOR select NONE, FOR create FULL, FOR update FULL`, pre-seeded with `person:carol->wrote:edge77->book:diary`; a second table `wrote2` with full table permissions but `DEFINE FIELD in/out ... PERMISSIONS FOR select NONE`, seeded with `person:carol->wrote2:edge88->book:diary`.
Controls: the boundary is real and active — root sees both endpoints, alice's SELECT reveals none, and alice may create fresh edges and re-RELATE with matching endpoints:
[PASS] C1 privileged caller reads endpoints (fixture valid)
[PASS] C2 alice SELECT reveals no endpoints (boundary holds on SELECT)
[PASS] C3 alice RELATE to fresh edge id succeeds (create allowed)
[PASS] C4 matching-endpoint RELATE succeeds (update allowed)Payloads: alice re-RELATEs `edge77` with one mismatched endpoint at a time:
[PASS] T1 row-hidden edge: error echoes stored 'in' = person:carol
[PASS] T2 row-hidden edge: error echoes stored 'out' = book:diary
[PASS] T3 field-hidden edge: error echoes stored 'in' = person:carolEach mismatched RELATE returns `Found person:carol for the 'in' field, ...` / `Found book:diary for the 'out' field, ...` — the stored endpoints of an edge whose SELECT returns nothing to alice.
Automated run from the attached archive (`surrealdb-relate-endpoint-echo-PoC.zip`), executed from an extracted copy in a clean state (fresh container each run):
$ poc/poc.sh
[+] PASS: C1 privileged caller reads endpoints (fixture valid)
[+] PASS: C2 alice SELECT reveals no endpoints (boundary holds on SELECT)
[+] PASS: C3 alice RELATE to fresh edge id succeeds (create allowed)
[+] PASS: C4 matching-endpoint RELATE succeeds (update allowed)
[+] PASS: T1 row-hidden edge: error echoes stored 'in' = person:carol
[+] PASS: T2 row-hidden edge: error echoes stored 'out' = book:diary
[+] PASS: T3 field-hidden edge: error echoes stored 'in' = person:carol
==== result: 7 passed, 0 failed ====Impact
An authenticated principal with CREATE and UPDATE permission on an edge table (an app principal allowed to link entities) can recover the hidden graph structure — who is related to what — in at most two mismatched RELATE queries per edge record id, despite SELECT restrictions at either the row or field level. Record ids are commonly structured and guessable (`wrote:<a>:<b>`). This crosses SELECT permission boundaries on the current patched release. No integrity or availability impact (mismatched RELATEs are correctly rejected; matching ones succeed under the caller's existing write permission).
Patches
A patch has been created that refuses a re-RELATE onto an existing edge whatever endpoints it names when the caller cannot read the stored edge, so the override error no longer discloses a SELECT-hidden in/out endpoint.
- Version 4.0.0 and later are not affected by this issue.
References
- SurrealQL Documentation — RELATE
https://surrealdb.com/docs/surrealql/statements/relate - `fix(refs): re-RELATE override errors disclose SELECT-hidden edge endpoints` (commit `f98750b1c0`)
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iosurrealdb |
Corregida | 4.0.0 | 0 d | 4.0.1 no afectada |
4.0.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/surrealdb/surrealdb/security/advisories/GHSA-3rcm-c653-wgmrLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
