Summary
LibreNMS versions 25.12.0 and below contain an SQL injection vulnerability in the ajax_table.php endpoint when handling IPv6 address searches.
By abusing the unvalidated prefix portion of the address parameter, an attacker can inject arbitrary SQL, which may lead to unauthorized data access or database manipulation.
Affected context
This vulnerability appears in LibreNMS deployments that expose the ajax_table.php endpoint and support IPv6 address searching.
The issue arises when the application splits an IPv6 address parameter into an address and prefix and then directly concatenates the prefix into an SQL query string without proper validation or parameterization.
Installations where user-controlled search parameters are accepted and passed into the database layer without strict filtering are particularly at risk, especially when the database user has broad read or write privileges.
Exploit preconditions
- Attack surface: HTTP requests to the
ajax_table.phpendpoint (typically over the web UI / API). - Required access: Ability to send crafted requests containing the
addressparameter; this could be authenticated or unauthenticated depending on how the instance is configured. - Trigger point: Execution of the IPv6 search logic that splits the
addressinput and incorporates the prefix directly into the SQL query. - Why exploitation is possible: The prefix portion of the
addressparameter is concatenated into the SQL string without parameterization or adequate validation, allowing attacker-controlled SQL fragments to alter the intended query structure.
Why this happens
The underlying bug is a classic SQL injection pattern: dynamically building SQL query strings with untrusted data.
In this case, LibreNMS splits the user-supplied IPv6 address into an address and prefix component, then embeds the prefix directly in the SQL query text.
Because the prefix is not passed through a parameterized query interface or properly constrained to expected formats, it can inject control characters, operators, or additional SQL statements.
This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where user input is mixed with query logic rather than treated as data.
Potential impact
- Unauthorized reading of monitoring and configuration data stored in the LibreNMS database.
- Modification or deletion of database records, potentially impacting monitoring accuracy and device inventories.
- Creation or alteration of user accounts or permissions if the schema and privileges allow it.
- Leveraging database-level functions to move toward remote code execution in certain environments.
- Disruption of monitoring operations through corrupted or tampered database state.
General mitigation guidance
Effective mitigation focuses on eliminating dynamic SQL construction with untrusted input and tightening database privileges:
- Use parameterized queries or prepared statements for all user-supplied input, including search filters and prefixes.
- Apply strict input validation and normalization on address-related fields, enforcing allowed formats (e.g., IPv6 notation and prefix length ranges) before reaching the database layer.
- Centralize query construction through safe data access layers instead of building SQL strings inline in request handlers.
- Configure the database user used by LibreNMS according to least-privilege principles, limiting access to only the necessary schemas and operations.
- Add defense-in-depth controls such as query builders or ORM frameworks that discourage direct string concatenation.
How teams detect issues like this
Detection typically involves combining code-level and runtime perspectives:
- Static analysis: Scan the codebase for SQL queries built via string concatenation, especially around parameters like
addressor prefix-handling logic; flag any use of concatenation instead of bound parameters. - Code review: Examine request handlers and AJAX endpoints for manual query assembly and ensure user input is passed through validation and parameterized query APIs.
- Security testing: Use targeted input fuzzing and application security testing tools to exercise IPv6 search functionality and detect anomalous SQL behavior or errors.
- Database monitoring: Monitor for unusual or complex queries originating from application accounts, including attempts at UNIONs, stacked queries, or manipulation of authentication-related tables.

