Skip to content

Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)#23

Open
devin-ai-integration[bot] wants to merge 5 commits intodevelop-7.0.xfrom
devin/1777588309-fix-insecure-deserialization
Open

Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)#23
devin-ai-integration[bot] wants to merge 5 commits intodevelop-7.0.xfrom
devin/1777588309-fix-insecure-deserialization

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 30, 2026

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 raw ObjectInputStream with 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 the ObjectInputStream. Only classes matching configured safe prefixes are permitted:

  • org.broadleafcommerce.* — Broadleaf domain types
  • java.lang.*, java.util.*, java.math.*, java.time.* — safe JDK types
  • Primitive array types (byte[], char[], int[], etc.)
  • Object arrays of permitted types (e.g. [Lorg.broadleafcommerce.SomeClass;)

Any class not on the allowlist triggers an InvalidClassException, blocking exploitation.

The isClassAllowed() method is protected so subclasses can extend the allowlist if needed.

Labels: Security, critical, ready-for-code-review

Additional context

  • Reference: CWE-502 — Deserialization of Untrusted Data
  • The vulnerability was at ZookeeperDistributedQueue.java:830-835
  • Build verified: mvn compile -pl core/broadleaf-framework -am passes cleanly

Link to Devin session: https://app.devin.ai/sessions/16deafe0069b46828ad1d10a741ae10b
Requested by: @Colhodm


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)
Open in Devin Review

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>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

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>
devin-ai-integration[bot]

This comment was marked as resolved.

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>
devin-ai-integration[bot]

This comment was marked as resolved.

IncrementalUpdateCommand contains List<SolrInputDocument> fields from
org.apache.solr.common, which must be permitted during deserialization.

Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant