微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

您的应用容易受到意图重定向的影响

如何解决您的应用容易受到意图重定向的影响

当我在 Google Play 商店更新我的应用程序时,我收到了以下邮件

我们审核了您的应用,发现您的应用使用的软件 包含用户的安全漏洞。具有这些功能的应用 漏洞可能会暴露用户信息或损坏用户的设备, 并且可能被视为违反我们的恶意行为 政策。

以下是问题列表和对应的 APK 版本 在您最近提交的文件中检测到。请将您的应用迁移到 尽快使用更新的软件并增加版本 升级后的 APK 编号。

意图重定向

您的应用容易受到意图重定向的影响。

下面是我的 build.gradle 文件

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

  android {
    compileSdkVersion 28
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

defaultConfig {
    applicationId "......."
    minSdkVersion 19
    targetSdkVersion 29
    versionCode 7
    versionName "1.0.7"
    multiDexEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
    }
}

}

dependencies {
    
implementation filetree(dir: 'libs',include: ['*.jar'])

implementation 'com.amazonaws:aws-android-sdk-ddb:2.17.0'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.17.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.smarteist:autoimageslider:1.3.7'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places:2.3.0'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
implementation 'com.google.android:flexBox:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.wang.avi:library:2.1.3'  // Loading Animation
implementation 'com.google.android.gms:play-services-auth-api-phone:17.4.0'
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.1'
implementation 'com.razorpay:checkout:1.5.16'
implementation 'com.paytm:pgplussdk:1.4.3'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
implementation 'com.google.firebase:firebase-analytics:18.0.1'
implementation 'io.sentry:sentry-android:3.1.0'

}

我已经在 Android 清单中将 android:exported 更改为 false 并且还添加了 getPackageName if 检查我的所有 getIntent() 方法

解决方法

过去,我的应用也收到过此警告。 实际上,他们调查了您的代码并发现了这种模式:

Intent intent = getIntent();
Intent forward = (Intent) intent.getParcelableExtra(“key”);
startActivity(forward);

我不知道这是如何工作的,但你应该简单地避免这种模式,即 - 不要在parcelable中转发意图。可能这种模式存在于您的某个依赖项中,那么您遇到了一些问题...

例如,如果您将意图从一个组件转移到另一个组件,您可以将其临时存储在 SharedPreferences 中,但您可以使用意图的字符串表示代替可分割,这有一些限制,但在许多情况下都有效。
在一项活动中:

Intent targetIntent = ...
String representation = targetIntent.toUri(0);
SharedPreferences prefs = getSharedPreferences("intentStore",MODE_PRIVATE);
String key = UUID.randomUUID().toString();
prefs.edit().putString(key,representation).apply();

Intent startIntent = new Intent(this,ActivityB.class);
startIntent.putExtra("intentKey",key);
startActivity(startIntent);

在ActivityB中处理意图:

String key = getIntent().getStringExtra("intentKey");
SharedPreferences prefs = getSharedPreferences("intentStore",MODE_PRIVATE);
String representation = prefs.getString(key,null);
// may be need check on null
Intent targetIntent = null;
try {
   targetIntent = Intent.parseUri(representation,Intent.URI_ALLOW_UNSAFE);
} catch (URISyntaxException e) {
   e.printStackTrace();
}

// handle targetIntent
...

Intent.URI_ALLOW_UNSAFE 如果您在意图中使用某些标志来提供某些权限(例如对文档 uri 的写入权限),则需要。 可能您需要清理 activityB onDestroy 方法中的“intentStore”偏好设置。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。