GHSA-M887-2246-MGW3
VIEWER role can define tables implicitly via CREATE on a non-STRICT database
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-M887-2246-MGW3 divulgada | |
| 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 |
Version: `surreal version`: 3.2.0 for linux on x86_64. Seen first on a RocksDB-backed server, reproduced on an in-memory one.
Summary: a user with the `VIEWER` role can change a database's schema. `CREATE` on a table that does not exist yet, in a database that is not `STRICT`, returns `OK` and leaves a new table defined as `TYPE ANY SCHEMALESS PERMISSIONS NONE` (0 rows). An explicit `DEFINE TABLE` by the same user is correctly refused ("IAM error: Not enough permissions to perform this action"), so the implicit definition bypasses the check that the explicit one applies.
Reproduce (fresh server: `surreal start --user root --pass root memory`):
As root:
DEFINE NAMESPACE n; USE NS n; DEFINE DATABASE loose; DEFINE DATABASE strict STRICT;
DEFINE USER v ON ROOT PASSWORD 'v' ROLES VIEWER;
USE NS n DB loose; DEFINE TABLE t SCHEMALESS; CREATE t:1 SET a = 1;As `v` (ns `n`, db `loose`):
CREATE probe_new:x SET a = 1; -- OK, returns []
DEFINE TABLE probe_defined; -- ERR: IAM error: Not enough permissions
UPDATE t:1 SET a = 2; -- OK, returns [], row unchanged (expected)As root: `INFO FOR DB;` now lists `probe_new` (`DEFINE TABLE probe_new TYPE ANY SCHEMALESS PERMISSIONS NONE`), 0 rows.
In db `strict` the same `CREATE` by `v` returns "The table 'probe_new' does not exist" (expected).
Impact: a read-only credential (e.g. one given to a backup or reporting job) can add arbitrary empty tables to any non-STRICT database it can reach. No data is read or changed beyond that, but it is a schema write by a role documented as read-only, and it can clutter or collide with table names an application later defines.
Expected: a `VIEWER` statement that would implicitly define a table is refused the same way an explicit `DEFINE TABLE` is.
Workaround we plan: set every database reachable by VIEWER users to STRICT.
Patches
A patch has been created that requires DEFINE TABLE authority before a table is defined on demand, so a VIEWER can no longer implicitly create a table via CREATE on a nonexistent table.
- Version 4.0.0 and later are not affected by this issue.
References
- SurrealQL Documentation — DEFINE TABLE
https://surrealdb.com/docs/surrealql/statements/define/table - `fix(exec): require DEFINE TABLE authority to define a table on demand` (commit `2598b3b0ad`)
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-m887-2246-mgw3Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
