Мы недавно получили электронное письмо от Google относительно нашего опубликованного приложения в магазине Google Play.
Ниже приводится то, что они заявили в письме.
Hello Google Play Developer,
The apps listed at the end of this email have a WebView File-based Cross-Site Scripting issue which can allow a malicious network to access any file accessible to your app.
What's happening
One or more of your apps contain a File-based Cross-Site Scripting vulnerability that must be fixed. Please refer to the notice on your Play Console for the deadline to fix this vulnerability. After this deadline, updates to affected apps will be blocked if the vulnerability is still present. Your published APK version will remain unaffected.
Action required
WebViews with WebSettings that set either setAllowFileAccessFromFileURLs orsetAllowUniversalAccessFromFileURLs to true must not load any untrusted web content. This includes content from trusted domains that is loaded over HTTP. Malicious web content or networks can inject scripts to redirect the WebView to a malicious file and launch a Cross-Site Scripting attack to access private local files or cookies.
You should prevent this vulnerability in one of the following ways:
Ensure that WebViews do not have dangerous settings - You can update yourandroid:targetSdkVersion in your Manifest to be at least 16 to use safe default settings for WebView. Otherwise, you can callsetAllowFileAccessFromFileURLs(false) andsetAllowUniversalAccessFromFileURLs(false) to ensure that their WebViews are safe.
Ensure that WebViews cannot load file:// URLs or execute JavaScript - You can call setAllowFileAccess(false) to prevent WebViews with dangerous settings from loading file:// URLs or call setJavaScriptEnabled(false) to prevent WebViews with dangerous settings from executing JavaScript code.
Ensure that WebViews with dangerous settings not load untrusted web content - If a WebView needs to enable these dangerous settings, you must ensure that it does not load untrusted web content.
We recommend that you also ensure that WebViews with dangerous settings do not load web content over HTTP. You can set android:usesCleartextTraffic=false or set aNetwork Security Config that disallows HTTP traffic in your Manifest. Alternatively, you can ensure that any WebViews with dangerous settings do not load any URLs with HTTP schemes.
Lastly, you should also ensure that WebViews with dangerous settings do not load URLs obtained from untrusted sources.
Next steps
Update your app using the steps highlighted above.
Sign in to your Play Console and submit the updated version of your app.
Check back after five hours; we will show a warning message if the app hasn't been updated correctly.
Теперь проблема в том, что мы на самом делезагружает локальные html-файлы в наше приложение, которое требует некоторого взаимодействия с javascript, а также доступа к локальным ресурсам, поэтому нам необходимо сохранить следующее разрешение true.
callsetAllowFileAccessFromFileURLs (true).setAllowUniversalAccessFromFileURLs (ложь).setJavaScriptEnabled (true).
Что может быть возможным решением для этого и как я могу безопасно предотвратить уязвимости в моем приложении?