/

CVE-2020-36947

Severity:

HIGH RISK

(7.1)

SQL Injection in LibreNMS MAC Accounting Graph Endpoint

CVE-2020-36947

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Authenticated Data Exfiltration via SQL Injection

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LibreNMS 1.46 contains an authenticated SQL injection flaw in the MAC accounting graph endpoint, where the sort parameter is incorporated into database queries without proper sanitization.

An authenticated remote attacker can manipulate this parameter using time-based blind SQL injection techniques to infer and extract sensitive database information.

Affected context

The vulnerability occurs in LibreNMS 1.46 within the MAC accounting graph functionality, where user-controlled input is used to influence database queries.

It is present in deployments where authenticated users can access the MAC accounting graph endpoint and where the sort parameter is passed directly or indirectly into SQL statements.

The issue is most relevant when LibreNMS is exposed to untrusted or semi-trusted users, such as shared deployments, MSP environments, or installations with multiple operator accounts.

Exploit preconditions

  • Attack surface: Web interface of LibreNMS, specifically the MAC accounting graph endpoint.
  • Required access: Valid authenticated LibreNMS user account with permission to access MAC accounting graphs.
  • Trigger point: Submission of crafted requests where the sort parameter contains malicious SQL fragments.
  • Why exploitation is possible: The sort parameter is concatenated into SQL queries without strict validation, parameterization, or whitelisting, enabling time-based blind SQL injection.

Why this happens

This issue stems from constructing SQL queries using string concatenation with user-supplied data instead of using parameterized queries or strict input validation.

The sort parameter, intended to control ordering or presentation, is treated as trusted and inserted directly into the query, allowing an attacker to modify query logic.

This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where user-controlled input is not safely handled before being used by the SQL engine.

More broadly, it reflects a design pattern where presentation-related parameters (sorting, filtering, pagination) are not constrained to a safe set of values.

Potential impact

  • Extraction of sensitive database information such as user-related data or configuration details.
  • Discovery of database schema, table names, and column metadata.
  • Leveraging database information for further lateral movement or privilege escalation in the environment.
  • Increased ability to plan secondary attacks (e.g., targeted credential attacks, system enumeration).

General mitigation guidance

Mitigation should focus on neutralizing user input before it reaches the database and reducing the trust placed in client-provided parameters:

  • Use parameterized queries or prepared statements for all dynamic SQL, including ordering and filtering logic.
  • Apply strict allowlists for parameters like sort, constraining them to a predefined set of column names and directions.
  • Avoid building SQL fragments directly from HTTP parameters; instead, map user choices to known-safe server-side constants.
  • Implement least-privilege database accounts so that even if a query is manipulated, access to sensitive tables and operations is limited.
  • Centralize database access patterns in a data-access layer to enforce secure query construction across the application.

How teams detect issues like this

Effective detection combines code-level analysis and runtime monitoring:

  • Use static analysis tools or linters configured with rules to detect string-concatenated SQL queries and unsanitized use of request parameters.
  • During code review, flag any direct use of request variables (like $_GET, $_POST, or framework equivalents) inside query-building logic, especially for sorting and filtering.
  • Introduce application-security tests (DAST) that perform automated SQL injection probes against web endpoints, including authenticated paths.
  • Monitor database logs for anomalous patterns such as frequent time-based queries, unexpected delays, or unusual query structures coming from the application.
  • Enforce secure coding policies in CI/CD pipelines that reject builds with identified unsafe query construction patterns.

Sources

SourceLink
community.librenms.orgcommunity.librenms.org/
github.comgithub.com/librenms/librenms
exploit-db.comexploit-db.com/exploits/49246
librenms.orglibrenms.org
vulncheck.comvulncheck.com/advisories/librenms-mac-accounting-graph-authenticated-sql-injection

Frequently asked

questions

Yes. It is remotely exploitable through the LibreNMS web interface, but the attacker must be authenticated and able to reach the MAC accounting graph endpoint.

An attacker needs a valid LibreNMS user account with access to the MAC accounting graph functionality. No direct database access is required, but the web account must be able to invoke the vulnerable endpoint.

Replace all string-concatenated SQL using the sort parameter with parameterized queries and a strict allowlist of permitted sort fields and directions, ensuring that user input is never directly embedded into SQL syntax.

Adopt a standard data-access layer that enforces parameterization by default, require allowlisting for all sorting and filtering parameters, integrate static and dynamic security testing into the development lifecycle, and include secure coding training focused on injection prevention for developers.

Find out what's already
exploitable in your codebase.