summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2016-12-29 14:36:58 -0800
committergitbuildkicker <android-build@google.com>2017-04-06 15:18:34 -0700
commit9fa33e71c2a0493911217858e07fdf6dd18538c5 (patch)
treeb7d7358bfb8158a32f5e1c0b23e8ed8dbac4e8d3
parent413ebd137fdd3296bd19cea3c0e04b2b20e924b3 (diff)
downloadbase-9fa33e71c2a0493911217858e07fdf6dd18538c5.tar.gz
[DO NOT MERGE] Don't allow permission change to runtimeandroid-7.1.2_r11
Prevent apps to change permission protection level to dangerous from any other type as this would allow a privilege escalation where an app adds a normal permission in other app's group and then redefines it as dangerous leading to the group auto-grant. Test: Added a CTS test which passes. Bug: 33860747 Change-Id: I1ccf546f78ee79ff027cb98124be81c8e5265a82 (cherry picked from commit fe430be9f102893c95258cc81589df132b7d02b3)
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 39e2914d73c3..b6a994081229 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -15204,6 +15204,20 @@ public class PackageManagerService extends IPackageManager.Stub {
+ perm.info.name + "; ignoring new declaration");
pkg.permissions.remove(i);
}
+ } else if (!PLATFORM_PACKAGE_NAME.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;
+ }
+ }
}
}
}