Skip to content

Implement ObjectInputFilter allowlist for legacy object deserialization - #838

Open
AliRana30 wants to merge 1 commit into
apache:mainfrom
AliRana30:fix/object-input-filter-835
Open

AliRana30 wants to merge 1 commit into
apache:mainfrom
AliRana30:fix/object-input-filter-835

Conversation

@AliRana30

Copy link
Copy Markdown
Contributor

What changes?

  1. ObjectFileSerialization:
    • Adds createObjectInputFilter(Class<?> elementType) to restrict legacy object deserialization to expected primitives, wrappers, standard safe collections, Wayang types, Scala tuples, and expected elementType hierarchies.
    • Adds dynamic allowlist pattern configuration via wayang.basic.serialization.allowlist.
    • Rejects unauthorized classes with InvalidClassException.
  2. WayangValue:
    • Enforces the ObjectInputFilter on Flink criterion deserialization.
    • Refactors convertToByte and convertToObject to use try-with-resources.
  3. Tests:
    • Added unit test cases to verify rejection of disallowed classes, explicit elementType acceptance, and system property pattern matching.

Why are the changes needed?

Directly calling ObjectInputStream.readObject() without an ObjectInputFilter allows arbitrary class instantiation, posing a deserialization security risk (CWE-502).

How was this tested?

  • Unit tests added to ObjectFileSerializationTest and WayangValueTest.
  • Ran mvn test on wayang-basic and wayang-flink.
  • Ran mvn apache-rat:check.

Closes : #835

Copilot AI balanced review requested due to automatic review settings October 10, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@AliRana30

Copy link
Copy Markdown
Contributor Author

@zkaoudi Pr is up for your review.

@novatechflow

Copy link
Copy Markdown
Member

Thanks for the fix. Three issues to address before merging:

  • The allowlist accepts arbitrary Number, Collection, and Map subclasses. Custom readObject() hooks still execute.
  • A fresh WayangValue rejects valid custom payloads and silently returns null because the expected type comes from previous data.
  • List.of(), Set.of(), and Map.of() fail deserialization because java.util.CollSer is missing.

Reproduced all three on Java 17. Please tighten the allowlist and add regression tests.

@AliRana30
AliRana30 force-pushed the fix/object-input-filter-835 branch from 05351a2 to c2850f7 Compare October 21, 2026 23:02
@AliRana30

Copy link
Copy Markdown
Contributor Author

@novatechflow Updated the allowlist and WayangValue as per the feedback. Alos added regression tests for all three cases in ObjectFileSerializationTest and WayangValueTest. Verified clean build on Java 17

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.

[Improvement] Implement ObjectInputFilter allowlist for legacy object deserialization

3 participants