Stored XSS via SNMP and Syslog in LibreNMS
LibreNMS is vulnerable to stored cross-site scripting (XSS) due to improper output encoding of SNMP-polled data and syslog messages in legacy PHP templates, allowing attackers to execute arbitrary JavaScript in the browsers of authenticated users.
LibreNMS versions prior to 26.5.0 contain multiple stored cross-site scripting (XSS) vulnerabilities within legacy PHP templates located in the includes/html/ directory. The vulnerability stems from the direct echoing of data retrieved from SNMP-monitored network devices and incoming syslog messages without appropriate output encoding or escaping.
Specific components impacted include the syslog viewer, alert details page, and device health monitoring dashboards (mempool, storage, and sensors). An attacker with the ability to modify SNMP interface descriptions (ifAlias) or send arbitrary syslog traffic to the LibreNMS server can inject malicious JavaScript. When an authenticated LibreNMS administrator or user views these dashboards, the payload executes within their browser context. This allows attackers to perform actions on behalf of the user, potentially including credential theft or unauthorized configuration changes within the monitoring platform. The issue is exacerbated by the platform's reliance on legacy PHP templates that bypass the auto-escaping features present in newer Blade-based templates.
Attack Chain
- Attacker establishes control over a network device or syslog-capable host monitored by the target LibreNMS instance.
- Attacker modifies the SNMP
ifAlias(interface description) or sends a crafted syslogprogramstring containing a JavaScript payload (e.g.,<img src=x onerror="fetch('...')">). - LibreNMS performs its scheduled SNMP discovery/polling cycle or receives the syslog packet.
- The unescaped, malicious string is stored directly into the LibreNMS SQL database (e.g., the
portstable orsyslogtable). - An authenticated LibreNMS user navigates to the affected web interface (e.g., Alerts page, Health dashboard, or Syslog view).
- The legacy PHP template fetches the malicious string from the database and echoes it raw into the HTML response.
- The victim's web browser renders the HTML and executes the attacker's JavaScript payload within the context of the user session.
- Attacker achieves unauthorized execution, such as data exfiltration or session manipulation.
Impact
The vulnerability allows an attacker to compromise the sessions of authenticated users, which can lead to unauthorized access to the network monitoring platform. Given that LibreNMS often holds high-privileged credentials and visibility into sensitive infrastructure, successful exploitation could facilitate lateral movement, information gathering, or operational disruption. The impact is significant for organizations using LibreNMS as a central visibility tool for core network components.
Recommendation
- Upgrade all LibreNMS installations to version 26.5.0 or later immediately.
- Audit logs for unexpected characters or script tags in SNMP interface descriptions or syslog program fields.
- Restrict access to SNMP configuration and syslog submission channels to trusted IP ranges to prevent unauthorized data injection.
- Use the webserver log source to monitor for unusual POST/GET patterns directed at health, alert, and syslog endpoints.
Immediate actions
Upgrade LibreNMS to 26.5.0 or later
Threat Hunt
Search web logs for anomalous script-like characters in parameters for health/alerts pages
Data: webserver logs
Detection coverage 1
Detect XSS Payload in Web Requests to LibreNMS
highDetects potential XSS exploitation attempts against LibreNMS by searching for common JavaScript injection patterns in web server logs, specifically targeting parameters likely to be rendered in health or alert templates.
Detection queries are available on the platform. Get full rules →