16
16
import java
17
17
import semmle.code.java.dataflow.TaintTracking
18
18
import semmle.code.java.frameworks.Rmi
19
- import DataFlow :: PathGraph
19
+ import BindingUnsafeRemoteObjectFlow :: PathGraph
20
20
21
21
/**
22
22
* A method that binds a name to a remote object.
@@ -48,22 +48,20 @@ private predicate hasVulnerableMethod(RefType type) {
48
48
* A taint-tracking configuration for unsafe remote objects
49
49
* that are vulnerable to deserialization attacks.
50
50
*/
51
- private class BindingUnsafeRemoteObjectConfig extends TaintTracking:: Configuration {
52
- BindingUnsafeRemoteObjectConfig ( ) { this = "BindingUnsafeRemoteObjectConfig" }
53
-
54
- override predicate isSource ( DataFlow:: Node source ) {
51
+ private module BindingUnsafeRemoteObjectConfig implements DataFlow:: ConfigSig {
52
+ predicate isSource ( DataFlow:: Node source ) {
55
53
exists ( ConstructorCall cc | cc = source .asExpr ( ) |
56
54
hasVulnerableMethod ( cc .getConstructedType ( ) .getAnAncestor ( ) )
57
55
)
58
56
}
59
57
60
- override predicate isSink ( DataFlow:: Node sink ) {
58
+ predicate isSink ( DataFlow:: Node sink ) {
61
59
exists ( MethodAccess ma | ma .getArgument ( 1 ) = sink .asExpr ( ) |
62
60
ma .getMethod ( ) instanceof BindMethod
63
61
)
64
62
}
65
63
66
- override predicate isAdditionalTaintStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
64
+ predicate isAdditionalFlowStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
67
65
exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
68
66
m .getDeclaringType ( ) .hasQualifiedName ( "java.rmi.server" , "UnicastRemoteObject" ) and
69
67
m .hasName ( "exportObject" ) and
@@ -74,6 +72,9 @@ private class BindingUnsafeRemoteObjectConfig extends TaintTracking::Configurati
74
72
}
75
73
}
76
74
77
- from DataFlow:: PathNode source , DataFlow:: PathNode sink , BindingUnsafeRemoteObjectConfig conf
78
- where conf .hasFlowPath ( source , sink )
75
+ private module BindingUnsafeRemoteObjectFlow =
76
+ TaintTracking:: Global< BindingUnsafeRemoteObjectConfig > ;
77
+
78
+ from BindingUnsafeRemoteObjectFlow:: PathNode source , BindingUnsafeRemoteObjectFlow:: PathNode sink
79
+ where BindingUnsafeRemoteObjectFlow:: flowPath ( source , sink )
79
80
select sink .getNode ( ) , source , sink , "Unsafe deserialization in a remote object."
0 commit comments