VYPR
Unrated severityNVD Advisory· Published May 13, 2024· Updated Nov 4, 2025

Cacti RCE vulnerability when importing packages

CVE-2024-25641

Description

Cacti provides an operational monitoring and fault management framework. Prior to version 1.2.27, an arbitrary file write vulnerability, exploitable through the "Package Import" feature, allows authenticated users having the "Import Templates" permission to execute arbitrary PHP code on the web server. The vulnerability is located within the import_package() function defined into the /lib/import.php script. The function blindly trusts the filename and file content provided within the XML data, and writes such files into the Cacti base path (or even outside, since path traversal sequences are not filtered). This can be exploited to write or overwrite arbitrary files on the web server, leading to execution of arbitrary PHP code or other security impacts. Version 1.2.27 contains a patch for this issue.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected products

13

Patches

Vulnerability mechanics

Root cause

"The import_package function blindly trusts user-supplied filenames and file content, allowing path traversal and arbitrary file writes."

Attack vector

An authenticated user with the 'Import Templates' permission can exploit this vulnerability. The attacker crafts a malicious XML package containing a file with a path traversal sequence in its name and arbitrary PHP code as its content. This package is then uploaded and imported via the 'Package Import' feature. The server-side script processes this XML, writing the malicious PHP file to a location within the Cacti base path, or potentially outside of it, enabling arbitrary code execution when accessed.

Affected code

The vulnerability resides in the `import_package()` function within the `/lib/import.php` script. Specifically, the code fails to sanitize the `$name` variable derived from the XML data before constructing the full file path using `CACTI_PATH_BASE . "/$name"` and subsequently writing the file content.

What the fix does

The patch introduces a regular expression check, `preg_match('/^(scripts|resource)[a-zA-Z0-9_\-]*$/', dirname($name))`, within the `import_package()` function. This validation ensures that the directory where the file is intended to be written is within the expected 'scripts' or 'resource' subdirectories of the Cacti base path. By rejecting filenames with invalid path components, it prevents path traversal and the writing of arbitrary files to unintended locations, thereby mitigating the arbitrary file write and subsequent RCE vulnerability.

Preconditions

  • authThe attacker must be authenticated to the Cacti application.
  • authThe authenticated user must possess the 'Import Templates' permission.

Reproduction

Use the provided PHP script to generate a malicious `test.xml.gz` file. Log in to Cacti with a user having 'Import Templates' permission, navigate to 'Import/Export' -> 'Import Packages', and upload the generated file. The PHP file will be written to the resource directory and can be accessed via `http://[cacti]/resource/test.php` to confirm code execution.

Generated on Jun 2, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

4

News mentions

0

No linked articles in our index yet.