Objects are read with Java serialization, which runs code chosen by the data
What it finds
ObjectInputStream(input).readObject() creates whatever classes the stream names and runs their deserialization code, so a crafted stream from an untrusted source can run code in the program. A data format such as JSON with a fixed schema, or an object input filter, limits what is read.
From the rule's source, object_deserialization.rs.
import java.io.ObjectInputStream fun load(input: java.io.InputStream): Any = ObjectInputStream(input).readObject()tx0 reports: Java serialization creates whatever classes Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:java-deserialization" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:java-deserialization] reason="..."tx0 explain tx0/kotlin:java-deserialization shows the same in the terminal. Found a false positive? Report it.