CVE-2026-59008 AI-generated analysis
platform/frameworks/base, DevicePolicyManagerService (device policy / application restrictions)
DevicePolicyManagerService.setApplicationRestrictions now rejects, with IllegalStateException, any attempt to put application restrictions on a new package once 1000 packages already carry restrictions for the user (counted across all admins), and performs the check and the policy write under the service lock.
Root cause
DevicePolicyManagerService.setApplicationRestrictions passed every request straight to mDevicePolicyEngine.setOrRemoveLocalPolicy(PolicyDefinition.APPLICATION_RESTRICTIONS(packageName), ...) with no cap on how many distinct packages could carry application restrictions. A device owner, profile owner, app-restrictions delegate or the device policy management role holder could therefore keep adding restriction entries for arbitrary package names without bound, and the call was not serialized against concurrent callers. The bulletin classifies the result as a High severity DoS. The material does not show which resource (storage, memory, policy file) is exhausted.
How the fix works
- services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java: adds constant MAX_PACKAGES_WITH_APP_RESTRICTIONS = 1000.
- DevicePolicyManagerService.java: adds enforceMaxRestrictedPackagesForEngine(EnforcingAdmin, int userId, String packageName, Bundle restrictions). It returns immediately when restrictions is null or empty (a clear/remove request). Otherwise it fetches a Set<PolicyKey> via mDevicePolicyEngine.getLocalPolicyKeysSetByAllAdmins(PolicyDefinition.GENERIC_APPLICATION_RESTRICTIONS, userId). It throws IllegalStateException("Cannot set application restrictions on more than 1000 packages") when the set size is >= 1000 and the set does not already contain new PackagePolicyKey(DevicePolicyIdentifiers.APPLICATION_RESTRICTIONS_POLICY, packageName). Updating an already-restricted package is always allowed.
- DevicePolicyManagerService.setApplicationRestrictions: the existing mDevicePolicyEngine.setOrRemoveLocalPolicy(...) call (with its thenAccept callback to mRcsArchivalAppTracker.onRestrictionsChanged) is wrapped in synchronized (getLockObject()) and preceded by the new enforceMaxRestrictedPackagesForEngine(enforcingAdmin, affectedUserId, packageName, restrictions) call. The count check and the write are therefore atomic with respect to other callers. The new concurrent unit test runs 1010 parallel callers and expects exactly 1000 successes.
- core/java/android/app/admin/DevicePolicyManager.java: the javadoc of setApplicationRestrictions documents the new IllegalStateException.
- services/tests/servicestests/.../DevicePolicyManagerTest.java: adds tests where a single admin, a delegated app, multiple admins (profile owner plus role holder) and concurrent callers hit the 1000 limit.
Completeness
- Covers the DevicePolicyEngine path of DevicePolicyManagerService.setApplicationRestrictions for callers that reach it, since the count is taken across all admins for affectedUserId. The tests cover a profile owner, a delegate and a role holder. Parent-instance handling is not shown.
- The limit is per user (userId is passed to getLocalPolicyKeysSetByAllAdmins, and the constant's comment says 'globally per-user'). A caller able to set restrictions on multiple users gets 1000 entries per user, not 1000 device-wide, despite the commit message wording 'global maximum'.
- Clearing restrictions (null or empty Bundle) is never blocked, and re-setting a package already in the set is allowed, so legitimate updates are unaffected.
- Only the entry count is bounded. This change does not limit the size or content of each restrictions Bundle.
- The constant's comment says different admins restricting the same target app count as independent entries, but the check uses a Set<PolicyKey> keyed by PackagePolicyKey(policy, packageName). The implementation of getLocalPolicyKeysSetByAllAdmins is not in the material, so it cannot be confirmed whether same-package entries from different admins are deduplicated.
- The javadoc in DevicePolicyManager.java mentions a separate system-only variant of setApplicationRestrictions. The material does not show whether it routes through the patched service method.
Behavior changes
- setApplicationRestrictions now throws IllegalStateException (documented in the public API javadoc) when a non-empty Bundle targets a package that is not already restricted and 1000 package keys already exist for the user across all admins.
- The engine policy write for application restrictions now runs under getLockObject(), which serializes concurrent setApplicationRestrictions calls.
- No behavior change for removing restrictions or updating an already-restricted package.
Per major
- Android 14: not affected per the bulletin (not listed); resolver reports 8/8 lines of the patched region present at android-security-14.0.0_r31
- Android 15: not affected per the bulletin (not listed); resolver reports 8/8 lines of the patched region present at android-security-15.0.0_r19
- Android 16: not affected per the bulletin (only 16-qpr2 is listed); resolver reports 8/8 lines of the patched region present at android-security-16.0.0_r10
- Android 17: same fix: commit 71bdf162ba20 in android-security-17.0.0_r3 (cherry-pick of internal c9c04f595d90 and 598eddaabe73), patched region fully present
Unknowns
- Which resource is exhausted by unbounded restriction entries (the bulletin only says DoS).
- The implementation of DevicePolicyEngine.getLocalPolicyKeysSetByAllAdmins, so whether entries for the same package from different admins are counted once or separately.
- Why the per-major resolver reports the patched region present on the 14, 15 and 16 security tags while the bulletin lists only 16-qpr2, 17 and 17-qpr2-next.
- Whether the system-only variant of setApplicationRestrictions mentioned in the javadoc shares the patched service path.
- How parent-instance calls map to affectedUserId for the limit.