简体   繁体   English

您的应用正在使用易受跨应用脚本攻击的 WebView Android PlayStore 警告

[英]Your app(s) are using a WebView that is vulnerable to cross-app scripting Android PlayStore Warning

In whistleIt we load static url in webview and handle notification and other things but in last 2 versions we receive warning在 whistleIt 中,我们在 webview 中加载静态 url 并处理通知和其他事情,但在最后 2 个版本中我们收到警告

Your app(s) are using a WebView that is vulnerable to cross-app scripting您的应用程序正在使用易受跨应用程序脚本攻击的 WebView

We are not using android:exported=”true“ in our activity also i am using below code in Webview activity but still getting warning email.我们没有在我们的活动中使用android:exported=”true“我也在 Webview 活动中使用以下代码,但仍然收到警告电子邮件。

<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />

what should i do now so our warning will get removed?我现在应该怎么做才能消除我们的警告?

Please add this line of code in your project manifest.xml请在您的项目 manifest.xml 中添加这行代码

<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
 android:value="true" />

according to https://support.google.com/faqs/answer/9084685?hl=en-GB根据https://support.google.com/faqs/answer/9084685?hl=en-GB

you can do 2 things你可以做两件事

1 Ensure that affected activities are not exported 1 确保不出口受影响的活动

Find any Activities with affected WebViews.查找任何具有受影响 WebView 的活动。 If these Activities do not need to take Intents from other apps you can set android:exported=false for the Activities in your Manifest.如果这些活动不需要从其他应用程序获取意图,您可以为清单中的活动设置 android:exported=false。 This ensures that malicious apps cannot send harmful inputs to any WebViews in these activities.这可确保恶意应用程序无法向这些活动中的任何 WebView 发送有害输入。

2 Protect WebViews in exported activities 2 在导出的活动中保护 WebView

If you want to set an Activity with an affected WebView as exported then we recommend that you make the following changes:如果要将具有受影响 WebView 的 Activity 设置为导出,我们建议您进行以下更改:

1 Protect calls to evaluateJavascript and loadUrl 1 保护对evaluateJavascript 和loadUrl 的调用

Ensure that parameters to evaluateJavascript are always trusted.确保用于评估Javascript 的参数始终受信任。 Calling evaluateJavascript using unsanitised input from untrusted intents lets attackers execute harmful scripts in the affected WebView.使用来自不受信任意图的未经处理的输入调用evaluateJavascript 允许攻击者在受影响的WebView 中执行有害脚本。 Similarly, calling loadUrl with unsanitised input containing javascript: scheme URLs lets attackers execute harmful scripts.类似地,使用包含 javascript: scheme URL 的未经处理的输入调用 loadUrl 可以让攻击者执行有害脚本。

2 Prevent unsafe file loads 2 防止不安全的文件加载

Ensure that affected WebViews cannot load the cookie database.确保受影响的 WebView 无法加载 cookie 数据库。 WebViews that load unsanitised file:// URLs from untrusted intents can be attacked by malicious apps in two steps.从不受信任的意图加载未经处理的 file:// URL 的 WebView 可以通过两个步骤受到恶意应用程序的攻击。 First step: a malicious web page can write tags into the cookies database.第一步:恶意网页可以将标签写入cookies数据库。 Second step: this modified cookies database file can be loaded if a malicious app sends an intent with a file:// URL pointing to your WebView cookies database, or if the malicious web page itself redirects your WebView to the file URL.第二步:如果恶意应用发送带有指向您的 WebView cookie 数据库的 file:// URL 的意图,或者如果恶意网页本身将您的 WebView 重定向到文件 URL,则可以加载此修改后的 cookie 数据库文件。 The malicious恶意的

stored in the cookies database will load and execute, which can steal session information. 存储在cookies数据库中会加载并执行,可以窃取会话信息。

You can ensure that affected WebViews cannot load the WebView cookies database in three ways.您可以通过三种方式确保受影响的 WebView 无法加载 WebView cookie 数据库。

  1. Disable all file access.禁用所有文件访问。
  2. Make sure that the WebView only loads file:// URLs and verify that any loaded file:// URLs point to safe files.确保 WebView 仅加载 file:// URL 并验证所有加载的 file:// URL 是否指向安全文件。 Note that an attacker can use a symbolic link to trick checks on the URL path.请注意,攻击者可以使用符号链接来欺骗检查 URL 路径。 To prevent such an attack, make sure that you check the canonical path of any untrusted file:// URL before loading instead of just checking the URL path.为防止此类攻击,请确保在加载之前检查任何不受信任的 file:// URL 的规范路径,而不仅仅是检查 URL 路径。
  3. If you want to allow both http:// URLs and file:// URLs, implement the file:// URL verification using shouldOverrideUrlLoading and shouldInterceptRequest in WebViewClient.如果要同时允许 http:// URL 和 file:// URL,请在 WebViewClient 中使用 shouldOverrideUrlLoading 和 shouldInterceptRequest 实现 file:// URL 验证。 This ensures that all URLs loaded into WebView are verified, not limited to the URLs directly provided to a loadUrl() function call.这确保所有加载到 WebView 的 URL 都经过验证,不限于直接提供给 loadUrl() 函数调用的 URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM