"Applied fix from trunk for revision: 1866834"
------------------------------------------------------------------------ r1866834 | jleroux | 2019-09-12 09:49:41 +0200 (jeu. 12 sept. 2019) | 8 lignes Improved: Improve ObjectInputStream class (OFBIZ-10837) Fixes CVE-2019-0189 Allows users to easily override the list of accepted objects by using the listOfSafeObjectsForInputStream property CVE-2019-0189 ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1866836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -62,7 +62,8 @@ public class SafeObjectInputStream extends java.io.ObjectInputStream {
|
||||
if (!WHITELIST_PATTERN.matcher(classDesc.getName()).find()) {
|
||||
Debug.logWarning("***Incompatible class***: " + classDesc.getName() +
|
||||
". Please see OFBIZ-10837. Report to dev ML if you use OFBiz without changes. "
|
||||
+ "Else add your class into UtilObject::getObjectException", "SafeObjectInputStream");
|
||||
+ "Else follow https://s.apache.org/45war"
|
||||
, "SafeObjectInputStream");
|
||||
throw new ClassCastException("Incompatible class: " + classDesc.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.io.InputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.apache.ofbiz.base.lang.Factory;
|
||||
@@ -101,13 +102,22 @@ public final class UtilObject {
|
||||
|
||||
/** Deserialize a byte array back to an object */
|
||||
public static Object getObjectException(byte[] bytes) throws ClassNotFoundException, IOException {
|
||||
String listOfSafeObjectsForInputStream = UtilProperties.getPropertyValue("SafeObjectInputStream",
|
||||
"ListOfSafeObjectsForInputStream");
|
||||
List<String> listOfSafeObjects = null;
|
||||
if (UtilValidate.isNotEmpty(listOfSafeObjectsForInputStream)) {
|
||||
listOfSafeObjects = java.util.Arrays.asList(listOfSafeObjectsForInputStream);
|
||||
} else {
|
||||
listOfSafeObjects = java.util.Arrays.asList("byte\\[\\]", "foo", "SerializationInjector",
|
||||
"\\[Z","\\[B","\\[S","\\[I","\\[J","\\[F","\\[D","\\[C",
|
||||
"java..*", "sun.util.calendar..*", "org.apache.ofbiz..*");
|
||||
} // "foo" and, "SerializationInjector" are used in UtilObjectTests::testGetObject
|
||||
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
|
||||
SafeObjectInputStream wois = new SafeObjectInputStream(bis,
|
||||
Thread.currentThread().getContextClassLoader(),
|
||||
java.util.Arrays.asList("byte\\[\\]", "foo", "SerializationInjector",
|
||||
"\\[Z","\\[B","\\[S","\\[I","\\[J","\\[F","\\[D","\\[C",
|
||||
"java..*", "sun.util.calendar..*", "org.apache.ofbiz..*"));) {
|
||||
// "foo" and, "SerializationInjector" are used in UtilObjectTests::testGetObject
|
||||
listOfSafeObjects)) {;
|
||||
|
||||
return wois.readObject();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user