GHSA-xgjr-7j9q-2h4r: listmonk: SQL Injection in `/api/subscribers/export` bypasses table access control, leaking admin password hashes and SMTP credentials
- Source:
- OSV.dev
- Published:
- Fetched:
- Updated:
- Affects:
- github.com/knadh/listmonk
https://osv.dev/vulnerability/GHSA-xgjr-7j9q-2h4r ↗
listmonk: SQL Injection in `/api/subscribers/export` bypasses table access control, leaking admin password hashes and SMTP credentials ### Summary A SQL injection vulnerability in `GET /api/subscribers/export` allows an authenticated user with the `subscribers:sql_query` permission to bypass the table access control that exists on the regular query endpoint (`GET /api/subscribers`) and read arbitrary tables from the database — including `users` (bcrypt password hashes) and `settings` (SMTP credentials, API keys). Both error-based and time-based exfiltration techniques are confirmed to work. This creates a privilege escalation path: `subscribers:sql_query` → hash exfiltration → offline bcrypt crack (cost factor 6) → Super Admin account takeover. --- ### Details The subscriber query feature accepts a user-controlled `query` parameter that is injected directly into a SQL template via `strings.ReplaceAll`. The regular query endpoint `GET /api/subscribers` correctly calls `validateQueryTables` to block access to sensitive tables before execution. The export endpoint `GET /api/subscribers/export` **omits this call entirely**, creating an asymmetric bypass of an intentional security control. **`internal/core/subscribers.go` — protected path (regular query):** ```go // QuerySubscribers — table validation present stmt := strings.ReplaceAll(c.q.QuerySubscribersTpl, "%query%", cond) if err := validateQueryTables(c.db, stmt, allowedSubQueryTables); err != nil { return nil, 0, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Error preparing subscriber query: %v", err)) } ``` **`internal/core/subscribers.go` — vulnerable path (export):** ```go // ExportSubscribers — NO table validation stmt := strings.ReplaceAll(c.q.QuerySubscribersForExport, "%query%", cond) tx, err := c.db.Preparex(stmt) // executes directly without restriction ``` **`queries/subscribers.sql` — the `%query%` placeholder is injected into a WHERE clause:** ```sql SELECT subscribers.id, subscribers.email, ... FROM subscribers LEFT JOIN subscriber_lists ON ... WHERE (subscribers.status != 'blocklisted') AND %query% ORDER BY subscribers.id ASC LIMIT ... ``` Because the export path does not run inside a `ReadOnly` transaction (unlike the dry-run used in `QuerySubscribers`), PostgreSQL CTEs with data-modifying statements (`WITH ... UPDATE ... RETURNING`) are also executable, enabling write operations beyond read-only exfiltration. --- ### PoC **Prerequisites:** Authenticated session with `subscribers:sql_query` and `subscribers:get_all` permissions. **Step 1 — Confirm the bypass (blocked on query, open on export):** ```bash # Blocked on regular endpoint: curl -s "http://TARGET:9000/api/subscribers?query=(SELECT+1+FROM+users+LIMIT+1)+IS+NOT+NULL" \ -H "Cookie: session=SESSION_TOKEN" # → HTTP 400: {"message":"Error preparing subscriber query: table 'users' is not allowed"} # Bypassed on export endpoint: curl -s "http://TARGET:9000/api/subscribers/export?query=(SELECT+1+FROM+users+LIMIT+1)+IS+NOT+NULL" \ -H "Cookie: session=SESSION_TOKEN" # → HTTP 200: returns subscriber rows with no error ``` Affected: Go:github.com/knadh/listmonk Fixed in: 1.1.1-0.20260619102436-c0a6525009a6 References: https://github.com/knadh/listmonk/security/advisories/GHSA-xgjr-7j9q-2h4r https://nvd.nist.gov/vuln/detail/CVE-2026-62361 https://github.com/knadh/listmonk/commit/c0a6525009a65265230185f16e8674dcc83aa024 https://github.com/knadh/listmonk https://github.com/knadh/listmonk/releases/tag/v6.2.0