Description
allowFileAccess controls local file access and allowContentAccess controls access to content-provider URIs. For scripts running in a file page, allowFileAccessFromFileURLs permits access to other files and allowUniversalAccessFromFileURLs permits access to other origins.
Potential impact
- Disclosure of local files or content URI data.
- Bypass of permission boundaries through WebView.
- Exposure of sensitive information when combined with XSS.
Remediation
- Disable file and content access you do not need. Keep external web content in a separate WebView from pages that need local files.
- Allow only required URIs, validate input and use Content Security Policy to restrict which resources a page can load.
Examples
Before
java
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
After
java
webView.getSettings().setAllowFileAccess(false);
webView.getSettings().setAllowContentAccess(false);
webView.getSettings().setAllowUniversalAccessFromFileURLs(false);
The revised settings disable file-system access with setAllowFileAccess(false), content URI access with setAllowContentAccess(false), and universal access from file pages. Bundled resources under file:///android_asset and file:///android_res remain accessible regardless of the file-access setting.