22
33import java
44import semmle.code.java.dataflow.DataFlow
5+ import semmle.code.java.dataflow.TaintTracking
56import semmle.code.java.dataflow.TaintTracking2
67import semmle.code.java.dataflow.TaintTracking3
78private import semmle.code.java.security.ArbitraryApkInstallation
@@ -18,9 +19,9 @@ private module ApkConf implements DataFlow::ConfigSig {
1819 ma .getMethod ( ) instanceof SetDataMethod and
1920 ma .getArgument ( 0 ) = node .asExpr ( ) and
2021 (
21- any ( PackageArchiveMimeTypeConfiguration c ) . hasFlowToExpr ( ma .getQualifier ( ) )
22+ PackageArchiveMimeTypeConfiguration:: hasFlowToExpr ( ma .getQualifier ( ) )
2223 or
23- any ( InstallPackageActionConfiguration c ) . hasFlowToExpr ( ma .getQualifier ( ) )
24+ InstallPackageActionConfiguration:: hasFlowToExpr ( ma .getQualifier ( ) )
2425 )
2526 )
2627 }
@@ -34,14 +35,14 @@ module ApkConfiguration = DataFlow::Make<ApkConf>;
3435 *
3536 * This is used to track if an intent is used to install an APK.
3637 */
37- private class InstallPackageActionConfiguration extends TaintTracking3 :: Configuration {
38- InstallPackageActionConfiguration ( ) { this = "InstallPackageActionConfiguration" }
38+ private module InstallPackageActionConfig implements DataFlow :: StateConfigSig {
39+ class FlowState = string ;
3940
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
4243 }
4344
44- override predicate isAdditionalTaintStep (
45+ predicate isAdditionalFlowStep (
4546 DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
4647 DataFlow:: FlowState state2
4748 ) {
@@ -63,24 +64,30 @@ private class InstallPackageActionConfiguration extends TaintTracking3::Configur
6364 )
6465 }
6566
66- override predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
67+ predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
6768 state = "hasPackageInstallAction" and node .asExpr ( ) .getType ( ) instanceof TypeIntent
6869 }
70+
71+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
6972}
7073
74+ private module InstallPackageActionConfiguration =
75+ TaintTracking:: MakeWithState< InstallPackageActionConfig > ;
76+
7177/**
7278 * A dataflow configuration tracking the flow of the Android APK MIME type to
7379 * the `setType` or `setTypeAndNormalize` method of an intent, followed by a call
7480 * to `setData[AndType][AndNormalize]`.
7581 */
76- private class PackageArchiveMimeTypeConfiguration extends TaintTracking2 :: Configuration {
77- PackageArchiveMimeTypeConfiguration ( ) { this = "PackageArchiveMimeTypeConfiguration" }
82+ private module PackageArchiveMimeTypeConfig implements DataFlow :: StateConfigSig {
83+ class FlowState = string ;
7884
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
8188 }
8289
83- override predicate isAdditionalTaintStep (
90+ predicate isAdditionalFlowStep (
8491 DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
8592 DataFlow:: FlowState state2
8693 ) {
@@ -98,8 +105,13 @@ private class PackageArchiveMimeTypeConfiguration extends TaintTracking2::Config
98105 )
99106 }
100107
101- override predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
108+ predicate isSink ( DataFlow:: Node node , DataFlow:: FlowState state ) {
102109 state = "typeSet" and
103110 node instanceof SetDataSink
104111 }
112+
113+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
105114}
115+
116+ private module PackageArchiveMimeTypeConfiguration =
117+ TaintTracking:: MakeWithState< PackageArchiveMimeTypeConfig > ;
0 commit comments