程序笔记   发布时间:2022-07-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Grafana 任意文件读取漏洞 (CVE-2021-43798)学习大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

漏洞概述

Grafana是一个跨平台、开源的数据可视化网络应用程序平台。用户配置连接的数据源之后,Grafana可以在网络浏览器里显示数据图表和警告。 Grafana 的读取文件接口存在未授权,且未对文件地址进行过滤,导致可以目录穿越/../../../../../../../../../os filepath实现系统任意文件读取。

漏洞详情

1、官方修复代码:https://github.com/grafana/grafana/commit/c798c0e958d15d9cc7f27c72113d572fa58545ce

Grafana 任意文件读取漏洞 (CVE-2021-43798)学习

2、可以看到问题出在pkg/api/api.go中的 getPluginAssets()函数,如下:

Grafana 任意文件读取漏洞 (CVE-2021-43798)学习

通过pluginid得到插件信息,如果插件不存在就返回404; 通过requestedFile := filepath.Clean(web.Params(c.Req)["*"]) 文件path,并且通过了clean函数的处理,但这里没有处理彻底,导致可以通过../../../../../方式绕过,pluginFilePath := filepath.Join(plugin.PluginDir, requestedFile) 拼接插件目录。

poc:/public/plugins/exit-plugin-name/../../../../../../../../etc/passwd

3、官方修复增加了 rel, err := filepath.Rel("/", requestedFile),我们来看看go中的rel()函数是做什么的: Rel(basepath, targpath string) (string, error),官方解释有点绕,说人话就是: 函数返回值等于 targpath 减去 basepath ,要求 targpath 和 basepath 必须“都是相对路径”或“都是绝对路径”。

rel, err := filepath.Rel("/", requestedFile)/是绝对路径,我们要实现目录穿越的话,../../是相对路径,因此这里就过不去,无法成功利用了。

影响范围

Grafana 8.0.0-beta1 - 8.3.0

安全版本

Grafana >= 8.3.1 Grafana >= 8.2.7 Grafana >= 8.1.8 Grafana >= 8.0.7

受影响plugins

alertGroups alertlist alertmanager annolist barchart bargauge canvas cloudwatch dashboard dashlist debug elasticsearch gauge geomap gettingstarted grafana-azure-monitor-datasource grafana graph graphite heatmap histogram influxdb jaeger live logs loki mixed mssql mysql news nodeGraph opentsdb piechart pluginlist postgres prometheus stat state-timeline status-history table-old table tempo testdata text timeseries welcome xychart zipkin> yon

大佬总结

以上是大佬教程为你收集整理的Grafana 任意文件读取漏洞 (CVE-2021-43798)学习全部内容,希望文章能够帮你解决Grafana 任意文件读取漏洞 (CVE-2021-43798)学习所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: