CVE-2026-59021 AI-generated analysis
platform/frameworks/base, services/devicepolicy (DevicePolicyEngine policy state persistence)
Replaces Set.of(...split(";")) with HashSet-based deduplication in the device policy XML readers (StringSetPolicySerializer, LockTaskPolicySerializer, EnforcingAdmin) and wraps PolicyState.readFromXml in DevicePolicyEngine with a per-entry IllegalArgumentException catch, so a persisted policy value containing the ';' separator no longer aborts parsing of device_policy_state.xml or crashes system_server.
Root cause
The policy serializers persist string sets by joining elements with ";" (saveToXml via String.join) and read them back with Set.of(valuesStr.split(";")). Set.of rejects duplicate elements with IllegalArgumentException. Per the commit message, if an admin set a policy containing the separator character (;) multiple times, the split on reload yields duplicate elements and Set.of throws. In DevicePolicyEngine.readLocalPoliciesInner / readGlobalPoliciesInner the call PolicyState.readFromXml(parser) was not guarded against IllegalArgumentException, so the exception propagated. Per the commit message this dropped all subsequent policies, or crashed system_server and caused a bootloop. The same Set.of pattern existed in EnforcingAdmin.readFromXml for the authorities attribute.
How the fix works
- services/devicepolicy/.../StringSetPolicySerializer.java:readFromXml: splits into valuesArray and builds new HashSet<>(Arrays.asList(valuesArray)) instead of Set.of; if values.size() != valuesArray.length, logs 'Duplicate values found in StringSet policy' with Log.e. Duplicates are collapsed instead of throwing.
- services/devicepolicy/.../LockTaskPolicySerializer.java:readFromXml: same HashSet replacement for the packages attribute, with Log.e 'Duplicate packages found in LockTask policy'. The remaining hunks in saveToXml/readFromXml are formatting only.
- services/devicepolicy/.../EnforcingAdmin.java:readFromXml: same HashSet replacement for the authorities attribute (ATTR_AUTHORITIES_SEPARATOR), with Slogf.e 'Duplicate authorities found in EnforcingAdmin'; adds the java.util.Arrays import.
- services/devicepolicy/.../DevicePolicyEngine.java:readLocalPoliciesInner and readGlobalPoliciesInner: wraps PolicyState.readFromXml(parser) in try/catch (IllegalArgumentException) and logs via Slogf.wtf 'Error parsing policy state'. In readLocalPoliciesInner, policyState then stays null, so the entry falls into the existing 'Error parsing local policy ... policyState is null' wtf branch and is not stored, while the XmlUtils.nextElementWithin loop continues. This is defense in depth for any remaining IllegalArgumentException thrown by a serializer.
Completeness
- The commit changes the three Set.of(...split(...)) readers in StringSetPolicySerializer, LockTaskPolicySerializer and EnforcingAdmin; whether other such readers exist in the Android 14 tree is not shown.
- Covers both policy-state read loops in DevicePolicyEngine (local and global), but the new catch only surrounds PolicyState.readFromXml; an IllegalArgumentException from PolicyDefinition.readPolicyKeyFromXml or readEnforcingAdminsInner is not caught by this commit.
- The write side is unchanged on Android 14: saveToXml in StringSetPolicySerializer and LockTaskPolicySerializer still joins values with ';' without escaping or validation, so a value containing ';' is still persisted and is mis-split (now deduplicated) on reload; the policy content is silently altered rather than rejected. The Android 17 commit adds a constructor check in PackageSetPolicyValue that rejects package names containing ';'; the Android 14 commit has no equivalent.
- Only IllegalArgumentException is newly handled; other exception types from PolicyState.readFromXml are not.
Behavior changes
- Duplicate elements in a persisted string set, lock task package list or enforcing admin authorities attribute are deduplicated with an error log instead of throwing.
- A policy entry whose PolicyState parsing throws IllegalArgumentException is logged with Slogf.wtf and skipped, and parsing continues with later entries.
- New log lines: 'Duplicate values found in StringSet policy', 'Duplicate packages found in LockTask policy', 'Duplicate authorities found in EnforcingAdmin', 'Error parsing policy state'.
Per major
- Android 14: same fix: c10d911df76b in android-security-14.0.0_r31, 4 files (DevicePolicyEngine, EnforcingAdmin, LockTaskPolicySerializer, StringSetPolicySerializer); patched region fully present (8/8 lines).
- Android 15: adapted fix: bd79687428de in android-security-15.0.0_r19, same DevicePolicyEngine/EnforcingAdmin/LockTaskPolicySerializer changes, plus the HashSet change in PackageSetPolicySerializer (not StringSetPolicySerializer); patched region present (8/8 lines).
- Android 16: adapted fix: 3d92ee0f876e in android-security-16.0.0_r10 touches only DevicePolicyEngine. It removes IllegalArgumentException from the outer file-level catch and adds the per-entry try/catch around PolicyState.readFromXml(policyDefinition, parser). Serializer and EnforcingAdmin changes are not in this commit. Per-major facts report the patched region present (8/8 lines).
- Android 17: different commit: 99894bf30414 in android-security-17.0.0_r3 adds a ';' rejection in the PackageSetPolicyValue constructor (core/java/android/app/admin), adds IllegalArgumentException to the outer file-level catch in DevicePolicyEngine, and applies the HashSet change in LockTaskPolicySerializer and PackageSetPolicySerializer. EnforcingAdmin is not touched, and the per-entry try/catch seen on 16 is not shown for 17.
Unknowns
- Which admin API or policy type was used in the reported case, and how the ';' reached the stored value.
- Whether the Android 14 tree has other Set.of(...split(...)) readers (e.g. a PackageSetPolicySerializer) beyond the three changed.
- How readGlobalPoliciesInner handles a null policyState (context truncated).
- Which commit introduced the outer IllegalArgumentException catch on 16, and whether 16 carries the serializer and EnforcingAdmin HashSet changes.
- Whether Android 16 and 17 carry the EnforcingAdmin.readFromXml HashSet change.
- Whether Android 17 also received the per-entry try/catch shipped on 16.
- Whether other IllegalArgumentException sources exist in PolicyDefinition.readPolicyKeyFromXml or readEnforcingAdminsInner.