Fixed: Adds a blacklist (to be renamed soon to denylist) in Java serialisation (OFBIZ-12167)

Adds an example based on RMI which is known to be a problem
This commit is contained in:
Jacques Le Roux
2021-02-05 11:03:26 +01:00
parent 03167586f9
commit ee51eb7360
@@ -63,9 +63,18 @@ public final class SafeObjectInputStream extends ObjectInputStream {
@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
if (!whitelistPattern.matcher(classDesc.getName()).find()) {
String className = classDesc.getName();
// BlackList exploits; eg: don't allow RMI here
if (className.contains("java.rmi.server")) {
Debug.logWarning("***Incompatible class***: "
+ classDesc.getName()
+ ". java.rmi.server classes are not allowed for security reason",
"SafeObjectInputStream");
return null;
}
if (!whitelistPattern.matcher(className).find()) {
// DiskFileItem, FileItemHeadersImpl are not serializable.
if (classDesc.getName().contains("org.apache.commons.fileupload")) {
if (className.contains("org.apache.commons.fileupload")) {
return null;
}
Debug.logWarning("***Incompatible class***: "