@@ -14,7 +14,7 @@ import java
1414import semmle.code.java.controlflow.Guards
1515import AndroidFileIntentSink
1616import AndroidFileIntentSource
17- import DataFlow :: PathGraph
17+ import AndroidFileLeakFlow :: PathGraph
1818
1919private predicate startsWithSanitizer ( Guard g , Expr e , boolean branch ) {
2020 exists ( MethodAccess ma |
@@ -25,16 +25,14 @@ private predicate startsWithSanitizer(Guard g, Expr e, boolean branch) {
2525 )
2626}
2727
28- class AndroidFileLeakConfig extends TaintTracking:: Configuration {
29- AndroidFileLeakConfig ( ) { this = "AndroidFileLeakConfig" }
30-
28+ module AndroidFileLeakConfig implements DataFlow:: ConfigSig {
3129 /**
3230 * Holds if `src` is a read of some Intent-typed variable guarded by a check like
3331 * `requestCode == someCode`, where `requestCode` is the first
3432 * argument to `Activity.onActivityResult` and `someCode` is
3533 * any request code used in a call to `startActivityForResult(intent, someCode)`.
3634 */
37- override predicate isSource ( DataFlow:: Node src ) {
35+ predicate isSource ( DataFlow:: Node src ) {
3836 exists (
3937 OnActivityForResultMethod oafr , ConditionBlock cb , CompileTimeConstantExpr cc ,
4038 VarAccess intentVar
@@ -50,9 +48,9 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
5048 }
5149
5250 /** 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 }
5452
55- override predicate isAdditionalTaintStep ( DataFlow:: Node prev , DataFlow:: Node succ ) {
53+ predicate isAdditionalFlowStep ( DataFlow:: Node prev , DataFlow:: Node succ ) {
5654 exists ( MethodAccess aema , AsyncTaskRunInBackgroundMethod arm |
5755 // fileAsyncTask.execute(params) will invoke doInBackground(params) of FileAsyncTask
5856 aema .getQualifier ( ) .getType ( ) = arm .getDeclaringType ( ) and
@@ -72,12 +70,14 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
7270 )
7371 }
7472
75- override predicate isSanitizer ( DataFlow:: Node node ) {
73+ predicate isBarrier ( DataFlow:: Node node ) {
7674 node = DataFlow:: BarrierGuard< startsWithSanitizer / 3 > :: getABarrierNode ( )
7775 }
7876}
7977
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 )
8282select sink .getNode ( ) , source , sink , "Leaking arbitrary Android file from $@." , source .getNode ( ) ,
8383 "this user input"
0 commit comments