Summary
LibreNMS 1.65 contains a SQL injection vulnerability in the sort parameter processed by the /ajax_table.php API endpoint. An authenticated attacker with normal privileges may be able to manipulate database queries and extract sensitive information from the LibreNMS database.
Affected context
The vulnerability occurs in LibreNMS deployments where authenticated users can access the AJAX table API and supply sorting parameters that are incorporated into database queries without sufficient controls. Multiple table components under includes/html/table are affected, including address, alert, device, event, inventory, routing, sensor, storage, and toner-related views.
Exploit preconditions
- Attack surface: The /ajax_table.php API endpoint and its table-specific handlers - Required access: An authenticated account with normal application privileges - Trigger point: Processing of attacker-controlled sort parameters - Why exploitation is possible: Input used to construct a database query is not
adequately constrained to an approved set of sorting fields or safely separated
from SQL syntax
Why this happens
The underlying bug is insufficient neutralization and validation of user controlled input used in a SQL query. When a sort parameter is treated as a trusted query fragment rather than as a constrained data value or mapped application option, an attacker may influence database statement behavior. This matches CWE-89, which covers improper neutralization of special elements used in an SQL command.
Potential impact
- An attacker may extract sensitive information from the LibreNMS database.
- Database records, credentials, monitoring data, or configuration details could be exposed.
- Query behavior could be altered in ways that affect application availability or integrity.
- Data obtained from the database could support further compromise of monitored systems.
General mitigation guidance
Mitigation generally focuses on ensuring that dynamic query components cannot be supplied directly by users. Common defensive patterns include using parameterized queries for values, mapping sort inputs to a strict server-side allowlist of known columns and directions, and rejecting unexpected input before query construction. Database accounts should follow least privilege, sensitive credentials should not be stored or exposed unnecessarily, and access to administrative monitoring interfaces should be limited to trusted users and networks. Reducing input trust at the API boundary and applying consistent query-building abstractions across all affected table handlers can reduce recurrence.
How teams detect issues like this
Detection approaches include static analysis for string concatenation or interpolation of request parameters into SQL statements, review of endpoint handlers that accept sort, filter, or pagination fields, and searches for database calls lacking parameter binding. Code review should verify that user-provided sort fields are mapped to fixed server-side identifiers rather than passed through as query fragments. Runtime monitoring can correlate unusual authenticated requests, repeated malformed sorting parameters, and abnormal database read activity. Automated application security testing and neutral code-scanning tools may help identify similar patterns.

