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

am: 84e1238ed6

Change-Id: I2c912b8363a6ca8a12e1c56ae5f1956a4ba5dc07
This commit is contained in:
Svetoslav Ganov
2017-03-09 19:32:59 +00:00
committed by android-build-merger

View File

@@ -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;
}
}
}
}
}