Skip to content

Commit 987bfa6

Browse files
luchua-bcsmowton
authored andcommitted
Update condition check and qldoc
1 parent 8c2fddb commit 987bfa6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
3434
/**
3535
* Holds if `src` is a read of some Intent-typed method argument guarded by a check like
3636
* `requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS`, where `requestCode` is the first
37-
* argument to `Activity.onActivityResult`.
37+
* argument to `Activity.onActivityResult` and `REQUEST_CODE__SELECT_CONTENT_FROM_APPS` is
38+
* any request code in a call to `startActivityForResult(intent, code)`.
3839
*/
3940
override predicate isSource(DataFlow::Node src) {
4041
exists(
41-
AndroidActivityResultInput ai, AndroidFileIntentInput fi, ConditionBlock cb,
42-
VarAccess intentVar
42+
AndroidActivityResultInput ai, AndroidFileIntentInput fi, ConditionBlock cb, EQExpr ee,
43+
CompileTimeConstantExpr cc, VarAccess intentVar
4344
|
44-
cb.getCondition().getAChildExpr().(CompileTimeConstantExpr).getIntValue() =
45-
fi.getRequestCode() and
46-
cb.getCondition().getAChildExpr() = ai.getRequestCodeVar() and
45+
cb.getCondition() = ee and
46+
ee.hasOperands(ai.getRequestCodeVar(), cc) and
47+
cc.getIntValue() = fi.getRequestCode() and
4748
intentVar.getType() instanceof TypeIntent and
48-
cb.getBasicBlock() = intentVar.(Argument).getAnEnclosingStmt() and
49+
cb.controls(intentVar.getBasicBlock(), true) and
4950
src.asExpr() = intentVar
5051
)
5152
}

java/ql/test/experimental/query-tests/security/CWE-200/SensitiveAndroidFileLeak.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ edges
88
| FileService.java:25:42:25:50 | localPath : String | FileService.java:25:13:25:51 | makeParamsToExecute(...) [[]] : String |
99
| FileService.java:40:41:40:55 | params : Object[] | FileService.java:44:33:44:52 | (...)... : Object |
1010
| FileService.java:44:33:44:52 | (...)... : Object | FileService.java:45:53:45:59 | ...[...] |
11+
| LeakFileActivity2.java:15:13:15:18 | intent : Intent | LeakFileActivity2.java:16:26:16:31 | intent : Intent |
1112
| LeakFileActivity2.java:16:26:16:31 | intent : Intent | FileService.java:20:31:20:43 | intent : Intent |
1213
| LeakFileActivity.java:14:35:14:38 | data : Intent | LeakFileActivity.java:18:40:18:59 | contentIntent : Intent |
1314
| LeakFileActivity.java:18:40:18:59 | contentIntent : Intent | LeakFileActivity.java:19:31:19:43 | contentIntent : Intent |
@@ -24,6 +25,7 @@ nodes
2425
| FileService.java:40:41:40:55 | params : Object[] | semmle.label | params : Object[] |
2526
| FileService.java:44:33:44:52 | (...)... : Object | semmle.label | (...)... : Object |
2627
| FileService.java:45:53:45:59 | ...[...] | semmle.label | ...[...] |
28+
| LeakFileActivity2.java:15:13:15:18 | intent : Intent | semmle.label | intent : Intent |
2729
| LeakFileActivity2.java:16:26:16:31 | intent : Intent | semmle.label | intent : Intent |
2830
| LeakFileActivity.java:14:35:14:38 | data : Intent | semmle.label | data : Intent |
2931
| LeakFileActivity.java:18:40:18:59 | contentIntent : Intent | semmle.label | contentIntent : Intent |
@@ -32,5 +34,6 @@ nodes
3234
| LeakFileActivity.java:21:58:21:72 | streamsToUpload : Uri | semmle.label | streamsToUpload : Uri |
3335
| LeakFileActivity.java:21:58:21:82 | getPath(...) | semmle.label | getPath(...) |
3436
#select
37+
| FileService.java:45:53:45:59 | ...[...] | LeakFileActivity2.java:15:13:15:18 | intent : Intent | FileService.java:45:53:45:59 | ...[...] | Leaking arbitrary Android file from $@. | LeakFileActivity2.java:15:13:15:18 | intent | this user input |
3538
| FileService.java:45:53:45:59 | ...[...] | LeakFileActivity2.java:16:26:16:31 | intent : Intent | FileService.java:45:53:45:59 | ...[...] | Leaking arbitrary Android file from $@. | LeakFileActivity2.java:16:26:16:31 | intent | this user input |
3639
| LeakFileActivity.java:21:58:21:82 | getPath(...) | LeakFileActivity.java:14:35:14:38 | data : Intent | LeakFileActivity.java:21:58:21:82 | getPath(...) | Leaking arbitrary Android file from $@. | LeakFileActivity.java:14:35:14:38 | data | this user input |

0 commit comments

Comments
 (0)