diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-09-08 14:32:06 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-09-08 14:41:01 -0700 |
commit | fb5096d07bb3bb59fd4b5db6b68613030169b4bd (patch) | |
tree | 3f7fb4506c460b632563f7cbe30222b8633486b3 /src/com/android/launcher3/InstallShortcutReceiver.java | |
parent | add78abb98391ccd74b96e1e4d312e3c89fe0eba (diff) | |
download | android_packages_apps_Trebuchet-fb5096d07bb3bb59fd4b5db6b68613030169b4bd.tar.gz android_packages_apps_Trebuchet-fb5096d07bb3bb59fd4b5db6b68613030169b4bd.tar.bz2 android_packages_apps_Trebuchet-fb5096d07bb3bb59fd4b5db6b68613030169b4bd.zip |
Preventing a shortcut which requires permissions from being added to
homescreen
A shortcut can be added by any app as INSTALL_SHORTCUT is a normal
level permission. But the intent is actually launched by the launcher
app which can have other permission as well.
> When adding a shortcut from the broadcast, verify that the intent does
not require any permission
> When adding a shortcut using the two-step drop process, verify that
the source app also has the permission to create such a shortcut
Bug: 30778130
Change-Id: I710a490d69019dc25709db5a97020c20d9325007
Diffstat (limited to 'src/com/android/launcher3/InstallShortcutReceiver.java')
-rw-r--r-- | src/com/android/launcher3/InstallShortcutReceiver.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java index df87cc204..d8e58d829 100644 --- a/src/com/android/launcher3/InstallShortcutReceiver.java +++ b/src/com/android/launcher3/InstallShortcutReceiver.java @@ -33,6 +33,7 @@ import com.android.launcher3.compat.LauncherActivityInfoCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.compat.UserManagerCompat; +import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.Thunk; import org.json.JSONException; @@ -146,6 +147,15 @@ public class InstallShortcutReceiver extends BroadcastReceiver { } PendingInstallShortcutInfo info = createPendingInfo(context, data); if (info != null) { + if (!info.isLauncherActivity()) { + // Since its a custom shortcut, verify that it is safe to launch. + if (!PackageManagerHelper.hasPermissionForActivity( + context, info.launchIntent, null)) { + // Target cannot be launched, or requires some special permission to launch + Log.e(TAG, "Ignoring malicious intent " + info.launchIntent.toUri(0)); + return; + } + } queuePendingShortcutInfo(info, context); } } |