Skip to content

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

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

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

Conversation

@devin-ai-integration
Copy link
Copy Markdown

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

Fix insecure deserialization in ZookeeperDistributedQueue (CWE-502)

Addresses a critical Remote Code Execution vulnerability via insecure deserialization.

A Brief Overview

ZookeeperDistributedQueue.deserialize() uses ObjectInputStream.readObject() on data from Zookeeper without any class filtering or validation. This is a well-known deserialization vulnerability (CWE-502) that can lead to Remote Code Execution (RCE) if an attacker can influence the data stored in Zookeeper.

Changes

  • Added an ObjectInputFilter (Java 9+ API) to the deserialize() method that restricts deserialization to an allowlist of safe package prefixes:
    • java.lang.*, java.util.*, java.io.*, java.math.*, java.time.*, java.net.*
    • org.broadleafcommerce.*
  • Array types are unwrapped to their base component type and validated against the allowlist (primitive arrays are always allowed).
  • Primitives are always allowed.
  • Unknown classes are rejected with a warning log message.
  • Added a new constructor parameter (additionalAllowedPackages) so callers can extend the allowlist for custom types if needed, without modifying the default security posture.
  • All existing constructors delegate to the new constructor with null additional packages, preserving backward compatibility.

Labels: Security, critical

Additional context

The fix uses Java's built-in ObjectInputFilter mechanism (available since Java 9; this project targets Java 17), which is the recommended approach per Oracle's secure coding guidelines. The allowlist approach is preferred over a denylist because it prevents exploitation via novel gadget chains not yet on any known blocklist.

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


Open in Devin Review

Add ObjectInputFilter to deserialize() to prevent Remote Code Execution
via untrusted data from Zookeeper. The filter uses an allowlist approach,
permitting only standard Java types and org.broadleafcommerce.* classes
by default. Additional packages can be allowed via a new constructor
parameter.

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.

Unwrap array component types and validate them against the allowlist
to prevent bypass via arrays of disallowed types (e.g. Evil[]).

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