Java: add extra sink for java/unsafe-deserialization#20025
Merged
owen-mc merged 4 commits intogithub:mainfrom Jul 11, 2025
Merged
Java: add extra sink for java/unsafe-deserialization#20025owen-mc merged 4 commits intogithub:mainfrom
java/unsafe-deserialization#20025owen-mc merged 4 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the java/unsafe-deserialization query by expanding the recognition of deserialization sinks to include calls to readObject on any classes implementing java.io.ObjectInput, not just subclasses of java.io.ObjectInputStream. This provides broader coverage for detecting unsafe deserialization patterns.
- Added support for detecting unsafe deserialization through
ObjectInputinterface implementations - Refactored the code to separate
readObjectandreadUnsharedmethod handling - Added comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
java/ql/lib/semmle/code/java/JDK.qll |
Added TypeObjectInput class for java.io.ObjectInput interface |
java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll |
Refactored to detect readObject calls on ObjectInput implementations and separated readUnshared handling |
java/ql/test/query-tests/security/CWE-502/com/example/MyObjectInput.java |
Test class implementing ObjectInput interface for validation |
java/ql/test/query-tests/security/CWE-502/A.java |
Updated test cases to include new deserialization scenarios |
java/ql/test/query-tests/security/CWE-502/UnsafeDeserialization.ext.yml |
Added source models for test data flow |
java/ql/test/query-tests/security/CWE-502/UnsafeDeserialization.expected |
Updated expected results reflecting new detections |
java/ql/lib/change-notes/2025-07-11-unsafe-deserialization-extra-sink.md |
Documentation of the enhancement |
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.
The qualifiers of a calls to
readObjecton any classes that implementjava.io.ObjectInputare now recognised as sinks forjava/unsafe-deserialization. Previously this was only the case for classes which extendjava.io.ObjectInputStream.