-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: CWE-200 - Query to detect exposure of sensitive information from android file intent #6567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: CWE-200 - Query to detect exposure of sensitive information from android file intent #6567
Conversation
java/ql/src/experimental/Security/CWE/CWE-200/AndroidFileIntentSource.qll
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/AndroidFileIntentSink.qll
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
|
This mostly looks good now, just resolving what we do with the android class models, which intersect with a few other PRs currently in flight, with the team working on droid. |
|
Thanks @smowton for the update and all your help with this PR. |
|
Note there are test failures |
|
Failing:
|
|
Hi @smowton, I tested the query on my staging server and the test passed so the CodeQL version is identical to my local copy. As the link shows a 404 "page not found" error, probably because it's an internal page, I cannot see details of "Java Language Tests (GitHub Actions)". Would you please shed some light on what is wrong? Thanks. |
2b8665a to
16a89ff
Compare
|
Pushed test fixes; some were due to a new feature introduced last week that requires a rebase on |
|
Also removed the CSV models of AsyncTask, which are too complicated to represent in that form anyway. |
java/ql/src/experimental/Security/CWE/CWE-200/AndroidFileIntentSource.qll
Outdated
Show resolved
Hide resolved
|
In fact there's quite a few of the modelled methods that aren't used in this PR: do you intend to only track exploitable data types, i.e. mostly strings? Or any sort of influence over the Intent? If it's the former, the int |
|
I intend to only track exploitable data types, i.e. mostly strings. However, as an invocation can be: I added those methods since I think they can propagate the taint. They shall be harmless. |
|
Oh I see-- these are actually fluent methods, and should be modelled like
The use of There's no need to add those edges here because we have a more complete model of Intent intended to land this week at which point I'll edit this PR to remove it, but in future |
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Show resolved
Hide resolved
|
Thanks @smowton for the explanation and the offer to modify the query and merge with the new intent model to be released. I will use fluent methods for new queries in the future. |
|
|
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/AndroidFileIntentSink.qll
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql
Outdated
Show resolved
Hide resolved
68f3378 to
4be2347
Compare
|
@luchua-bc I've updated this to use the shared Intent models; will merge this on green |
javaGenerated file changes for java
- Android,``android.*``,45,233,70,,,3,67,,,
+ Android,``android.*``,45,245,70,,,3,67,,,
- Totals,,143,5125,408,13,6,10,107,33,1,66
+ Totals,,143,5137,408,13,6,10,107,33,1,66
- android.content,8,27,61,,,,,,,,,,,,,8,,,,,,27,,4,57
+ android.content,8,27,73,,,,,,,,,,,,,8,,,,,,27,,8,65 |
|
Thanks @smowton a lot for all your help with this PR. |
|
Thanks @smowton a lot for the change of |
The Android API allows to start an activity in another mobile application and receive a result back. When starting an activity to retrieve a file from another application, missing input validation can lead to leaking of sensitive configuration file or user data because the intent is from the application itself that is allowed to access its protected data therefore bypassing the access control.
The query detects the exposure of sensitive information from android file intents and it also models the following common scenarios of file access in Android:
AsyncTaskto execute in the backgroundPlease consider to merge the PR. Thanks.