-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: Unsafe resource loading in Android webview #3706
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
Conversation
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
524615f to
9030834
Compare
smowton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, sorry for the delay! Quite a few comments I'm afraid but they should all be quite quick and easy to apply.
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.java
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
smowton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your fast response -- a few more comments to look at, but this is looking good
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
|
Regarding the text about two vulnerabilities, let me check my understanding: "Vulnerability introduced by WebViews with JavaScript enabled and remote inputs allowed" I think refers to the situation where (a) the URL might be controlled by an attacker and (b) Javascript is switched on, but neither of Then "High precision vulnerability when allowing universal resource access is also enabled" refers to the situation where additionally one of If so then I suggest "universal" -> "cross-origin" since "Universal" is just one of the two access settings we care about, and "High precision" -> "A more severe", since we have the same imprecision level but the consequences are worse. |
smowton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This incorporates my suggested reword (please apply it elsewhere if this text is duplicated), plus avoids the CodeQL help weighing in on Droid vs. iPhone :)
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
smowton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Let's sort out the doc comments, then good to merge
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
|
BTW don't worry about the failing code scanning job, there was an outage recently and it should clear on your next push. Rebase on latest |
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql
Outdated
Show resolved
Hide resolved
|
Thanks a lot for all the help from @smowton and @aschackmull with this PR. |
|
@luchua-bc please rebase the branch on latest |
java/ql/test/stubs/google-android-9.0.0/android/content/Context.java
Outdated
Show resolved
Hide resolved
|
This still needs a rebase: |
|
Thanks @smowton. Probably the issue was caused by that I haven't merged with master for a long time. I will refresh my copy. |
In any case, you can learn about that in your own time -- this will land in #4483. |
bd451fe to
edba5d9
Compare
2f0fea9 to
bd451fe
Compare
|
Merged as #4483 |
Android WebViews that allow loading URLs controlled by external inputs and whose JavaScript interface is enabled are potentially vulnerable to cross-site scripting and sensitive resource disclosure attacks.
In addition, WebViews whose settings have setAllowFileAccessFromFileURLs or setAllowUniversalAccessFromFileURLs enabled must not load any untrusted web content since malicious scripts can launch cross-site scripting attacks, either accessing arbitrary local files including WebView cookies, session tokens, and private app data or even credentials used on arbitrary web sites.
This query detects the following two scenarios:
Please consider to merge the PR. Thanks.