diff --git a/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/util/queue/ZookeeperDistributedQueue.java b/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/util/queue/ZookeeperDistributedQueue.java index 259089438f..2b8e545af2 100644 --- a/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/util/queue/ZookeeperDistributedQueue.java +++ b/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/util/queue/ZookeeperDistributedQueue.java @@ -38,6 +38,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.ObjectInputFilter; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -79,6 +80,13 @@ public class ZookeeperDistributedQueue implements Distri private static final Log LOG = LogFactory.getLog(ZookeeperDistributedQueue.class); private static final String QUEUE_ENTRY_NAME = "dz-queue-entry"; + /** + * Filter that restricts deserialization to known safe classes to prevent RCE via CWE-502. + */ + private static final ObjectInputFilter DESERIALIZATION_FILTER = ObjectInputFilter.Config.createFilter( + "org.broadleafcommerce.**;org.apache.solr.**;java.lang.*;java.util.*;java.io.Serializable;java.math.*;java.time.*;!*" + ); + protected final Object QUEUE_MONITOR = new Object(); private final String queueFolderPath; private final ZooKeeper zk; @@ -832,6 +840,7 @@ protected Object deserialize(byte[] bytes) { ObjectInputStream ois = null; try { ois = new ObjectInputStream(bais); + ois.setObjectInputFilter(DESERIALIZATION_FILTER); return ois.readObject(); } catch (IOException | ClassNotFoundException e) { throw new DistributedQueueException("Unable to deserialze an element from the Zookeeper queue.", e);