GHSA-CFF7-Q66J-4HC8
UNIQUE-Index Conflict Errors Disclose SELECT-Restricted Field Values and Record Ids 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-CFF7-Q66J-4HC8 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
When a write conflicts with a UNIQUE index, SurrealDB returns the error `Database index `<index>` already contains `<value>`, with record `<record>`` to the caller verbatim. The message embeds the stored hidden value and the record id of the existing row, and the write path never consults the acting principal's field-level SELECT permissions or the row's table PERMISSIONS before doing so. Any authenticated principal with write access to a table therefore obtains a reliable existence oracle over field values and rows its SELECT permissions forbid reading: a probe write either succeeds (value unused) or returns the hidden value and record id (value in use). 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
SurrealDB treats error text as permission-relevant: GHSA-6g9v-7gq3-p2c6 (fixed 3.1.0) stripped raw operands from arithmetic error messages for exactly this reason, and the September 2026 security wave hardened the indexed read paths (restricted-field indexes withheld from query planning in GHSA-x6mm-9295-rvph; indexed COUNT/ORDER BY fast paths guarded in GHSA-c8j9-96c9-8xrp and GHSA-h4h3-3rfj-x6fq). The unique-index write-conflict path was not covered.
- `surrealdb/core/src/err/mod.rs:541` (main `18971ffb`): `Error::IndexExists { record, index, value }` formats as `Database index `{index}` already contains `{value}`, with record `{record}``.
- Raised by `surrealdb/core/src/idx/index.rs::err_index_exists` (line 398, raise at line 205) during unique-index maintenance in the document write pipeline (`doc/create.rs`, `doc/insert.rs`, `doc/upsert.rs`).
- Nothing on this path consults the acting principal's `PERMISSIONS FOR select` on the field or the table before including the stored value and record id.
Both restriction models are bypassed:
- Field-level: `DEFINE FIELD email ON users PERMISSIONS FOR select NONE` — a principal with CREATE but no SELECT on `email` receives the stored `email` value verbatim in the conflict error.
- Row-level: `DEFINE TABLE secrets PERMISSIONS FOR select NONE` — a principal with INSERT permission on the table receives the fully invisible record's unique field value and its record id.
The uniqueness enforcement itself is correct (the write is rejected); the flaw is the content of the failure observable, which turns a rejected write into a read oracle.
Proof of concept
Environment: official `surrealdb/surrealdb:latest` image (v3.3.0) on 127.0.0.1:16451, root user bootstraps the schema, a record user `alice` with CREATE/INSERT permission only. All data synthetic. The attached archive automates every step; the container is removed on exit.
Controls: the boundary is real and active — the unauthenticated caller is denied, root sees the protected value, and alice's SELECT reveals nothing:
[PASS] C1 unauthenticated SELECT denied
[PASS] C2 privileged SELECT sees field (schema active)
[PASS] C3 alice SELECT does not reveal protected valuesPayload A (field-level restriction): `email` carries a UNIQUE index and `PERMISSIONS FOR select NONE`. alice probes with a candidate value:
CREATE users SET email = 'victim@example.com';
→ Database index 'users_email_uniq' already contains 'victim@example.com', with record 'users:victim'
[PASS] A1 conflict error echoes probed value + record id (field-restricted)
[PASS] A2 non-conflicting probe succeeds (differential confirmed)The rejected write returns the stored hidden value (`victim@example.com`) and the record id (`users:victim`). A probe with an unused value succeeds, completing the existence oracle.
Payload B (row-level restriction): a fully invisible record `secrets:s1` (table `PERMISSIONS FOR select NONE`) with a UNIQUE field leaks its existence, value echo, and record id the same way:
[PASS] B1 invisible record leaks existence + record id (row-restricted)Automated run from the attached archive (`surrealdb-unique-index-info-leak-PoC.zip`), executed from an extracted copy in a clean state (fresh container each run):
$ poc/poc.sh
[*] starting fresh surrealdb/surrealdb:latest on 127.0.0.1:16451
[+] endpoint ready: http://127.0.0.1:16451
[+] record user alice signed up
[+] PASS: C1 unauthenticated SELECT denied
[+] PASS: C2 privileged SELECT sees field (schema active)
[+] PASS: C3 alice SELECT does not reveal protected values
[+] PASS: A1 conflict error echoes probed value + record id (field-restricted)
[+] PASS: A2 non-conflicting probe succeeds (differential confirmed)
[+] PASS: B1 invisible record leaks existence + record id (row-restricted)
==== result: 6 passed, 0 failed ====
[*] removed container surreal-vt-pocImpact
An authenticated principal with only write permissions on a table can enumerate hidden data through the unique-index conflict error: user, email, token or key existence can be probed value-by-value (user enumeration against hidden registration data), low-entropy hidden values can be recovered by dictionary probing, and record ids of invisible rows are disclosed. This crosses both the field-level SELECT permission boundary and the row-level PERMISSIONS boundary on the current patched release, in a codebase that already treats error-message content as permission-relevant (GHSA-6g9v-7gq3-p2c6). No integrity or availability impact (the conflicting write is correctly rejected).
Patches
A patch has been created that withholds the conflicting record's id and its indexed value from a UNIQUE-index conflict error when the caller is not permitted to read them.
- Version 4.0.0 and later are not affected by this issue.
References
- SurrealQL Documentation — DEFINE INDEX
https://surrealdb.com/docs/surrealql/statements/define/indexes - `fix(idx): UNIQUE-index conflict errors disclose SELECT-restricted values and record ids` (commit `f7acedefc3`)
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-cff7-q66j-4hc8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
