Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)#23
Open
devin-ai-integration[bot] wants to merge 5 commits intodevelop-7.0.xfrom
Open
Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)#23devin-ai-integration[bot] wants to merge 5 commits intodevelop-7.0.xfrom
devin-ai-integration[bot] wants to merge 5 commits intodevelop-7.0.xfrom
Conversation
Add allowlist-based class filtering to the deserialize() method to prevent Remote Code Execution via untrusted ObjectInputStream.readObject() calls. - Override resolveClass() with an anonymous ObjectInputStream that validates class names against a configurable set of allowed prefixes - Default allowlist includes org.broadleafcommerce.*, java.lang.*, java.util.*, java.math.*, java.time.*, and primitive array types - Extract isClassAllowed() as a protected method for subclass extensibility - Reject all classes not on the allowlist with InvalidClassException Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Recursively strip leading '[' characters so types like byte[][] ("[[B")
and String[][] ("[[Ljava.lang.String;") are correctly validated against
the allowlist instead of being rejected.
Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
The entry was ineffective (resolveClass is never called for interfaces) and its prefix match inadvertently permitted java.io.SerializablePermission. Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
IncrementalUpdateCommand contains List<SolrInputDocument> fields from org.apache.solr.common, which must be permitted during deserialization. Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Without this, crafted streams using java.lang.reflect.Proxy with allowed interfaces could bypass the resolveClass filter entirely. Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)
Fixes the critical insecure deserialization vulnerability where
ObjectInputStream.readObject()was called without any class filtering, potentially allowing Remote Code Execution if an attacker can influence data stored in Zookeeper.A Brief Overview
ZookeeperDistributedQueue.deserialize()previously used a rawObjectInputStreamwith no validation on which classes could be instantiated during deserialization. This is a well-known attack vector (CWE-502) that can lead to RCE via gadget chains.The fix introduces an allowlist-based class filter by overriding
resolveClass()in theObjectInputStream. Only classes matching configured safe prefixes are permitted:org.broadleafcommerce.*— Broadleaf domain typesjava.lang.*,java.util.*,java.math.*,java.time.*— safe JDK typesbyte[],char[],int[], etc.)[Lorg.broadleafcommerce.SomeClass;)Any class not on the allowlist triggers an
InvalidClassException, blocking exploitation.The
isClassAllowed()method isprotectedso subclasses can extend the allowlist if needed.Labels: Security, critical, ready-for-code-review
Additional context
ZookeeperDistributedQueue.java:830-835mvn compile -pl core/broadleaf-framework -ampasses cleanlyLink to Devin session: https://app.devin.ai/sessions/16deafe0069b46828ad1d10a741ae10b
Requested by: @Colhodm
Devin Review