Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,6 +80,13 @@ public class ZookeeperDistributedQueue<T extends Serializable> 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.*;!*"
);
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

protected final Object QUEUE_MONITOR = new Object();
private final String queueFolderPath;
private final ZooKeeper zk;
Expand Down Expand Up @@ -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);
Expand Down