Skip to content

Authenticated RCE via multi-line SNMP responses

Critical
netniV published GHSA-c5j8-jxj3-hh36 Jan 26, 2025

Package

Cacti (PHP)

Affected versions

<= 1.2.8

Patched versions

1.2.29

Description

Summary

Due to a flaw in multi-line SNMP result parser, authenticated users can inject malformed OIDs in the response. When processed by ss_net_snmp_disk_io() or ss_net_snmp_disk_bytes(), a part of each OID will be used as a key in an array that is used as part of a system command, causing a command execution vulnerability.

Details

In cacti_snmp_walk() cacti uses exec_into_array() to execute commands and read results with multiple lines as an array, After that the following code will be used to parse those lines by check for an equal sign and assigning the left size of it as the oid and the right side as its value. These parsed OIDs will be added to the final result. In the process the values will be filtered but not the OIDs.

ss_flaw

If the line being parsed did not contain an OID (checked by the regex) then it will this line, without filtering, to the value of the previous OID.

ss_net_snmp_disk_io() requests three OIDs using snmpwalk, then stores is in two variables $names and $iops. The last part of each OID from $names will be added to an array named $indexes.

$parts = explode('.', $measure['oid']);
$indexes[$parts[cacti_sizeof($parts)-1]] = $parts[cacti_sizeof($parts)-1];

Another snmpwalk request will be made and cacti will check if the last part of each OID from this request is in $indexes , if it is, then the value of this OID will be added to an array named $current.

$current["dr$index"] = $measure['value'];

current will be json encoded and added to a shell command. Before passing the json string to a shell, cacti will quote this data using single quotes, but this can be easily broken.

$data = "'" . json_encode($current) . "'";
shell_exec("echo $data > $tmpdir/$tmpfile");

PoC

  1. Start an snmp agent to send the payload.
  2. Change 'Local Linux Machine' device port to your agent port.
  3. Add "Net-SNMP - Combined SCSI Disk I/O " to the device graph templates, if its not already.
  4. Go to graph tree and select Local Linux Machine.
  5. Click "view in realtime" in 'Combine SCSI disk I/O' graph.

cacti_devmod
ss_realtime

Impact

This vulnerability can allows authenticated users with device management permissions to execute code in the server, and steal, edit, or delete sensitive data.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
High
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

CVE ID

CVE-2025-22604

Weaknesses

Credits