GHSA-R867-GHGV-MRP9
pREST executes DELETE and PUT against whole tables when the query string is empty - a single request with a valid token and no WHERE condition wipes or rewrites every row
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-R867-GHGV-MRP9 divulgada · CVSS 8.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
All evidence, reproduction steps, and scripts in the report were verified against a real running instance. Nothing is fabricated or synthetic; every verdict is backed by captured output from an actual deployment.
pREST (Go middleware that exposes a PostgreSQL database as a REST API) translates request query parameters into SQL WHERE clauses. Its DELETE and PUT controllers append the WHERE clause only when one is present (`src/controllers/crud.go`, Delete: `sql := DeleteSQL(...); if where != "" {...}`; Update is the same shape) - a request with no query parameters executes a bare `DELETE FROM "db"."schema"."table"` or an unscoped `UPDATE` against the entire table. There is no row-count limit, no requirement for a condition, and no confirmation parameter. Verified on a live v2.4.2 instance with authentication enabled: `DELETE /{db}/{schema}/t2` with no query string returned `{"rows_affected":3}` (HTTP 200) and a direct SQL check confirmed the table was empty - three rows destroyed by one request; the same request with `?id=1` correctly targets one row. In the default `access.restrict=false` mode `TablePermissions` returns true for every table and `FieldsPermissions` skips field filtering for delete operations entirely, so any token that can write one table can wipe it. The request needs only a valid write-capable token (or no token at all in the default unauthenticated mode), which makes this reachable not just by attackers but by ordinary client bugs: one proxy that strips a query string, one template that drops its filters, and the table is gone.
Details
The unscoped-write control flow:
# src/controllers/crud.go - Delete
# sql := DeleteSQL(...)
# if where != "" { // WHERE appended only when the query string yields one
# sql = fmt.Sprintf("%s WHERE %s", sql, where)
# }
# src/controllers/crud.go - Update: same `if where != ""` shape for SET/WHERE
# src/adapters/postgres/postgres.go - TablePermissions
# access.restrict=false (default) -> returns true for any table
# FieldsPermissions: delete operations skip field filtering entirelyThis is distinct from the known SQLi class (CVE-2025-58450, path-parameter injection, no fixed release): no injection is involved here. The SQL is fully parameterized and the identifiers pass `validatePathSegments`/`ident.IsSafeSegment` (we verified the injection class is mitigated on v2.4.2) - the database faithfully executes exactly the destructive statement the empty query string implies. The authentication-enabled deployment does not change the outcome: any valid token with write permission on the table triggers the same unscoped execution.
Proof of concept
The instance is pREST v2.4.2 (source-built, Go) in front of PostgreSQL 16, `PREST_AUTH_ENABLED=true`, table `pr6cr4_api.t2` holding 3 rows, caller holds a valid JWT:
#!/usr/bin/env bash
BASE=http://127.0.0.1:21990
# step 1: unscoped DELETE - no query parameters at all
curl -s -X DELETE -H "Authorization: Bearer $TOKEN" "$BASE/pr6cr4db/pr6cr4_api/t2"
# step 2: confirm server-side that the table is empty
psql -h 127.0.0.1 -U postgres -c "SELECT count(*) FROM pr6cr4_api.t2"
# step 3 (control): the same endpoint with a condition targets one row
# (re-seed the table with a few rows first - step 1 wiped it)
curl -s -X DELETE -H "Authorization: Bearer $TOKEN" "$BASE/pr6cr4db/pr6cr4_api/t2?id=1"Captured output from the running instance (verbatim from the retained probe log):
## F2: unscoped DELETE (JWT valid, no WHERE)
$ curl -X DELETE -H "Authorization: Bearer \$TOK" /pr6cr4db/pr6cr4_api/t2
{"rows_affected":3} [200] # psql: SELECT count(*) FROM t2 -> 0 (table wiped, no condition)Output interpretation: the API executed `DELETE FROM "pr6cr4db"."pr6cr4_api"."t2"` with no WHERE clause and reported the destroyed row count as a normal success response. The `?id=1` control confirms the parameterized path works when a condition is present, isolating the defect to the missing unscoped-write guard rather than the SQL layer. Table and token names are instance-specific; the stable verdict is the unscoped DELETE/PUT execution on empty query strings.
Impact
Unauthenticated (default mode) or single-token (authentication enabled) destruction or wholesale rewrite of any permitted table (CWE-284): one request without a query string erases every row, with no limit, no confirmation, and no audit friction beyond pREST's own logs - reachable by an attacker with any leaked or low-privilege write token, and equally by routine client defects such as a proxy stripping the query string. In the default `access.restrict=false` mode the blast radius is every table in every exposed schema. A fix is to reject DELETE/PUT without a WHERE condition (HTTP 400) or require an explicit opt-in parameter, and to enforce a row-count ceiling on unscoped writes.
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 |
2.5.3Arsenal 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-r867-ghgv-mrp9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
