飙血推荐
  • HTML教程
  • MySQL教程
  • JavaScript基础教程
  • php入门教程
  • JavaScript正则表达式运用
  • Excel函数教程
  • UEditor使用文档
  • AngularJS教程
  • ThinkPHP5.0教程

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

时间:2021-12-13  作者:ffx1  

漏洞概述

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

漏洞详情

1、官方修复代码:https://域名/grafana/grafana/commit/c798c0e958d15d9cc7f27c72113d572fa58545ce

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

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

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

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

rel, err := 域名("/", 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

标签:编程
湘ICP备14001474号-3  投诉建议:234161800@qq.com   部分内容来源于网络,如有侵权,请联系删除。