@@ -14,7 +14,7 @@ import java
14
14
import semmle.code.java.controlflow.Guards
15
15
import AndroidFileIntentSink
16
16
import AndroidFileIntentSource
17
- import DataFlow :: PathGraph
17
+ import AndroidFileLeakFlow :: PathGraph
18
18
19
19
private predicate startsWithSanitizer ( Guard g , Expr e , boolean branch ) {
20
20
exists ( MethodAccess ma |
@@ -25,16 +25,14 @@ private predicate startsWithSanitizer(Guard g, Expr e, boolean branch) {
25
25
)
26
26
}
27
27
28
- class AndroidFileLeakConfig extends TaintTracking:: Configuration {
29
- AndroidFileLeakConfig ( ) { this = "AndroidFileLeakConfig" }
30
-
28
+ module AndroidFileLeakConfig implements DataFlow:: ConfigSig {
31
29
/**
32
30
* Holds if `src` is a read of some Intent-typed variable guarded by a check like
33
31
* `requestCode == someCode`, where `requestCode` is the first
34
32
* argument to `Activity.onActivityResult` and `someCode` is
35
33
* any request code used in a call to `startActivityForResult(intent, someCode)`.
36
34
*/
37
- override predicate isSource ( DataFlow:: Node src ) {
35
+ predicate isSource ( DataFlow:: Node src ) {
38
36
exists (
39
37
OnActivityForResultMethod oafr , ConditionBlock cb , CompileTimeConstantExpr cc ,
40
38
VarAccess intentVar
@@ -50,9 +48,9 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
50
48
}
51
49
52
50
/** Holds if it is a sink of file access in Android. */
53
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof AndroidFileSink }
51
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof AndroidFileSink }
54
52
55
- override predicate isAdditionalTaintStep ( DataFlow:: Node prev , DataFlow:: Node succ ) {
53
+ predicate isAdditionalFlowStep ( DataFlow:: Node prev , DataFlow:: Node succ ) {
56
54
exists ( MethodAccess aema , AsyncTaskRunInBackgroundMethod arm |
57
55
// fileAsyncTask.execute(params) will invoke doInBackground(params) of FileAsyncTask
58
56
aema .getQualifier ( ) .getType ( ) = arm .getDeclaringType ( ) and
@@ -72,12 +70,14 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
72
70
)
73
71
}
74
72
75
- override predicate isSanitizer ( DataFlow:: Node node ) {
73
+ predicate isBarrier ( DataFlow:: Node node ) {
76
74
node = DataFlow:: BarrierGuard< startsWithSanitizer / 3 > :: getABarrierNode ( )
77
75
}
78
76
}
79
77
80
- from DataFlow:: PathNode source , DataFlow:: PathNode sink , AndroidFileLeakConfig conf
81
- where conf .hasFlowPath ( source , sink )
78
+ module AndroidFileLeakFlow = TaintTracking:: Global< AndroidFileLeakConfig > ;
79
+
80
+ from AndroidFileLeakFlow:: PathNode source , AndroidFileLeakFlow:: PathNode sink
81
+ where AndroidFileLeakFlow:: flowPath ( source , sink )
82
82
select sink .getNode ( ) , source , sink , "Leaking arbitrary Android file from $@." , source .getNode ( ) ,
83
83
"this user input"
0 commit comments