AVideo Unauthenticated Cross-User JavaScript Execution via YPTSocket Vulnerability
AVideo is vulnerable to unauthenticated cross-site scripting (XSS) due to an incomplete server-side fix for a YPTSocket `autoEvalCodeOnHTML` eval sink, allowing an attacker to bypass the fix by nesting the payload under a top-level `json` field, leading to arbitrary JavaScript execution in any logged-in user's browser session.
AVideo is vulnerable to an unauthenticated cross-site scripting (XSS) vulnerability stemming from an incomplete fix for the YPTSocket autoEvalCodeOnHTML eval sink (GHSA-gph2-j4c9-vhhr). The initial patch only stripped the payload when present under $json['msg'], but the relay function msgToResourceId() prioritizes $msg['json'] before $msg['msg']. An unauthenticated attacker can exploit this flaw by obtaining a WebSocket token from plugin/YPTSocket/getWebSocket.json.php, connecting to the WebSocket server, and sending a message with autoEvalCodeOnHTML nested under a top-level json field. This bypasses the strip branch, delivering the payload verbatim to any logged-in user identified by to_users_id, and the client script executes it via eval(). Versions of AVideo up to and including 29.0 are affected if they have not implemented the recommended fixes.
Attack Chain
- An unauthenticated attacker requests a WebSocket token from
plugin/YPTSocket/getWebSocket.json.php. - The server issues a valid WebSocket token without authentication or CSRF checks.
- The attacker establishes a WebSocket connection to the server using the obtained token.
- The attacker crafts a malicious message containing JavaScript code within the
autoEvalCodeOnHTMLfield, nested under a top-leveljsonfield:{"msg": "x", "json": {"autoEvalCodeOnHTML": "<js>"}, "to_users_id": <victim>}. - The attacker sends the crafted message to the WebSocket server.
- The server-side validation logic in
plugin/YPTSocket/Message.phpfails to properly sanitize theautoEvalCodeOnHTMLfield due to the bypass. - The server relays the message to the targeted user (
to_users_id) via the WebSocket connection. - The client-side script (
plugin/YPTSocket/script.js) receives the message and executes the JavaScript code withinautoEvalCodeOnHTMLviaeval(), leading to XSS.
Impact
This vulnerability allows for unauthenticated XSS and arbitrary JavaScript execution within any logged-in user’s browser session. A successful exploit enables attackers to compromise the same-origin policy, potentially leading to session data exfiltration, authenticated XHR calls on the victim’s behalf, privilege escalation (if targeting an administrator), and mass exploitation by enumerating active users via the getClientsList request. Deployments that only patched to commit c08694bf6 remain vulnerable.
Recommendation
- Apply the recommended patch by scrubbing
autoEvalCodeOnHTMLfrom every outbound carrier the relay may choose inplugin/YPTSocket/Message.phpandplugin/YPTSocket/MessageSQLiteV2.phpas described in the advisory. - Harden the relay in
msgToResourceId()(both files) by recursively walking the chosen$obj['msg']and unsettingautoEvalCodeOnHTMLwhen the message originated from a non-PHP, non-CLI client. - As defense in depth, remove or gate the client-side
eval(json.msg.autoEvalCodeOnHTML)atplugin/YPTSocket/script.js:573-575behind a server-signed field rather than a plain JSON key. - Deploy the Sigma rule
Detect AVideo YPTSocket autoEvalCodeOnHTML Bypassto detect attempts to exploit this vulnerability by monitoring for WebSocket messages containing theautoEvalCodeOnHTMLfield within ajsonfield.
Detection coverage 2
Detect AVideo YPTSocket autoEvalCodeOnHTML Bypass
highDetects attempts to exploit the AVideo YPTSocket autoEvalCodeOnHTML vulnerability by monitoring for WebSocket messages containing the `autoEvalCodeOnHTML` field within a `json` field.
Detect AVideo WebSocket connection to exploit XSS
mediumDetects a WebSocket connection attempt to AVideo that may be used to exploit the XSS vulnerability. This focuses on suspicious parameters in the WebSocket URL.
Detection queries are kept inside the platform. Get full rules →