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

Commit cc0ec4d2 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by android-build-merger
Browse files

Merge "[DO NOT MERGE] Don't allow permission change to runtime" into mnc-dev am: c8dac8d6

am: 84e1238e

Change-Id: I2c912b8363a6ca8a12e1c56ae5f1956a4ba5dc07
parents 9335807f 84e1238e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -12641,6 +12641,20 @@ public class PackageManagerService extends IPackageManager.Stub {
                                    + perm.info.name + "; ignoring new declaration");
                            pkg.permissions.remove(i);
                        }
                    } else if (!"android".equals(pkg.packageName)) {
                        // Prevent apps to change protection level to dangerous from any other
                        // type as this would allow a privilege escalation where an app adds a
                        // normal/signature permission in other app's group and later redefines
                        // it as dangerous leading to the group auto-grant.
                        if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
                                == PermissionInfo.PROTECTION_DANGEROUS) {
                            if (bp != null && !bp.isRuntime()) {
                                Slog.w(TAG, "Package " + pkg.packageName + " trying to change a "
                                        + "non-runtime permission " + perm.info.name
                                        + " to runtime; keeping old protection level");
                                perm.info.protectionLevel = bp.protectionLevel;
                            }
                        }
                    }
                }
            }