Summary
LibreNMS before 26.3.1 contains a stored cross-site scripting vulnerability in legacy PHP templates that render SNMP- and syslog-sourced values without adequate output escaping. An attacker who controls a monitored network device may inject JavaScript that executes when an authenticated user views an affected page.
Affected context
The vulnerability occurs in LibreNMS deployments that use legacy PHP templates to display data received from monitored network devices. It becomes risky when a device or its management interface can be controlled by an attacker, and when authenticated users view pages containing unescaped SNMP interface descriptions or syslog program fields.
Exploit preconditions
- Attack surface: Web pages rendered by legacy LibreNMS PHP templates
- Required access: Ability to control or influence a monitored network device, including values reported through SNMP or syslog
- Trigger point: An authenticated user views an affected LibreNMS page
- Why exploitation is possible: Device-sourced values are inserted into HTML without context-appropriate output encoding, allowing stored script content to be interpreted by the browser
Why this happens
The underlying bug is improper neutralization of user-controllable data in web output, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'). Legacy templates treat SNMP- and syslog-derived values as trusted display data instead of encoding them for their output context, allowing embedded markup or script content to persist and execute in users' browsers.
Potential impact
- An attacker may execute JavaScript in the context of an authenticated LibreNMS session
- The vulnerability could expose data available to the affected user
- An attacker may perform unauthorized actions through the victim's browser
- Administrative users could experience greater impact if they view the affected content
General mitigation guidance
Mitigation generally focuses on making output encoding the default for every untrusted value rendered by the application.
Common defensive patterns include:
- Apply context-appropriate HTML, attribute, URL, or JavaScript encoding at the final output point
- Treat SNMP, syslog, device metadata, and other externally sourced values as untrusted
- Prefer templating systems with automatic escaping enabled by default
- Restrict administrative privileges and separate monitoring roles from high-impact management roles
- Use a restrictive Content Security Policy as defense in depth
- Avoid rendering raw HTML unless it is explicitly required and safely sanitized
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for unescaped variables in PHP templates
- Code review checks tracing SNMP and syslog data from ingestion to HTML output
- Tests that insert harmless marker characters into device-sourced fields and verify correct encoding
- Policy enforcement requiring automatic template escaping or approved sanitization libraries
- Browser-based security testing focused on pages displaying externally controlled monitoring data
Automated code review and security scanning tools may help identify missing output encoding, but findings should be validated against the relevant rendering context.

