An unauthenticated attacker can inject arbitrary SQL through the sort query parameter accepted by
Daptin's generic entity list endpoint (GET /api/<entity>), which every table in a Daptin instance
exposes. The parameter is concatenated into raw SQL identifiers with no validation that the
referenced column exists, unlike a sibling code path in the same file that received exactly this
validation as the fix for a previously published advisory
(GHSA-rw2c-8rfq-gwfv).
Impact ranges from unauthenticated denial of service (a single crafted request 500s the query) to
blind/error-based extraction of data from tables the requester has no permission to read.
PaginatedFindAllWithoutFilters in server/resource/resource_findallpaginated.go reads the sort
query parameter directly from the request with no validation:
// server/resource/resource_findallpaginated.go:300-302
var sortOrder []string
if len(req.QueryParams["sort"]) > 0 {
sortOrder = req.QueryParams["sort"]
Each entry is then concatenated with the table name and passed to goqu.I() (goqu's raw SQL
identifier constructor) in two separate places, with no check that the referenced column exists
on the table:
// server/resource/resource_findallpaginated.go:435-449 (SELECT column list)
for _, sort := range sortOrder {
...
if strings.Index(sort, "(") == -1 {
sort = prefix + sort
}
idQueryCols = append(idQueryCols, goqu.I(sort).As(strings.ReplaceAll(sort, ".", "_")))
}
// server/resource/resource_findallpaginated.go:916-943 (ORDER BY clause)
for _, so := range sortOrder {
...
orders = append(orders, goqu.I(ord).Asc())
}
goqu.I() renders its argument by wrapping it in the dialect's quote character (a backtick, in
this build's configured dialect) without escaping an embedded quote character of the same kind.
A backtick supplied in sort...
0.12.30Exploitability
AV:NAC:LPR:NUI:NScope
S:UImpact
C:HI:LA:H9.4/CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:HInjection
Input Validation