A WebView is allowed to read local files, to run its debugger, or to expose Java objects to scripts

tx0/java:webview-file-accessrecommendedwarningsecurity, cwe-200

What it finds

A WebView that loads content from elsewhere runs its scripts with whatever the app grants it. setAllowFileAccess(true) and the file URL settings let a page read the app's private files, setAllowContentAccess(true) its content providers, setWebContentsDebuggingEnabled(true) lets anyone with a cable inspect it, as the Android WebSettings documentation explains (CWE-200).

Reported is one of these settings switched on.

From the rule's source, webview_file_access.rs.

Example from the rule's tests
import android.webkit.WebSettings;import android.webkit.WebView; class Browser {  void setup(WebSettings settings) {    settings.setAllowFileAccess(true);tx0 reports: exposes local data    settings.setAllowUniversalAccessFromFileURLs(true);tx0 reports: exposes local data    WebView.setWebContentsDebuggingEnabled(true);tx0 reports: exposes local data or the debugger    settings.setAllowFileAccess(false);  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:webview-file-access" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:webview-file-access] reason="..."

tx0 explain tx0/java:webview-file-access shows the same in the terminal. Found a false positive? Report it.