The vulnerability is a classic reflected Cross-Site Scripting (XSS) attack. The root cause is twofold, involving both server-side and client-side code.
-
Server-Side Source: The PHP script view/videoNotFound.php takes user input from the 404ErrorMsg URL parameter and directly embeds it into a JavaScript function call. It uses json_encode() without the necessary flags (JSON_HEX_TAG, JSON_HEX_AMP) to escape characters that have special meaning in HTML, such as < and >. This allows an attacker to inject raw HTML tags into the string passed to the client.
-
Client-Side Sink: The injected string is passed to the avideoAlertInfo() JavaScript function. This function, in turn, calls a series of other functions (avideoAlert() -> avideoAlertHTMLText()) that ultimately use the innerHTML property to render the message in the browser. Because innerHTML parses and executes HTML, any malicious script embedded in the user-provided string (e.g., via an <img onerror=...> tag) is executed in the context of the victim's browser session.
The patch addresses the vulnerability comprehensively. On the server side, it adds the JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, and JSON_HEX_QUOT flags to json_encode in videoNotFound.php to properly escape the input. On the client side, it refactors all the alert-related JavaScript functions in view/js/script.js to use the safe textContent property by default, instead of the dangerous innerHTML property, thus preventing the rendering of injected HTML.