Daptin: Unauthenticated SQL Injection via the `sort` query parameter on every entity list endpoint
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| daptindaptin | — | Not listed |
| Gogithub.com/daptin/daptin |
< 0.12.30→ 0.12.30 |
0.12.30 |
Original description The description as published by the source.
Summary
An unauthenticated attacker can inject arbitrary SQL through the sort query parameter accepted by
Daptin's generic entity list endpoint (GET /api/), 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.
Details
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
}
idQuery…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web github.com