Skip to content

Commit 39e652b

Browse files
committed
Java: teach UnsafeDeserialization about ValidatingObjectInputStream
The class org.apache.commons.io.serialization.ValidatingObjectInputStream is an implementation of ObjectInputStream that validates the deserialized classes against a white list. Therefore, this class should not be considered an unsafe deserialization sink.
1 parent 797721c commit 39e652b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

java/ql/src/semmle/code/java/security/UnsafeDeserialization.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ class SafeKryo extends DataFlow2::Configuration {
5151
predicate unsafeDeserialization(MethodAccess ma, Expr sink) {
5252
exists(Method m | m = ma.getMethod() |
5353
m instanceof ObjectInputStreamReadObjectMethod and
54-
sink = ma.getQualifier()
54+
sink = ma.getQualifier() and
55+
not exists(DataFlow::ExprNode node |
56+
node.getExpr() = sink and
57+
node
58+
.getTypeBound()
59+
.(RefType)
60+
.hasQualifiedName("org.apache.commons.io.serialization", "ValidatingObjectInputStream")
61+
)
5562
or
5663
m instanceof XMLDecoderReadObjectMethod and
5764
sink = ma.getQualifier()

0 commit comments

Comments
 (0)