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_regexpfield (typically an authenticated user with reporting privileges). - Trigger point: Subsequent execution of a report that uses the stored
graph_name_regexpvalue 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.

