@@ -8,9 +8,11 @@ import semmle.code.java.dataflow.TaintTracking3 |
8 | 8 | import semmle.code.java.security.AndroidIntentRedirection |
9 | 9 |
|
10 | 10 | /** |
| 11 | + * DEPRECATED: Use `IntentRedirectionFlow` instead. |
| 12 | + * |
11 | 13 | * A taint tracking configuration for tainted Intents being used to start Android components. |
12 | 14 | */ |
13 | | -class IntentRedirectionConfiguration extends TaintTracking::Configuration { |
| 15 | +deprecated class IntentRedirectionConfiguration extends TaintTracking::Configuration { |
14 | 16 | IntentRedirectionConfiguration() { this = "IntentRedirectionConfiguration" } |
15 | 17 |
|
16 | 18 | override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
@@ -26,31 +28,44 @@ class IntentRedirectionConfiguration extends TaintTracking::Configuration { |
26 | 28 | } |
27 | 29 | } |
28 | 30 |
|
| 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 | + |
29 | 46 | /** |
30 | 47 | * A sanitizer for sinks that receive the original incoming Intent, |
31 | 48 | * since its component cannot be arbitrarily set. |
32 | 49 | */ |
33 | 50 | private class OriginalIntentSanitizer extends IntentRedirectionSanitizer { |
34 | | - OriginalIntentSanitizer() { any(SameIntentBeingRelaunchedConfiguration c).hasFlowTo(this) } |
| 51 | + OriginalIntentSanitizer() { SameIntentBeingRelaunchedFlow::hasFlowTo(this) } |
35 | 52 | } |
36 | 53 |
|
37 | 54 | /** |
38 | 55 | * Data flow configuration used to discard incoming Intents |
39 | 56 | * flowing directly to sinks that start Android components. |
40 | 57 | */ |
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 } |
43 | 60 |
|
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 } |
47 | 62 |
|
48 | | - override predicate isBarrier(DataFlow::Node barrier) { |
| 63 | + predicate isBarrier(DataFlow::Node barrier) { |
49 | 64 | // Don't discard the Intent if its original component is tainted |
50 | 65 | barrier instanceof IntentWithTaintedComponent |
51 | 66 | } |
52 | 67 |
|
53 | | - override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { |
| 68 | + predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { |
54 | 69 | // Intents being built with the copy constructor from the original Intent are discarded too |
55 | 70 | exists(ClassInstanceExpr cie | |
56 | 71 | cie.getConstructedType() instanceof TypeIntent and |
@@ -61,29 +76,31 @@ private class SameIntentBeingRelaunchedConfiguration extends DataFlow2::Configur |
61 | 76 | } |
62 | 77 | } |
63 | 78 |
|
| 79 | +private module SameIntentBeingRelaunchedFlow = DataFlow::Make<SameIntentBeingRelaunchedConfig>; |
| 80 | + |
64 | 81 | /** An `Intent` with a tainted component. */ |
65 | 82 | private class IntentWithTaintedComponent extends DataFlow::Node { |
66 | 83 | IntentWithTaintedComponent() { |
67 | | - exists(IntentSetComponent setExpr, TaintedIntentComponentConf conf | |
| 84 | + exists(IntentSetComponent setExpr | |
68 | 85 | setExpr.getQualifier() = this.asExpr() and |
69 | | - conf.hasFlowTo(DataFlow::exprNode(setExpr.getSink())) |
| 86 | + TaintedIntentComponentFlow::hasFlowTo(DataFlow::exprNode(setExpr.getSink())) |
70 | 87 | ) |
71 | 88 | } |
72 | 89 | } |
73 | 90 |
|
74 | 91 | /** |
75 | 92 | * A taint tracking configuration for tainted data flowing to an `Intent`'s component. |
76 | 93 | */ |
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 } |
79 | 96 |
|
80 | | - override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } |
81 | | - |
82 | | - override predicate isSink(DataFlow::Node sink) { |
| 97 | + predicate isSink(DataFlow::Node sink) { |
83 | 98 | any(IntentSetComponent setComponent).getSink() = sink.asExpr() |
84 | 99 | } |
85 | 100 | } |
86 | 101 |
|
| 102 | +private module TaintedIntentComponentFlow = TaintTracking::Make<TaintedIntentComponentConfig>; |
| 103 | + |
87 | 104 | /** A call to a method that changes the component of an `Intent`. */ |
88 | 105 | private class IntentSetComponent extends MethodAccess { |
89 | 106 | int sinkArg; |
|