2
2
3
3
import java
4
4
import semmle.code.java.dataflow.DataFlow
5
+ import semmle.code.java.dataflow.TaintTracking
5
6
import semmle.code.java.dataflow.TaintTracking2
6
7
import semmle.code.java.dataflow.TaintTracking3
7
8
private import semmle.code.java.security.ArbitraryApkInstallation
@@ -18,9 +19,9 @@ private module ApkConf implements DataFlow::ConfigSig {
18
19
ma .getMethod ( ) instanceof SetDataMethod and
19
20
ma .getArgument ( 0 ) = node .asExpr ( ) and
20
21
(
21
- any ( PackageArchiveMimeTypeConfiguration c ) . hasFlowToExpr ( ma .getQualifier ( ) )
22
+ PackageArchiveMimeTypeConfiguration:: hasFlowToExpr ( ma .getQualifier ( ) )
22
23
or
23
- any ( InstallPackageActionConfiguration c ) . hasFlowToExpr ( ma .getQualifier ( ) )
24
+ InstallPackageActionConfiguration:: hasFlowToExpr ( ma .getQualifier ( ) )
24
25
)
25
26
)
26
27
}
@@ -34,14 +35,14 @@ module ApkConfiguration = DataFlow::Make<ApkConf>;
34
35
*
35
36
* This is used to track if an intent is used to install an APK.
36
37
*/
37
- private class InstallPackageActionConfiguration extends TaintTracking3 :: Configuration {
38
- InstallPackageActionConfiguration ( ) { this = "InstallPackageActionConfiguration" }
38
+ private module InstallPackageActionConfig implements DataFlow :: StateConfigSig {
39
+ class FlowState = string ;
39
40
40
- override predicate isSource ( DataFlow:: Node source ) {
41
- source .asExpr ( ) instanceof InstallPackageAction
41
+ predicate isSource ( DataFlow:: Node source , FlowState state ) {
42
+ source .asExpr ( ) instanceof InstallPackageAction and state instanceof DataFlow :: FlowStateEmpty
42
43
}
43
44
44
- override predicate isAdditionalTaintStep (
45
+ predicate isAdditionalFlowStep (
45
46
DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
46
47
DataFlow:: FlowState state2
47
48
) {
@@ -63,24 +64,30 @@ private class InstallPackageActionConfiguration extends TaintTracking3::Configur
63
64
)
64
65
}
65
66
66
- override predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
67
+ predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
67
68
state = "hasPackageInstallAction" and node .asExpr ( ) .getType ( ) instanceof TypeIntent
68
69
}
70
+
71
+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
69
72
}
70
73
74
+ private module InstallPackageActionConfiguration =
75
+ TaintTracking:: MakeWithState< InstallPackageActionConfig > ;
76
+
71
77
/**
72
78
* A dataflow configuration tracking the flow of the Android APK MIME type to
73
79
* the `setType` or `setTypeAndNormalize` method of an intent, followed by a call
74
80
* to `setData[AndType][AndNormalize]`.
75
81
*/
76
- private class PackageArchiveMimeTypeConfiguration extends TaintTracking2 :: Configuration {
77
- PackageArchiveMimeTypeConfiguration ( ) { this = "PackageArchiveMimeTypeConfiguration" }
82
+ private module PackageArchiveMimeTypeConfig implements DataFlow :: StateConfigSig {
83
+ class FlowState = string ;
78
84
79
- override predicate isSource ( DataFlow:: Node node ) {
80
- node .asExpr ( ) instanceof PackageArchiveMimeTypeLiteral
85
+ predicate isSource ( DataFlow:: Node node , FlowState state ) {
86
+ node .asExpr ( ) instanceof PackageArchiveMimeTypeLiteral and
87
+ state instanceof DataFlow:: FlowStateEmpty
81
88
}
82
89
83
- override predicate isAdditionalTaintStep (
90
+ predicate isAdditionalFlowStep (
84
91
DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
85
92
DataFlow:: FlowState state2
86
93
) {
@@ -98,8 +105,13 @@ private class PackageArchiveMimeTypeConfiguration extends TaintTracking2::Config
98
105
)
99
106
}
100
107
101
- override predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
108
+ predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
102
109
state = "typeSet" and
103
110
node instanceof SetDataSink
104
111
}
112
+
113
+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
105
114
}
115
+
116
+ private module PackageArchiveMimeTypeConfiguration =
117
+ TaintTracking:: MakeWithState< PackageArchiveMimeTypeConfig > ;
0 commit comments