Cross-site scripting (XSS) vulnerability in the handle_request function in lib/HTTPServer.pm in Monitorix before 3.4.0 allows remote attackers to inject arbitrary web script or HTML via the PATH_INFO.
Monitorix versions prior to 3.4.0 are vulnerable to a cross-site scripting (XSS) attack. This allows attackers to inject malicious JavaScript into the web interface, potentially leading to account compromise, data theft, or system takeover through client-side exploitation.
Step 1: Payload Delivery: An attacker crafts a malicious URL containing a JavaScript payload within the PATH_INFO component. This payload is designed to execute arbitrary code within the victim's browser.
Step 2: Request Submission: The attacker tricks a user into visiting the crafted URL. This could be through phishing, social engineering, or other means.
Step 3: Server Processing: The Monitorix server receives the HTTP request and, due to the vulnerability, processes the PATH_INFO without proper sanitization.
Step 4: HTML Generation: The handle_request function incorporates the attacker-controlled PATH_INFO (including the malicious JavaScript) into the HTML response.
Step 5: Browser Rendering: The victim's browser receives the HTML response, which now includes the attacker's JavaScript payload.
Step 6: Payload Execution: The browser executes the injected JavaScript, allowing the attacker to perform actions such as stealing cookies, redirecting the user, or defacing the website.
The vulnerability stems from insufficient input validation within the handle_request function of lib/HTTPServer.pm. Specifically, the code fails to properly sanitize the PATH_INFO variable before incorporating it into the HTML response. This allows attackers to inject arbitrary HTML and JavaScript payloads. The root cause is a lack of proper escaping or filtering of user-supplied input, leading to a classic XSS vulnerability. The handle_request function likely directly incorporates the PATH_INFO into the HTML output without sanitization, making it vulnerable to malicious script injection.