Security fixes for PendingIntent related apis in LauncherApps

Allowing arbitrary activityOptions during the creation of PendingIntent
is a source of security vulnerability. This CL removes activityOptions
from the call-site.

Bug: 209607104
Test: manual
Change-Id: Id262b9a0de58d8834c85d925cf84bb44b8b99742
This commit is contained in:
Pinyao Ting
2022-02-02 17:23:02 +00:00
parent 84e5767fdf
commit ee3d464035
2 changed files with 8 additions and 6 deletions

View File

@@ -753,7 +753,7 @@ public class LauncherApps {
* {@link #startMainActivity(ComponentName, UserHandle, Rect, Bundle)}. * {@link #startMainActivity(ComponentName, UserHandle, Rect, Bundle)}.
* *
* @param component The ComponentName of the activity to launch * @param component The ComponentName of the activity to launch
* @param startActivityOptions Options to pass to startActivity * @param startActivityOptions This parameter is no longer supported
* @param user The UserHandle of the profile * @param user The UserHandle of the profile
* @hide * @hide
*/ */
@@ -765,7 +765,8 @@ public class LauncherApps {
Log.i(TAG, "GetMainActivityLaunchIntent " + component + " " + user); Log.i(TAG, "GetMainActivityLaunchIntent " + component + " " + user);
} }
try { try {
return mService.getActivityLaunchIntent(component, startActivityOptions, user); // due to b/209607104, startActivityOptions will be ignored
return mService.getActivityLaunchIntent(component, null /* opts */, user);
} catch (RemoteException re) { } catch (RemoteException re) {
throw re.rethrowFromSystemServer(); throw re.rethrowFromSystemServer();
} }
@@ -860,7 +861,7 @@ public class LauncherApps {
* *
* @param packageName The packageName of the shortcut * @param packageName The packageName of the shortcut
* @param shortcutId The id of the shortcut * @param shortcutId The id of the shortcut
* @param opts Options to pass to the PendingIntent * @param opts This parameter is no longer supported
* @param user The UserHandle of the profile * @param user The UserHandle of the profile
*/ */
@Nullable @Nullable
@@ -872,8 +873,9 @@ public class LauncherApps {
Log.i(TAG, "GetShortcutIntent " + packageName + "/" + shortcutId + " " + user); Log.i(TAG, "GetShortcutIntent " + packageName + "/" + shortcutId + " " + user);
} }
try { try {
// due to b/209607104, opts will be ignored
return mService.getShortcutIntent( return mService.getShortcutIntent(
mContext.getPackageName(), packageName, shortcutId, opts, user); mContext.getPackageName(), packageName, shortcutId, null /* opts */, user);
} catch (RemoteException re) { } catch (RemoteException re) {
throw re.rethrowFromSystemServer(); throw re.rethrowFromSystemServer();
} }

View File

@@ -872,7 +872,7 @@ public class LauncherAppsService extends SystemService {
PendingIntent injectCreatePendingIntent(int requestCode, @NonNull Intent[] intents, PendingIntent injectCreatePendingIntent(int requestCode, @NonNull Intent[] intents,
int flags, Bundle options, String ownerPackage, int ownerUserId) { int flags, Bundle options, String ownerPackage, int ownerUserId) {
return mActivityManagerInternal.getPendingIntentActivityAsApp(requestCode, intents, return mActivityManagerInternal.getPendingIntentActivityAsApp(requestCode, intents,
flags, options, ownerPackage, ownerUserId); flags, null /* options */, ownerPackage, ownerUserId);
} }
@Override @Override
@@ -1237,7 +1237,7 @@ public class LauncherAppsService extends SystemService {
// calling identity to mirror the startActivityAsUser() call which does not validate // calling identity to mirror the startActivityAsUser() call which does not validate
// the calling user // the calling user
return PendingIntent.getActivityAsUser(mContext, 0 /* requestCode */, launchIntent, return PendingIntent.getActivityAsUser(mContext, 0 /* requestCode */, launchIntent,
FLAG_IMMUTABLE, opts, user); FLAG_IMMUTABLE, null /* options */, user);
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }