@@ -27,25 +27,28 @@ private module ApkInstallationConfiguration implements DataFlow::ConfigSig {
27
27
28
28
module ApkInstallationFlow = DataFlow:: Make< ApkInstallationConfiguration > ;
29
29
30
+ private newtype ActionState =
31
+ ActionUnset ( ) or
32
+ HasInstallPackageAction ( )
33
+
30
34
/**
31
35
* A dataflow configuration tracking the flow from the `android.content.Intent.ACTION_INSTALL_PACKAGE`
32
36
* constant to either the constructor of an intent or the `setAction` method of an intent.
33
37
*
34
38
* This is used to track if an intent is used to install an APK.
35
39
*/
36
40
private module InstallPackageActionConfiguration implements DataFlow:: StateConfigSig {
37
- class FlowState = string ;
41
+ class FlowState = ActionState ;
38
42
39
43
predicate isSource ( DataFlow:: Node source , FlowState state ) {
40
- source .asExpr ( ) instanceof InstallPackageAction and state instanceof DataFlow :: FlowStateEmpty
44
+ source .asExpr ( ) instanceof InstallPackageAction and state instanceof ActionUnset
41
45
}
42
46
43
47
predicate isAdditionalFlowStep (
44
- DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
45
- DataFlow:: FlowState state2
48
+ DataFlow:: Node node1 , FlowState state1 , DataFlow:: Node node2 , FlowState state2
46
49
) {
47
- state1 instanceof DataFlow :: FlowStateEmpty and
48
- state2 = "hasPackageInstallAction" and
50
+ state1 instanceof ActionUnset and
51
+ state2 instanceof HasInstallPackageAction and
49
52
(
50
53
exists ( ConstructorCall cc |
51
54
cc .getConstructedType ( ) instanceof TypeIntent and
@@ -62,8 +65,8 @@ private module InstallPackageActionConfiguration implements DataFlow::StateConfi
62
65
)
63
66
}
64
67
65
- predicate isSink ( DataFlow:: Node node , DataFlow :: FlowState state ) {
66
- state = "hasPackageInstallAction" and node .asExpr ( ) .getType ( ) instanceof TypeIntent
68
+ predicate isSink ( DataFlow:: Node node , FlowState state ) {
69
+ state instanceof HasInstallPackageAction and node .asExpr ( ) .getType ( ) instanceof TypeIntent
67
70
}
68
71
69
72
predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
@@ -72,25 +75,28 @@ private module InstallPackageActionConfiguration implements DataFlow::StateConfi
72
75
private module InstallPackageActionFlow =
73
76
TaintTracking:: MakeWithState< InstallPackageActionConfiguration > ;
74
77
78
+ private newtype MimeTypeState =
79
+ MimeTypeUnset ( ) or
80
+ HasPackageArchiveMimeType ( )
81
+
75
82
/**
76
83
* A dataflow configuration tracking the flow of the Android APK MIME type to
77
84
* the `setType` or `setTypeAndNormalize` method of an intent, followed by a call
78
85
* to `setData[AndType][AndNormalize]`.
79
86
*/
80
87
private module PackageArchiveMimeTypeConfiguration implements DataFlow:: StateConfigSig {
81
- class FlowState = string ;
88
+ class FlowState = MimeTypeState ;
82
89
83
90
predicate isSource ( DataFlow:: Node node , FlowState state ) {
84
91
node .asExpr ( ) instanceof PackageArchiveMimeTypeLiteral and
85
- state instanceof DataFlow :: FlowStateEmpty
92
+ state instanceof MimeTypeUnset
86
93
}
87
94
88
95
predicate isAdditionalFlowStep (
89
- DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
90
- DataFlow:: FlowState state2
96
+ DataFlow:: Node node1 , FlowState state1 , DataFlow:: Node node2 , FlowState state2
91
97
) {
92
- state1 instanceof DataFlow :: FlowStateEmpty and
93
- state2 = "typeSet" and
98
+ state1 instanceof MimeTypeUnset and
99
+ state2 instanceof HasPackageArchiveMimeType and
94
100
exists ( MethodAccess ma |
95
101
ma .getQualifier ( ) = node2 .asExpr ( ) and
96
102
(
@@ -103,8 +109,8 @@ private module PackageArchiveMimeTypeConfiguration implements DataFlow::StateCon
103
109
)
104
110
}
105
111
106
- predicate isSink ( DataFlow:: Node node , DataFlow :: FlowState state ) {
107
- state = "typeSet" and
112
+ predicate isSink ( DataFlow:: Node node , FlowState state ) {
113
+ state instanceof HasPackageArchiveMimeType and
108
114
node instanceof SetDataSink
109
115
}
110
116
0 commit comments