Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff7add01 authored by Christopher Tate's avatar Christopher Tate
Browse files

Check component permissions like 'exported' before assigned permissions

In particular, don't assume that the absence of an explicit permission
requirement means that the activity is freely launchable unless you have
also checked thing like exported="true" first.

Bug 23223804

Change-Id: Idbfd1f5662b374a7a447b738591b267a1c497e41
parent ed7961eb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1687,16 +1687,16 @@ public final class ActivityStackSupervisor implements DisplayListener {

    private int getComponentRestrictionForCallingPackage(ActivityInfo activityInfo,
            String callingPackage, int callingPid, int callingUid, boolean ignoreTargetSecurity) {
        if (activityInfo.permission == null) {
            return ACTIVITY_RESTRICTION_NONE;
        }

        if (!ignoreTargetSecurity && mService.checkComponentPermission(activityInfo.permission,
                callingPid, callingUid, activityInfo.applicationInfo.uid, activityInfo.exported)
                == PackageManager.PERMISSION_DENIED) {
            return ACTIVITY_RESTRICTION_PERMISSION;
        }

        if (activityInfo.permission == null) {
            return ACTIVITY_RESTRICTION_NONE;
        }

        final int opCode = AppOpsManager.permissionToOpCode(activityInfo.permission);
        if (opCode == AppOpsManager.OP_NONE) {
            return ACTIVITY_RESTRICTION_NONE;