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

Unverified Commit 40d09c79 authored by Oli Lan's avatar Oli Lan Committed by Kevin F. Haggerty
Browse files

Prevent non-admin users from deleting system apps.

This addresses a security issue where the guest user can remove updates
for system apps.

With this CL, attempts to uninstall/downgrade system apps will fail if
attempted by a non-admin user, unless the DELETE_SYSTEM_APP flag is
specified.

This is a fixed version of ag/17408864, to address b/236578018.

Bug: 170646036
Test: manual, try uninstalling system app update as guest
Merged-In: I4e959e296cca9bbdfc8fccc5e5e0e654ca524165
Change-Id: I6ecfef50294c9000a6ce539bdec6f372c872a40b
(cherry picked from commit fbfa268d)
Merged-In: I6ecfef50294c9000a6ce539bdec6f372c872a40b
parent 1064ad0a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -21739,6 +21739,17 @@ public class PackageManagerService extends IPackageManager.Stub
                return PackageManager.DELETE_FAILED_INTERNAL_ERROR;
            }
            if (isSystemApp(uninstalledPs)
                    && (deleteFlags & PackageManager.DELETE_SYSTEM_APP) == 0) {
                UserInfo userInfo = mUserManager.getUserInfo(userId);
                if (userInfo == null || !userInfo.isAdmin()) {
                    Slog.w(TAG, "Not removing package " + packageName
                            + " as only admin user may downgrade system apps");
                    EventLog.writeEvent(0x534e4554, "170646036", -1, packageName);
                    return PackageManager.DELETE_FAILED_USER_RESTRICTED;
                }
            }
            disabledSystemPs = mSettings.getDisabledSystemPkgLPr(packageName);
            // Static shared libs can be declared by any package, so let us not
            // allow removing a package if it provides a lib others depend on.