/

CVE-2026-39951

Severity:

HIGH RISK

(7.6)

Stored SQL Injection (CWE-89) in Cacti Reports

CVE-2026-39951

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Confidentiality and Integrity Compromise

Severity:

HIGH RISK

(7.6)

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

Cacti versions 1.2.30 and earlier contain a stored SQL injection issue in the Reports feature via the graph_name_regexp field.

When malicious input is saved and later used in database queries without proper sanitization, an attacker can manipulate SQL statements and potentially access or alter data under typical web application deployment conditions.

Affected context

This vulnerability appears in Cacti deployments that expose the Reports feature and allow users to define or edit report filters, including the graph_name_regexp parameter.

It becomes relevant where user-provided report configuration is persisted and later interpolated into SQL queries to retrieve graph or performance data.

Risk is highest in environments where application database accounts have broad read/write permissions or where multi-tenant or role-based access controls rely on SQL-level filtering.

Exploit preconditions

  • Attack surface: Web-based Reports configuration interface in Cacti.
  • Required access: Ability to create or modify report definitions containing the graph_name_regexp field (typically an authenticated user with reporting privileges).
  • Trigger point: Subsequent execution of a report that uses the stored graph_name_regexp value in dynamically built SQL queries.
  • Why exploitation is possible: The application persists attacker-controlled input and later concatenates it into SQL statements without using parameterized queries or robust validation, enabling injection at query execution time.

Why this happens

The underlying issue is a classic SQL injection pattern where untrusted input is embedded directly into SQL queries.

In this case, the graph_name_regexp value from the Reports feature is stored and later used to construct database queries without parameterization or strict validation.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where control characters and query fragments within user input are not sufficiently neutralized before reaching the database engine.

Potential impact

  • An attacker may read sensitive data from Cacti's database, including configuration or performance metrics not normally accessible.
  • An attacker could modify or delete monitoring data, reports, or related configuration entries.
  • The injected SQL can potentially manipulate authentication or authorization-related data, impacting user access and roles.
  • In environments with overly privileged database accounts, an attacker may create or drop tables, leading to broader service disruption.

General mitigation guidance

Mitigation typically centers on removing dynamic string-based query construction and treating all user input as untrusted.

Secure patterns include consistently using parameterized queries or ORM abstractions for all database access, validating and constraining report filter inputs to expected formats (such as strict regex or whitelist patterns), and limiting database account privileges to the minimal set required.

Enforcing clear separation between presentation filters and SQL logic, along with careful encoding and validation at input boundaries, helps ensure that stored configuration data cannot alter query structure.

How teams detect issues like this

Detection commonly involves reviewing code for string concatenation in query builders and ensuring that inputs like graph_name_regexp are passed through parameter bindings rather than directly embedded.

Static analysis tools can be configured to flag uses of raw SQL APIs where user-controlled variables appear in the query string.

Manual code review should pay attention to stored configuration values being reused in queries and verify that validation and parameterization are consistently applied.

Policy-level controls, such as requiring database access through vetted data access layers and disallowing ad-hoc SQL in application code, further reduce the chance of similar issues.

Sources

SourceLink
github.comgithub.com/Cacti/cacti/commit/4c09efaebf3a9faec66969d0b5c4aceaf397f37f
github.comgithub.com/Cacti/cacti/security/advisories/GHSA-pf37-v86f-5xwp

Frequently asked

questions

Exploitability depends on who can create or edit reports; in many deployments, reporting permissions are limited, but a malicious or compromised user with access to the Reports feature can still leverage the issue.

No. The attacker only needs access to the web interface that stores graph_name_regexp; the application itself executes the injected SQL when reports run.

The strongest fix is to ensure all database interactions use parameterized queries or ORM constructs, and that filter fields like graph_name_regexp are validated against strict, well-defined formats before being stored or used.

Adopt a development policy that forbids dynamic SQL concatenation with user input, enforce mandatory input validation at all entry points, and integrate static analysis or security reviews into the development pipeline to catch injection patterns early.

Find out what's already
exploitable in your codebase.