Visitar URL original
Java: Android WebView Content Access Query by egregius313 · Pull Request #11283 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20221122042307/https://github.com/github/codeql/pull/11283
Skip to content
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: Android WebView Content Access Query #11283

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

egregius313
Copy link
Contributor

@egregius313 egregius313 commented Nov 16, 2022

Added a query for WebSettings#setAllowContentAccess, which can expose sensitive information.

@egregius313 egregius313 requested a review from a team as a code owner Nov 16, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 16, 2022

QHelp previews:

java/ql/src/Security/CWE/CWE-200/AndroidWebViewSettingsContentAccess.qhelp

Android WebSettings content access

Android can provide access to content providers within a WebView using the setAllowContentAccess setting.

Allowing access to content providers via content:// URLs may allow JavaScript to access protected content.

Recommendation

If your app does not require access to the content:// URL functionality, you should explicitly disable the setting by calling setAllowContentAccess(false) on the settings of the WebView.

Example

In the following (bad) example, access to content:// URLs is explicitly allowed.

WebSettings settings = webview.getSettings();

settings.setAllowContentAccess(true);

References

Copy link
Contributor

@atorralba atorralba left a comment •

Hey @egregius313, I added a couple comments. Let's review this again once you've considered those and completed the qhelp. Also, this needs a change note.


from MethodAccess ma
where
ma.getMethod() instanceof AllowContentAccessMethod and
Copy link
Contributor

@atorralba atorralba Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enabled by default, right? I think the query should take that into consideration and use dataflow to identify WebSettings instances that don't set this to false explicitly.

* @id java/android-websettings-content-access
* @problem.severity warning
* @security-severity 6.5
* @precision high
Copy link
Contributor

@atorralba atorralba Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this won't always be a security problem, let's get this down to medium so that the query becomes opt-in for users that want to see more results.

@egregius313 egregius313 marked this pull request as draft Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants