Skip to content

Add a defensive check to class resolution during deserialization - #281

Open
yannaingtun wants to merge 2 commits into
gngrOrg:masterfrom
yannaingtun:objectinputstream-class-resolution
Open

Add a defensive check to class resolution during deserialization#281
yannaingtun wants to merge 2 commits into
gngrOrg:masterfrom
yannaingtun:objectinputstream-class-resolution

Conversation

@yannaingtun

Copy link
Copy Markdown

This change restricts class resolution in ClassLoaderObjectInputStream by validating deserialized classes against an expected base type, preventing unexpected classes from being loaded.

Addresses issue #280.

Signed-off-by: yannaingtun <yannaingtun2007@gmail.com>
@hrj

hrj commented Dec 19, 2025

Copy link
Copy Markdown
Member

Thanks. Can you also modify the callers to use the new constructor?

@yannaingtun

Copy link
Copy Markdown
Author

Hi @hrj, thanks for the feedback.
I’ve updated all callers to use the new constructor:

new ClassLoaderObjectInputStream(..., expectedClass)

For now, I used Serializable.class as the base type since all retrieved objects are expected to be Serializable. Please let me know if you'd prefer a more specific base type for any of the call sites.

PR is ready for another review.

@hrj

hrj commented Dec 24, 2025

Copy link
Copy Markdown
Member

Thanks, it looks like a good start. If you can make the retrieved class a bit more specific that will help tighten the bolts around this.

If you are not able to, I will try to chip in next week.

PS: When you are ready, you can sign the commit(s) in order to satisfy the DCO: https://wiki.linuxfoundation.org/dco

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.

2 participants