MASTG-TEST-0036: 测试强制更新
此测试即将更新
此测试目前可使用,但将作为新的 OWASP MASTG v2 指南 的一部分进行全面修订。
请提交PR来帮助我们: MASTG v1->v2 MASTG-TEST-0036: 测试强制更新 (android)
概述¶
要测试强制更新,您需要检查应用程序是否支持应用内更新,并验证是否正确强制执行,以便用户在不先更新的情况下无法继续使用该应用程序。
静态分析¶
下面的代码示例展示了一个应用更新的例子
//Part 1: check for update
// Creates instance of the manager.
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfo = appUpdateManager.getAppUpdateInfo();
// Checks that the platform will allow the specified type of update.
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
// For a flexible update, use AppUpdateType.FLEXIBLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
//...Part 2: request update
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
AppUpdateType.IMMEDIATE,
// The current activity making the update request.
this,
// Include a request code to later monitor this update request.
MY_REQUEST_CODE);
//...Part 3: check if update completed successfully
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (myRequestCode == MY_REQUEST_CODE) {
if (resultCode != RESULT_OK) {
log("Update flow failed! Result code: " + resultCode);
// If the update is cancelled or fails,
// you can request to start the update again in case of forced updates
}
}
}
//..Part 4:
// Checks that the update is not stalled during 'onResume()'.
// However, you should execute this check at all entry points into the app.
@Override
protected void onResume() {
super.onResume();
appUpdateManager
.getAppUpdateInfo()
.addOnSuccessListener(
appUpdateInfo -> {
...
if (appUpdateInfo.updateAvailability()
== UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
// If an in-app update is already running, resume the update.
manager.startUpdateFlowForResult(
appUpdateInfo,
IMMEDIATE,
this,
MY_REQUEST_CODE);
}
});
}
}
来源: https://developer.android.com.cn/guide/app-bundle/in-app-updates
动态分析¶
为了测试正确的更新:尝试下载具有安全漏洞的应用程序的旧版本,可以通过开发人员的发布或使用第三方应用商店。接下来,验证您是否可以在不更新的情况下继续使用该应用程序。如果给出了更新提示,请验证您是否仍然可以通过取消提示或通过正常应用程序使用绕过它来使用该应用程序。这包括验证后端是否会停止调用易受攻击的后端,以及/或易受攻击的应用程序版本本身是否被后端阻止。最后,尝试在使用MIMT代理拦截其流量时修改应用程序的版本号,并观察后端如何响应(包括是否记录了更改)。