CVE-2025-22442 AI-generated analysis
platform/frameworks/base, DevicePolicyManagerService / UserManagerService (managed profile provisioning and user restrictions)
Makes DISALLOW_DEBUGGING_FEATURES a default restriction for managed profiles. It also applies the default managed-profile device-policy restrictions inside UserManagerService when the profile is created (before the profile owner is set and, on Android 14, before the user stops being partial), and makes "pm install --user" refuse nonexistent or partial users.
Root cause
The diffs show two related problems. (1) UserRestrictionsUtils.DEFAULT_ENABLED_FOR_MANAGED_PROFILES contained only DISALLOW_BLUETOOTH_SHARING, so a work profile did not get DISALLOW_DEBUGGING_FEATURES by default ("Developer options" enabled). Separately, maybeSetDefaultRestrictionsForAdminLocked returned early when the full default set equals() admin.defaultEnabledRestrictionsAlreadySet, and its policy-engine branch then applied the full default set rather than only the delta. (2) In DevicePolicyManagerService's managed-profile provisioning path (createAndProvisionManagedProfile), the profile user was created via mUserManager.createProfileForUserEvenWhenDisallowed without device-policy restrictions. The default restrictions were applied only later, in the profile-owner path that calls maybeSetDefaultRestrictionsForAdminLocked. On Android 14, UserManagerService.createUserInternalUncheckedNoTracing also marked the user non-partial and wrote it out (userInfo.partial = false, writeUserLP, updateUserIds) before even the base restrictions were set. On Android 14, PackageManagerShellCommand.doRunInstall also did not check that the target user existed or was fully created. From the diffs, the fix appears intended to keep shell installs from targeting a profile that is not fully set up.
How the fix works
- Commit 1 (2095d130b4d7, android-security-14.0.0_r19, Change-Id Ibe6b721f): in services/core/java/com/android/server/pm/UserRestrictionsUtils.java, DEFAULT_ENABLED_FOR_MANAGED_PROFILES now contains UserManager.DISALLOW_DEBUGGING_FEATURES in addition to DISALLOW_BLUETOOTH_SHARING.
- Commit 1: DevicePolicyManagerService.maybeSetDefaultRestrictionsForAdminLocked first computes restrictionsToSet as getDefaultEnabledForManagedProfiles() minus admin.defaultEnabledRestrictionsAlreadySet. It returns early only if that delta is empty, and applies only the delta in both branches: the policy-engine branch (mDevicePolicyEngine.setLocalPolicy with BooleanPolicyValue(true)) and the legacy branch (admin.ensureUserRestrictions().putBoolean plus saveUserRestrictionsLocked). Before the fix, the early return used equals() and the policy-engine branch applied the full default set.
- Commit 1: in the DPMS profile-owner path (the method that logs PROVISIONING_ENTRY_POINT_ADB and sends ACTION_PROFILE_OWNER_CHANGED), the result of isAdb(caller) is now stored. After maybeSetDefaultRestrictionsForAdminLocked and ensureUnknownSourcesRestrictionForProfileOwnerLocked, an ADB caller triggers setLocalUserRestrictionInternal(EnforcingAdmin.createEnterpriseEnforcingAdmin(who, userHandle), DISALLOW_DEBUGGING_FEATURES, false, userHandle). This removes the new default for ADB-provisioned profiles; the code comment cites CTS flows.
- Commit 2 (59a2f1fa1a7c, android-security-14.0.0_r29, Change-Id Ib71ff2a9): in UserManagerService.java, createUserInternalUnchecked and createUserInternalUncheckedNoTracing gain a @Nullable String[] devicePolicyUserRestrictions parameter, and all existing callers pass null. Inside createUserInternalUncheckedNoTracing, under mRestrictionsLock and after mBaseUserRestrictions.updateRestrictions, the given restrictions are set to true in a Bundle that is applied via mDevicePolicyUserRestrictions.updateRestrictions(userId, dpurBundle). On Android 14, the block 'userInfo.partial = false; writeUserLP(userData); updateUserIds();' moves from before the restrictions block to after it.
- Commit 2: UserManagerInternal.java and UserManagerService.LocalService gain a new createProfileForUserEvenWhenDisallowed(name, userType, flags, parentId, disallowedPackages, token, devicePolicyUserRestrictions) that forwards to createUserInternalUnchecked with the restrictions.
- Commit 2: the DPMS provisioning path now calls mUserManagerInternal.createProfileForUserEvenWhenDisallowed(..., token=null, UserRestrictionsUtils.getDefaultEnabledForManagedProfiles().toArray(new String[0])) inside a try block. A CheckedUserOperationException sets userInfo = null, which the existing check turns into ServiceSpecificException ERROR_PROFILE_CREATION_FAILED. The default managed-profile restrictions are therefore set as device-policy restrictions at creation, before installExistingAdminPackage and enableAdminAndSetProfileOwner run.
- Commit 2: in PackageManagerShellCommand.doRunInstall, when params.userId is neither USER_ALL nor USER_CURRENT, the user is looked up with UserManagerInternal.getUserInfo(requestUserId). If the user is null or userInfo.partial, the command fails with 'Failure [user N doesn't exist]' (return 1). On Android 14 the whole block is new; on 15, 16 and 17 only the '|| userInfo.partial' condition is added to an existing check.
Completeness
- Covers the DPMS createAndProvisionManagedProfile call site on all majors. On Android 16 and 17, a second DPMS call site (a method that returns mUserManager.createProfileForUserEvenWhenDisallowed(params.getProfileName(), ...)) is also converted. The Android 14 and 15 diffs touch only one call site, and whether that second method exists on 14 or 15 is not shown.
- Only the DEFAULT_ENABLED_FOR_MANAGED_PROFILES set is applied at creation. DISALLOW_INSTALL_UNKNOWN_SOURCES is still applied later via ensureUnknownSourcesRestrictionForProfileOwnerLocked, as the UserRestrictionsUtils comment notes.
- UserManagerService.createProfileForUserEvenWhenDisallowedWithThrow still passes devicePolicyUserRestrictions = null, so profiles created through it do not get restrictions at creation.
- The restriction is deliberately removed again when the profile owner is set via ADB (isAdb exemption).
- The partial-user check is added only to PackageManagerShellCommand.doRunInstall. Other shell commands that take a --user argument are not changed in these diffs.
- Index search found no other caller of maybeSetDefaultRestrictionsForAdminLocked, so the material does not show when existing profiles pick up the new default.
Behavior changes
- Newly created managed profiles have DISALLOW_DEBUGGING_FEATURES set (Developer options disabled in the work profile). The exception is a profile owner set via ADB, where the restriction is cleared again.
- Because the default set now includes DISALLOW_DEBUGGING_FEATURES, existing admins whose defaultEnabledRestrictionsAlreadySet lacks it get it the next time maybeSetDefaultRestrictionsForAdminLocked runs for them. When that happens is not shown.
- 'pm install --user N' now fails with 'Failure [user N doesn't exist]' when N does not exist or is still a partial user.
- The DPMS provisioning path now throws ServiceSpecificException ERROR_PROFILE_CREATION_FAILED when UserManagerService throws CheckedUserOperationException.
- On Android 14, the new user is marked non-partial and written out only after base and device-policy restrictions are set.
- Internal API change: UserManagerService.createUserInternalUnchecked and createUserInternalUncheckedNoTracing take an extra parameter, and UserManagerInternal gains createProfileForUserEvenWhenDisallowed.
Per major
- Android 14: Two commits. 2095d130b4d7 (android-security-14.0.0_r19) adds the DISALLOW_DEBUGGING_FEATURES default, the delta-based maybeSetDefaultRestrictionsForAdminLocked and the ADB exemption. 59a2f1fa1a7c (android-security-14.0.0_r29) adds the devicePolicyUserRestrictions plumbing, moves partial=false/writeUserLP/updateUserIds after the restriction setup, patches one DPMS call site and adds the full user-existence/partial check in doRunInstall. The code context at android-security-14.0.0_r31 shows both changes, though the resolver reports 5/8 lines of the patched region present.
- Android 15: Adapted fix e7890bc1f9c0 in android-security-15.0.0_r17. It has the same UserManagerService/UserManagerInternal plumbing and converts one DPMS call site. doRunInstall already had the user-existence check, so only '|| userInfo.partial' is added. partial=false already follows the restrictions block in the context, so no reordering is needed. 8/8 lines present at r19.
- Android 16: Adapted fix 0cd322056222 in android-security-16.0.0_r10. Same as 15, plus a second DPMS call site converted, @CanBeNULL parentId annotations and a new UserManagerServiceMockedTest test. 8/8 lines present at r10.
- Android 17: Adapted fix 79dd06a8c17c in android-security-17.0.0_r1. Same as 16, plus HsumBootUserInitializer.java updated for the new createUserInternalUnchecked parameter (the method is package-visible there) and HsumBootUserInitializerInitMethodTest mocks adjusted. 8/8 lines present at r3.
Unknowns
- The bulletin and commit messages do not state the exact trigger or what privilege is gained. The window and the missing restriction are inferred from the diffs.
- Whether Android 14 and 15 contain the second DPMS call site that is patched on 16 and 17.
- Whether a counterpart of commit 1 (DISALLOW_DEBUGGING_FEATURES default and delta logic) exists on 15, 16 and 17. Only the commit 2 equivalents are shown for those branches.
- Which callers besides the profile-owner path invoke maybeSetDefaultRestrictionsForAdminLocked (index search found none), and the exact name of the enclosing DPMS method in commit 1's third hunk.
- Why the resolver reports 5/8 lines present at android-security-14.0.0_r31 when the shown code context contains the patch.