Summary
A SQL Injection vulnerability in Cacti's SNMP agent managers module allows attacker-controlled identifiers to be concatenated directly into a DELETE query without validation.
When an attacker with SNMP agent management permissions can influence the serialized graph selection array, they may inject arbitrary SQL fragments into the database operation.
Affected context
This vulnerability occurs in Cacti deployments using the SNMP agent managers interface where selected graph IDs are processed via managers.php.
The issue manifests when the application deserializes user-provided arrays representing selected items and uses them directly in SQL queries without enforcing integer constraints or using parameterized statements.
It is most relevant in environments where users with SNMP agent management permissions can craft or tamper with the selected_graphs_array request parameter.
Exploit preconditions
- Attack surface: Web interface endpoint
managers.phphandling SNMP agent manager operations. - Required access: Ability to authenticate and obtain SNMP agent management permissions, or otherwise control the
selected_graphs_arrayparameter. - Trigger point: Submission of a crafted request where
selected_graphs_arraycontains malicious values that, once deserialized, are used in theDELETE FROM snmpagent_managers WHERE id IN (...)SQL statement. - Why exploitation is possible: The deserialized array elements are concatenated via
implode(',', $selected_items)directly into the SQL query string without integer validation, escaping, or parameterization, matching the pattern of CWE-89.
Why this happens
The root cause is the construction of SQL queries by directly embedding untrusted data into the query string.
Although cacti_unserialize() uses unserialize() with allowed_classes = false to prevent object injection, it still allows arbitrary string array elements to be restored from user input.
These array values are then imploded into an IN clause and passed to db_execute() without any type checking or bound parameters, creating a classic SQL Injection scenario defined by CWE-89: improper neutralization of special elements used in an SQL command.
Potential impact
- An attacker may delete arbitrary rows from the
snmpagent_managerstable. - An attacker could manipulate SQL syntax to affect other tables if the database engine and query context permit extended injection.
- The vulnerability can lead to corruption of monitoring or management configuration data.
- Depending on database privileges and configuration, the attacker might escalate to broader data disclosure or modification.
General mitigation guidance
Effective mitigation focuses on treating all user-sourced identifiers as untrusted and enforcing strict query construction patterns.
Preferred defensive approaches include using parameterized queries for any dynamic SQL, validating and casting IDs as integers before use, and centralizing data access through helper routines that reject non-conforming inputs.
Separating serialization/deserialization concerns from database logic and ensuring that deserialized arrays undergo schema and type validation before being consumed by persistence layers further reduces risk.
Running the application with least-privilege database accounts limits damage if an injection pathway is missed.
How teams detect issues like this
Detection commonly involves reviewing code paths where SQL queries are assembled using string concatenation, especially around implode() or similar aggregation functions.
Static analysis rules can flag calls to database execution helpers when untrusted variables, request parameters, or deserialized data are directly embedded into SQL strings.
Manual code reviews should look for missing input validation and absence of prepared statements in CRUD operations involving IDs and list parameters.
Organizational policies can mandate the use of parameterized queries and linting rules that block direct concatenation of dynamic data into SQL at commit or CI time.

