/

CVE-2026-40083

Severity:

HIGH RISK

(7.2)

SQL Injection (CWE-89) in Cacti SNMP Managers Module

CVE-2026-40083

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Manipulation and Potential Data Compromise

Severity:

HIGH RISK

(7.2)

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

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.php handling SNMP agent manager operations.
  • Required access: Ability to authenticate and obtain SNMP agent management permissions, or otherwise control the selected_graphs_array parameter.
  • Trigger point: Submission of a crafted request where selected_graphs_array contains malicious values that, once deserialized, are used in the DELETE 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_managers table.
  • 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.

Sources

SourceLink
github.comgithub.com/Cacti/cacti/releases/tag/release%2F1.2.31
github.comgithub.com/Cacti/cacti/security/advisories/GHSA-j9jv-6xjq-9hhj

Frequently asked

questions

Exploitability is generally scoped to the database operations performed by the affected query. In this case, it centers on the snmpagent_managers table and potentially adjacent data, depending on how the underlying database interprets injected content and query context.

The attacker typically needs authenticated access with SNMP agent management permissions or some means of controlling the selected_graphs_array parameter in requests to managers.php. Anonymous exploitation is unlikely without misconfigurations that expose this functionality.

The safest fix is to eliminate string-based SQL construction and adopt parameterized queries, combined with strict integer validation and casting of all identifier values before they reach the database layer.

Preventive strategies include enforcing a coding standard that bans dynamic SQL concatenation, integrating static analysis checks in CI pipelines, requiring peer review for all data access code, and validating every deserialized or user-supplied value against expected types and schemas prior to database use.

Find out what's already
exploitable in your codebase.