GHSA-X6RP-3GQ8-6Q47
Stored XSS in the visitor chat renderer via [html_snippet] BBCode
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-X6RP-3GQ8-6Q47 divulgada · CVSS 6.1 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`design/defaulttheme/tpl/lhchat/lists/user_msg_row.tpl.php:5` calls `erLhcoreClassBBCode::extractMetaByMessage($msg['msg'])` on the raw message of every message it renders, before any sanitizer runs and without looking at the sender.
`extractMetaByMessage` (`lib/core/lhbbcode/lhbbcode.php:1127-1137`) pulls the content of each `[html_snippet]` pair out with `preg_match_all` and stores the capture group unchanged.
`design/defaulttheme/tpl/lhgenericbot/message/content/html_snippet.tpl.php:2` echoes that capture group into a JavaScript object literal:
<script>lhinst.sendHTML(<?php echo $msg['id']?>,{'type':'msg','id':<?php echo $messageCanned?>});</script>There is no cast and no encoder. An anonymous visitor writes the tag into an ordinary chat message. The ingest filter at `modules/lhchat/addmsguser.php:38` strips `[html]` and only `[html]`, so `[html_snippet]` passes through it unchanged.
Result: an anonymous visitor executes script in the application origin for anyone who opens that chat, with no account and no operator interaction.
Details
`user_msg_row.tpl.php:5` passes the raw `$msg['msg']` to `extractMetaByMessage`, which at `lhbbcode.php:1131` matches `/\[html_snippet\](.*?)\[\/html_snippet\]/is` and at `:1134` keeps `$matches[1][$index]` verbatim. `html_snippet.tpl.php:2` prints that value into the `'id':` position of a JavaScript object literal inside a `<script>` element, where HTML escaping would not help and no escaping is applied. `modules/lhchat/addmsguser.php:38` removes `[html]` pairs from the stored message with `preg_replace` and leaves `[html_snippet]` untouched, so the ordinary visitor message path stores the payload. Neither `sender` nor `user_id_raw` nor `render_html` is read anywhere on this path, so the sink does not distinguish visitor messages from operator messages. The response carries no `script-src` policy.
Reachable in a stock install, with no account and no configuration change.
The payload has to close both the object literal and the call, `1});payload//`, because `1);payload//` leaves the brace open and the browser raises a syntax error instead.
Four visitor facing views render a stored message through this path: `chat/chat`, `chat/chatpreview`, `chat/printchat` and `chat/syncuser`. Two further includes of `user_msg_row.tpl.php` exist, in `lhchat/part/render_intro.tpl.php:36` and `lhtheme/renderpreview.tpl.php:8`, and both render bot trigger previews from `processTriggerPreview()` rather than stored chat messages. The operator panel renders through `meta_render_admin.tpl.php`, which has no `html_snippet` branch and never calls `extractMetaByMessage`, so an operator sees the payload as literal text. The victim therefore has to open a chat URL the attacker supplies.
`modules/lhchat/addmsguser.php:14` caps the message at `max_message_length`, 500 characters by default, and `:35` accepts it only while the chat status is `pending`, `active` or `bot`. Neither a department beyond the default nor an operator being online is required. `chat/chat` authorises on the chat hash alone (`modules/lhchat/chat.php:40`), and that hash does not expire.
Proof of concept
LiveHelperChat 4.94v (`d8787d04`), Docker, default configuration, anonymous visitor, Chromium.
- Store the payload through the ordinary visitor message endpoint.
POST /index.php/eng/chat/addmsguser/11/<chat-hash>
msg=V2 [html_snippet]1});window.__XSSVERIF=document.domain+'|'+document.cookie
+'|'+(localStorage.length);console.log('XSSVERIF:'+window.__XSSVERIF);//[/html_snippet] END
HTTP/1.1 200 OK
{"error":"f","r":""}- Open the chat view. The server emits the payload as script source.
GET /index.php/eng/chat/chat/11/<chat-hash>
<script>lhinst.sendHTML(23,{'type':'msg','id':1});window.__XSSVERIF=document.domain
+'|'+document.cookie+'|'+(localStorage.length);console.log('XSSVERIF:'+window.__XSSVERIF);//});</script>- In the browser on `http://127.0.0.1:8010` the console logs `XSSVERIF:127.0.0.1||0` and `window.__XSSVERIF` is set. The same payload is served by the JSON poll `chat/syncuser` as well.
Controls
- A message without the tag produces no `sendHTML` block in the DOM.
- The earlier payload shape `1);...//` emits `Uncaught SyntaxError: Unexpected token ')'` and nothing executes, which is why the brace matters.
- The operator view `site_admin/chat/printchatadmin/9` renders the same stored message as literal text, with no `<script>` element.
Live-verified: anonymous visitor message executes JavaScript in the application origin in Chromium, confirmed by console output and by the global it sets.
Impact
- Script execution in the application origin for every visitor who opens the attacker's chat URL.
- The payload is stored, so it fires on every later render of that chat.
- `PHPSESSID` and `lhc_vid` both carry `HttpOnly` and both storages are empty, so the lever is not reading but acting: the payload issues same origin requests that carry the viewer's cookies, demonstrated with a `fetch` on `chat/printchat` returning the full transcript.
- The ingest filter covers `[html]` only, while `extractMetaByMessage` recognises a second meta tag that no filter touches.
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-x6rp-3gq8-6q47Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
