GHSA-G84G-6GGW-J4G6
Arbitrary file read, delete and write via theme import mass assignment
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-G84G-6GGW-J4G6 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/lhtheme/import.php:80` applies the uploaded theme JSON to the model with `$widgetTheme->setState($data)`, and `lib/core/lhcore/lhdbtrait.php:6-11` is a bare loop:
foreach ($properties as $key => $val) { $this->$key = $val; }The model carries `#[\AllowDynamicProperties]`, so every key in the file becomes a property, including ones the import form never offers.
Three sinks follow from that one assignment. `lib/models/lhabstract/erlhabstractmodelwidgettheme.php:129` reads `file_get_contents($this->{$attr.'_path'}.'/'.$this->$attr)`, and `modules/lhtheme/export.php:34` returns that content base64 encoded. `:177-178` passes the same pair to `unlink()`. And `logo_image_pending` reaches `afterSave():232-236`, which calls `movePhoto($attr)` with the default `$isLocal = false`, so the upload lands through `moveUploadedFile()`, which applies no extension check at all.
Result: an account holding the single `administratethemes` permission reads any readable file, deletes files in any writable directory, and writes an executable `.php` into the web root.
Details
`import.php:80` hands the decoded upload to `setState()`, which applies it without a whitelist, so `logo_image`, `logo_image_path` and `logo_image_pending` are attacker controlled. `erlhabstractmodelwidgettheme.php:129` builds the read path from the first two and `export.php:34` emits the bytes, gated only by `export.php:33` requiring `logo_image_url` to be non empty. `:177` tests and `:178` deletes the same pair, concatenated without a separator, so the path value has to end in a slash itself. `afterSave():232-236` is the write path: `movePhoto()` takes `$isLocal = false` by default and routes to `moveUploadedFile()`, which has no extension allowlist, while the local branch used by `import.php:106` is constrained by the extension list at `import.php:93` and by `isPhotoLocal()`.
Reachable with no configuration change, once an administrator has granted the permission.
`lhtheme/administratethemes` (`modules/lhtheme/module.php:77`) is one grantable checkbox. The Operators role the installer creates receives only `personaltheme` and `use_operator` from this module (`modules/lhinstall/install.php:3052`, `:3058`). The holder cannot list users, read chats or open the system configuration, all three refused live.
The theme id is a small sequential integer. The role cannot list widget themes, so the id is found by walking `theme/export/<n>`; a wrong id returns 503 and writes one `lh_audits` row, which is the only noisy step.
Proof of concept
LiveHelperChat 4.94v (`d8787d04`), Docker, default configuration. Attacker is `chk08`, whose role holds exactly one `lh_rolefunction` row: `lhtheme` / `administratethemes`.
- Import a theme file carrying the path attributes. The endpoint takes multipart form data with a `themefile` whose name ends in `.json`.
curl -b jar -F csfr_token=<token> -F themefile=@theme.json -F ImportTheme=Import \
http://127.0.0.1:8020/index.php/site_admin/theme/import
theme.json: {"name":"chk08", "logo_image_path":"settings", "logo_image":"settings.ini.php"}The response is the import form again and names no id; the id is found through `theme/export/<n>`.
- Export the theme and decode the embedded image.
GET /index.php/site_admin/theme/export/<id> -> logo_image_data, 18566 bytes decoded
sha256 decoded fd220ba7a7caf2fdc4155b3af0dc730a94cf0fcf4357efc16550eca975eed752
sha256 in container fd220ba7a7caf2fdc4155b3af0dc730a94cf0fcf4357efc16550eca975eed752
/var/www/html/settings/settings.ini.phpThe file holds `'secrethash' => 'GmwdTARq10BQ...'` and `'user' => 'root'`, `'password' => 'rootpw'`.
- `logo_image_path` of `../../../../etc` and `logo_image` of `passwd` returns 839 bytes starting `root:x:0:0:root:/root:/bin/bash`, outside the document root.
- Deletion needs a second attribute: either a valid `logo_image_data` with an allowed `logo_image_data_ext`, or `logo_image_pending`. With `logo_image_path` of `var/` including the trailing slash, the named file is gone after the import. A file owned by `root` with mode `0444` was deleted, because `unlink()` depends on the directory.
- `"logo_image_pending": true` with an uploaded `.php` writes it under `var/storagetheme/<y>/<m>/<d>/<id>/`, and a plain GET on that path returned the marker string with HTTP 200.
Controls
- An account in the stock Operators role is refused on `theme/import`, and no theme row appears.
- Anonymous requests on import and export redirect to the login form.
- A non-existent file yields `logo_image_data` of zero bytes.
Live-verified: one permission read `settings.ini.php` byte identically, read `/etc/passwd`, deleted a root owned file in the web root, and wrote and executed a `.php` file.
Impact
- Code execution as the web server user, from a `.php` written through the import and fetched over HTTP.
- Any readable file is exfiltrated, including `secrethash` and the database credentials; a 3.3 MB binary came out byte identical, the only ceiling being PHP's `memory_limit`.
- Any file in a directory the web server user can write is deleted, regardless of its owner and mode.
- Import, export, read, delete and the write leave no `lh_audits` row at all.
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-g84g-6ggw-j4g6Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
