Fix access control checks getOwnerInstalledCaCerts
Prevent the profile owner or device owner from reading
ca certs for another user
Bug: 235822598
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Test: atest com.android.cts.devicepolicy.ProfileOwnerTest#testAdminActionBookkeeping
Test: atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testDelegatedCertInstaller
Test: atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDelegatedCertInstaller
Change-Id: I014fa1cfb4ddbbbdb86fbb0f948464dc4f5c069e
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 684ede3..d1f5fdd 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -18504,9 +18504,9 @@
public StringParceledListSlice getOwnerInstalledCaCerts(@NonNull UserHandle user) {
final int userId = user.getIdentifier();
final CallerIdentity caller = getCallerIdentity();
- Preconditions.checkCallAuthorization((userId == caller.getUserId())
- || isProfileOwner(caller) || isDefaultDeviceOwner(caller)
- || hasFullCrossUsersPermission(caller, userId));
+ Preconditions.checkCallAuthorization(
+ (isProfileOwner(caller) || isDefaultDeviceOwner(caller) || canQueryAdminPolicy(
+ caller)) && hasFullCrossUsersPermission(caller, userId));
synchronized (getLockObject()) {
return new StringParceledListSlice(