"Applied fix from trunk for revision: 1853745 "

------------------------------------------------------------------------
r1853745 | jleroux | 2019-02-17 13:38:06 +0100 (dim. 17 févr. 2019) | 8 lignes

Improved: Improve ObjectInputStream class
(OFBIZ-10837)

Fixes CVE-2019-0189

The white list I used was not complete.
This adds "java.util.HashMap", "Boolean", "Number", "Integer" which are the ones
missing I found so far. 
Maybe other classes could still miss OOTB. So I added a warning in 
SafeObjectInputStream::resolveClass
------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1853747 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2019-02-17 12:39:57 +00:00
parent 224a68f063
commit 5a558c85d4
2 changed files with 4 additions and 1 deletions
@@ -60,6 +60,9 @@ public class SafeObjectInputStream extends java.io.ObjectInputStream implements
@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
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 you class into UtilObject::getObjectException", "SafeObjectInputStream");
throw new ClassCastException("Incompatible class: " + classDesc.getName());
}
@@ -142,7 +142,7 @@ public final class UtilObject {
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
SafeObjectInputStream wois = new SafeObjectInputStream(bis,
Thread.currentThread().getContextClassLoader(),
java.util.Arrays.asList("byte\\[\\]", "Number", "Long", "foo", "SerializationInjector"));
java.util.Arrays.asList("byte\\[\\]", "Number", "Long", "foo", "SerializationInjector", "java.util.HashMap", "Boolean", "Number", "Integer"));
) { // byte[] used in EntityCrypto::doDecrypt, all others used in UtilObjectTests::testGetObject
return wois.readObject();
}