@@ -8,9 +8,11 @@ import semmle.code.java.dataflow.TaintTracking3
88import semmle.code.java.security.AndroidIntentRedirection
99
1010/**
11+ * DEPRECATED: Use `IntentRedirectionFlow` instead.
12+ *
1113 * A taint tracking configuration for tainted Intents being used to start Android components.
1214 */
13- class IntentRedirectionConfiguration extends TaintTracking:: Configuration {
15+ deprecated class IntentRedirectionConfiguration extends TaintTracking:: Configuration {
1416 IntentRedirectionConfiguration ( ) { this = "IntentRedirectionConfiguration" }
1517
1618 override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -26,31 +28,44 @@ class IntentRedirectionConfiguration extends TaintTracking::Configuration {
2628 }
2729}
2830
31+ private module IntentRedirectionConfig implements DataFlow:: ConfigSig {
32+ predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
33+
34+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof IntentRedirectionSink }
35+
36+ predicate isBarrier ( DataFlow:: Node sanitizer ) { sanitizer instanceof IntentRedirectionSanitizer }
37+
38+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
39+ any ( IntentRedirectionAdditionalTaintStep c ) .step ( node1 , node2 )
40+ }
41+ }
42+
43+ /** A taint tracking configuration for tainted Intents being used to start Android components. */
44+ module IntentRedirectionFlow = TaintTracking:: Make< IntentRedirectionConfig > ;
45+
2946/**
3047 * A sanitizer for sinks that receive the original incoming Intent,
3148 * since its component cannot be arbitrarily set.
3249 */
3350private class OriginalIntentSanitizer extends IntentRedirectionSanitizer {
34- OriginalIntentSanitizer ( ) { any ( SameIntentBeingRelaunchedConfiguration c ) . hasFlowTo ( this ) }
51+ OriginalIntentSanitizer ( ) { SameIntentBeingRelaunchedFlow :: hasFlowTo ( this ) }
3552}
3653
3754/**
3855 * Data flow configuration used to discard incoming Intents
3956 * flowing directly to sinks that start Android components.
4057 */
41- private class SameIntentBeingRelaunchedConfiguration extends DataFlow2 :: Configuration {
42- SameIntentBeingRelaunchedConfiguration ( ) { this = "SameIntentBeingRelaunchedConfiguration" }
58+ private module SameIntentBeingRelaunchedConfig implements DataFlow :: ConfigSig {
59+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
4360
44- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
45-
46- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof IntentRedirectionSink }
61+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof IntentRedirectionSink }
4762
48- override predicate isBarrier ( DataFlow:: Node barrier ) {
63+ predicate isBarrier ( DataFlow:: Node barrier ) {
4964 // Don't discard the Intent if its original component is tainted
5065 barrier instanceof IntentWithTaintedComponent
5166 }
5267
53- override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
68+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
5469 // Intents being built with the copy constructor from the original Intent are discarded too
5570 exists ( ClassInstanceExpr cie |
5671 cie .getConstructedType ( ) instanceof TypeIntent and
@@ -61,29 +76,31 @@ private class SameIntentBeingRelaunchedConfiguration extends DataFlow2::Configur
6176 }
6277}
6378
79+ private module SameIntentBeingRelaunchedFlow = DataFlow:: Make< SameIntentBeingRelaunchedConfig > ;
80+
6481/** An `Intent` with a tainted component. */
6582private class IntentWithTaintedComponent extends DataFlow:: Node {
6683 IntentWithTaintedComponent ( ) {
67- exists ( IntentSetComponent setExpr , TaintedIntentComponentConf conf |
84+ exists ( IntentSetComponent setExpr |
6885 setExpr .getQualifier ( ) = this .asExpr ( ) and
69- conf . hasFlowTo ( DataFlow:: exprNode ( setExpr .getSink ( ) ) )
86+ TaintedIntentComponentFlow :: hasFlowTo ( DataFlow:: exprNode ( setExpr .getSink ( ) ) )
7087 )
7188 }
7289}
7390
7491/**
7592 * A taint tracking configuration for tainted data flowing to an `Intent`'s component.
7693 */
77- private class TaintedIntentComponentConf extends TaintTracking3 :: Configuration {
78- TaintedIntentComponentConf ( ) { this = "TaintedIntentComponentConf" }
94+ private module TaintedIntentComponentConfig implements DataFlow :: ConfigSig {
95+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
7996
80- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
81-
82- override predicate isSink ( DataFlow:: Node sink ) {
97+ predicate isSink ( DataFlow:: Node sink ) {
8398 any ( IntentSetComponent setComponent ) .getSink ( ) = sink .asExpr ( )
8499 }
85100}
86101
102+ private module TaintedIntentComponentFlow = TaintTracking:: Make< TaintedIntentComponentConfig > ;
103+
87104/** A call to a method that changes the component of an `Intent`. */
88105private class IntentSetComponent extends MethodAccess {
89106 int sinkArg ;
0 commit comments