Skip to content

Commit 7a7f1db

Browse files
pinyaotingSirRGB
authored andcommitted
Fix permission issue in legacy shortcut
When building legacy shortcut, Launcher calls PackageManager#resolveActivity to retrieve necessary permission to launch the intent. However, when the source app wraps an arbitrary intent within Intent#createChooser, the existing logic will fail because launching Chooser doesn't require additional permission. This CL fixes the security vulnerability by performing the permission check against the intent that is wrapped within. Bug: 270152142 Test: manual (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c53818a16b4322a823497726ac7e7a44501b4442) Merged-In: If35344c08975e35085c7c2b9b814a3c457a144b0 Change-Id: If35344c08975e35085c7c2b9b814a3c457a144b0
1 parent 14d48fc commit 7a7f1db

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/com/android/launcher3/util/PackageManagerHelper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ public static boolean isAppSuspended(ApplicationInfo info) {
112112
* any permissions
113113
*/
114114
public boolean hasPermissionForActivity(Intent intent, String srcPackage) {
115+
// b/270152142
116+
if (Intent.ACTION_CHOOSER.equals(intent.getAction())) {
117+
final Bundle extras = intent.getExtras();
118+
if (extras == null) {
119+
return true;
120+
}
121+
// If given intent is ACTION_CHOOSER, verify srcPackage has permission over EXTRA_INTENT
122+
intent = (Intent) extras.getParcelable(Intent.EXTRA_INTENT);
123+
if (intent == null) {
124+
return true;
125+
}
126+
}
115127
ResolveInfo target = mPm.resolveActivity(intent, 0);
116128
if (target == null) {
117129
// Not a valid target

0 commit comments

Comments
 (0)