GHSA-FF2Q-H4X7-CPJ4
ON DELETE REJECT Errors Disclose SELECT-Hidden Referencing Record Ids in SurrealDB
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-FF2Q-H4X7-CPJ4 divulgada | |
| Remediación | Parche 4.0.0 | surrealdb · 0 d desde divulgación | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
When SurrealDB rejects a delete because an `ON DELETE REJECT` reference exists, the error reads `Cannot delete `<record>` as it is referenced by `<foreign>` with an ON DELETE REJECT clause` — and `<foreign>` is taken straight from the reference index with no permission gate. A principal who may delete a record but cannot SELECT the rows referencing it learns that a hidden referencing row exists and obtains its exact record id, one candidate record per query. This crosses the row-level SELECT permission boundary of the referencing table (`PERMISSIONS FOR select WHERE public = true` demonstrated, `NONE` equally affected). 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 reference-integrity check in the delete pipeline, `surrealdb/core/src/doc/purge.rs::check_referenced` (v3.3.0 line 532), scans the reference-index range for the record being deleted and, on the `Reject` strategy, constructs the referencing record id directly from the index key (`key.foreign_table`, `key.foreign_key`) and bails with `DeleteRejectedByReference(rid.to_sql(), record.to_sql())` (error at `doc/error.rs:131` on v3.3.0; `purge.rs:359` and `err/mod.rs:1182` on HEAD). Nothing on this path consults the acting principal's SELECT permissions on the foreign record, although the same principal's SELECT on the referencing table is demonstrably filtered by the row-level predicate (the row is invisible via SELECT), and the error is surfaced as `kind: Internal` — not as a permission error — so callers cannot even distinguish an integrity signal from a denial.
The rejection itself is intended behavior (referential integrity works); the flaw is the content of the failure observable. SurrealDB's own advisory line treats hidden-data-in-error-text as a patchable vulnerability class (GHSA-6g9v-7gq3-p2c6, arithmetic operand echo). The reference/edge advisory family covers only integrity issues (GHSA-4w65-7h3j-p29h CASCADE permission bypass, GHSA-whwg-vh4f-pmmf / CVE-2026-49997 edge delete bypass); no advisory covers this disclosure.
Proof of concept
Environment: official `surrealdb/surrealdb:latest` image (v3.3.0) on 127.0.0.1:16451, root bootstraps the schema, a record user `alice` is created by the PoC. All data synthetic. The attached archive automates every step and removes its container on exit.
Schema: `asset` with `PERMISSIONS FULL`; `report` with `PERMISSIONS FOR select WHERE public = true, FOR create FULL, FOR update FULL, FOR delete NONE` and `DEFINE FIELD about TYPE record<asset> REFERENCE ON DELETE REJECT`; one hidden referencing row (`report:case_hidden`, `public = false`) pointing at `asset:doc_secret`, one public row, one unreferenced asset.
Controls: the boundary is real and active — the unauthenticated caller is denied, root sees both rows, alice's SELECT returns only the public row, and alice can delete an unreferenced asset:
[PASS] C0 unauthenticated SELECT denied
[PASS] C1 privileged caller sees hidden row (fixture valid)
[PASS] C2 alice SELECT shows only public row (boundary holds on SELECT)
[PASS] C3 alice DELETE of unreferenced record succeedsPayload: alice deletes the referenced `asset:doc_secret`:
[PASS] T1 reject error discloses SELECT-hidden record id 'report:case_hidden'
[PASS] T1b error surfaced as Internal (not a permission denial)
[PASS] T2 control: root's delete rejected by REJECT clause tooThe rejected delete returns `Cannot delete 'asset:doc_secret' as it is referenced by 'report:case_hidden' with an ON DELETE REJECT clause` — naming the exact record id that alice's SELECT cannot return. Repeatable per candidate asset, yielding a hidden-row existence and record-id oracle.
Automated run from the attached archive (`surrealdb-delete-reject-record-disclosure-PoC.zip`), executed from an extracted copy in a clean state (fresh container each run):
$ poc/poc.sh
[+] PASS: C0 unauthenticated SELECT denied
[+] PASS: C1 privileged caller sees hidden row (fixture valid)
[+] PASS: C2 alice SELECT shows only public row (boundary holds on SELECT)
[+] PASS: C3 alice DELETE of unreferenced record succeeds
[+] PASS: T1 reject error discloses SELECT-hidden record id 'report:case_hidden'
[+] PASS: T1b error surfaced as Internal (not a permission denial)
[+] PASS: T2 control: root's delete rejected by REJECT clause too
==== result: 7 passed, 0 failed ====Impact
An authenticated principal holding DELETE permission on a table (the ordinary "users may delete their own content" grant) can enumerate hidden referencing rows about records they can delete: hidden moderation, watchlist, or ownership rows are revealed one record id per query, together with a boolean existence oracle for the hidden rows themselves. This crosses the row-level SELECT permission boundary on the current patched release, in a codebase that already treats error-text content as permission-relevant. No integrity or availability impact (the delete is correctly rejected).
Patches
A patch has been created that withholds a referencing record's id from an `ON DELETE REJECT` error unless the caller is permitted to read it, so a referential-integrity failure no longer discloses a SELECT-hidden record id to a permission-checked caller.
- Version 4.0.0 and later are not affected by this issue.
References
- SurrealQL Documentation — DEFINE FIELD
https://surrealdb.com/docs/surrealql/statements/define/field - `fix(refs): ON DELETE REJECT errors disclose SELECT-hidden referencing record ids` (commit `d31793fdc5`)
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
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-ff2q-h4x7-cpj4Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
