English
Recently, we received feedback from developers that the uni-app/5+ App project was packaged as an Android platform App and submitted to security platforms such as Tencent Cloud, Baidu Cloud, and Ai Encryption. The vulnerability risk was detected. We have been continuously following up on the feedback vulnerability risk. And actively looking for solutions to fix.
首先我们需要理解漏洞风险并不代表真实存在安全漏洞,比如WebView远程代码执行漏洞,仅在Android4.2及以下版本系统存在,目前HBuilderX发现App最低要求版本Android4.4;比如Activity、Service、Receiver等组件导出风险,有些功能依赖的组件必须设置为导出,实际上并不存在安全问题。而安全平台会把所有可能存在的漏洞或风险都列出来,很多安全问题都可能是误报或夸大了安全漏洞的隐患。
因此对于存在漏洞风险问题的基本解决方案是使用APK加固
,推荐uni安全加固其背后支持对接多个加固服务商,包括腾讯云和蚂蚁小程序云
If the hardening still cannot solve the problem, or the security platform requires testing before hardening, please post feedback on the official forum ask, and add the topics as "Security Vulnerability", "Security Test", upload the complete security test report and the tested apk file.
对于反馈的安全漏洞问题我们会根据风险等级,优先解决高风险和中风险问题 For low-risk issues, in theory, the security quality of the application will not be affected, so low-risk security vulnerabilities are usually not addressed.
WebView File Domain Same Origin Policy Bypass Vulnerability
issueAndroid platform WebView control cross-domain access high-risk vulnerability
problemWebview bypass certificate verification vulnerability
problem, it needs to be configured to take effectAndroid hostname\certificate weak verification risk
problem, which needs to be configured to take effectThe following are some common risk vulnerability solutions
修复方案 HBuilderX 3.1.14+ version adds untrustedca node configuration whether to allow the use of untrusted certificates. In the project manifest.json, configure "untrustedca" as "refuse" under the "app-plus"->"ssl" node. The example is as follows:
"app-plus": { //5+ App项目对应节点名称为"plus"
"ssl": {
"untrustedca": "refuse"
},
// ...
}
untrustedca属性值域说明:
风险描述 APP's Activity, Service, Receiver and other components can be set in AndroidManifest.xml through the configuration attribute android:exported It is private (false) or public (true). When it is set to public, the component is considered to be exported and can be accessed by any component of any other program. The exported components may be maliciously called by third-party apps, may return private information to malicious apps, and cause data leakage; may cause app crashes, resulting in denial of service and other vulnerabilities.
修复方案 HBuilderX 3.1.14+ has set all the components in the code managed by DCloud that do not need to be accessed externally as private (that is, the android:exported attribute value is set to false), and only the components that need to be accessed externally, such as the App entry Activity ( io.dcloud.PandoraEntry) is set to public.
另外需要注意,一些三方SDK因为功能需要会将其组件设置为对外导出,如下:
风险描述 The signature certificate is the only identifier for the identity of the app developer. If the program does not verify the signature certificate, it may be decompiled and repackaged and re-signed with another signature certificate. If the re-signed app can be started normally, it may cause the app to be counterfeited and pirated, affecting its legitimate income, and may even be added with phishing code, virus code, and malicious code, resulting in the leakage of user sensitive information or malicious attacks.
修复方案 对APK进行加固,推荐uni安全加固其背后支持对接多个加固服务商,包括腾讯云和蚂蚁小程序云。
风险描述 The native APK packaged as an App can be decompiled to obtain the Java source code.
修复方案 对APK进行加固,推荐uni安全加固其背后支持对接多个加固服务商,包括腾讯云和蚂蚁小程序云。
风险描述 This vulnerability can be used to achieve remote arbitrary code execution attacks based on client capabilities. WebView remote code execution vulnerability triggering prerequisites:
修复方案 The Android platform that HBuilderX publishes to the App supports at least Android 4.4, that is, minSdkVersion is greater than or equal to 19. That is to say, this vulnerability does not exist in Android4.4 and above. If your project is configured with minSdkVersion lower than 19, please refer to [https://ask.dcloud.net.cn/article/193](https:/ /ask.dcloud.net.cn/article/193) modified.
风险描述 When the application encrypts and decrypts, it uses the key hard-coded in the program. The attacker can easily decrypt the APP communication data by obtaining the key through decompilation.
修复方案 This problem has been fixed in HBuilderX 3.1.14+ version, and all the keys used in the internal logic have been obfuscated and encrypted.
风险描述 The SO file is the dynamic link library file contained in the APK. Android uses the NDK technology to compile the core code implemented by the C/C++ language into the SO library file for the Java layer to call. The cracked SO file may lead to the disclosure of the core functional codes and algorithms of the application. Using core functions and algorithms, attackers can easily capture sensitive client data and decrypt it, resulting in user privacy leakage or direct property loss
修复方案 对APK中的SO文件进行加固保护,推荐uni安全加固其背后支持对接多个加固服务商,包括腾讯云和蚂蚁小程序云。
风险描述 What makes StrandHogg unique is that it doesn't require rooting to enable sophisticated attacks, it exploits a weakness in Android's multitasking system to carry out a powerful attack that allows malicious apps to masquerade as any other app on the device program. The exploit is based on an Android control called "taskAffinity" that allows any application, including malicious applications, to freely adopt any identity it desires in the multitasking system.
修复方案
该漏洞已于2020.4.1的安全补丁中修复(涵盖Android 8.0 / 8.1 / 9.0+)。由于已经通过系统补丁封堵。理论上该漏洞不会对高版本系统的手机设备构成威胁。
而app客户端开发并没有彻底规避该漏洞的方案。各检测平台推荐配置android:taskAffinity=“”
,但仅是临时方案。但该方案会导致应用运行到android11+系统设备时任务堆栈窗口变成两个的问题。
Due to a bug in the android:taskAffinity=""
configuration! So we don't configure it this way by default. But there are cloud packaging configuration options for developers. It is up to the developer to decide whether to temporarily block the vulnerability. details as follows:
hasTaskAffinity
in the project's manifest.json according to the app type. true means to configure android:taskAffinity=""
, false not to configure. Default is false "app-plus" : {
"distribute" : {
"android" : {
...
...
"hasTaskAffinity": true
}
}
}
"plus" : {
"distribute" : {
"google" : {
...
...
"hasTaskAffinity": true
}
}
}
风险描述 从Nougat(Android 7) 一个名为“Network Security Configuration'的新安全功能也随之而来。如果应用程序的 SDK高于或等于24,则只有系统证书才会被信任。Android Network Security Configuration 功能提供了一个简单的层,用来保护应用程序在未加密的明文中意外传输的敏感数据。可以针对特定域和特定应用配置这些设置。如缺少networkSecurityConfig 特性,应用程序将使用系统默认安全配置,致使应用程序在不安全的定制 ROM 上运行时可能遭受恶意网络攻击。
修复方案
network_security_config.xml
配置文件network_security_config.xml
文件拷贝到应用资源nativeResources\android\res\xml
目录下AndroidManifest.xml
中application节点!添加networkSecurityConfig属性配置。配置参考如下:<application android:networkSecurityConfig="@xml/network_security_config"
... >
...
</application>