CVE-2026-49935 AI-generated analysis
platform/frameworks/base, services/core LocaleManagerService (app-specific locales / LocaleConfig override)
Adds an owner/installer/foreground-IME-or-READ_APP_SPECIFIC_LOCALES access check to LocaleManagerService.getOverrideLocaleConfig and a canonical-path containment check in getXmlFileNameForUser so a caller-supplied package name can no longer select a locale-config XML outside the target user's locale_configs directory; a follow-up commit returns null early for packages not found for the user to avoid a regression crash.
Root cause
In services/core/java/com/android/server/locales/LocaleManagerService.java, getOverrideLocaleConfig(appPackageName, userId) only ran mActivityManagerInternal.handleIncomingUser on userId and then directly built a file via getXmlFileNameForUser(appPackageName, userId), which returned new File(dir, appPackageName + SUFFIX_FILE_NAME) with dir = <DataSystemCeDirectory(userId)>/LOCALE_CONFIGS. There was no check that the caller owns, installed, or is otherwise authorized for appPackageName (unlike getApplicationLocales, which enforces owner/installer/IME-foreground or READ_APP_SPECIFIC_LOCALES), so any caller could read any package's stored override LocaleConfig. Because appPackageName was concatenated into the path without validation, a name containing ".." could resolve to a file outside the intended directory, including another user's locale_configs directory (as the added test name "../../10/locale_configs/com.victim" illustrates), so the cross-user check applied to the userId argument did not constrain the file read. The method is exposed through the binder service (LocaleManagerService.this.getOverrideLocaleConfig at line 215 of the r19 context).
How the fix works
- Commit 1 (a508a0a4dba6 on 15; 2a2f6ec57954 on 14; 45c98d340469 on 17), LocaleManagerService.java:getOverrideLocaleConfig: after handleIncomingUser, adds the same gate used by getApplicationLocales: if !isPackageOwnedByCaller(appPackageName, userId, null, null) && !isCallerInstaller(appPackageName, userId) && !(isCallerFromCurrentInputMethod(userId) && mActivityManagerInternal.isAppForeground(getPackageUid(appPackageName, userId))), then enforceReadAppSpecificLocalesPermission("getOverrideLocaleConfig"), which calls mContext.enforceCallingOrSelfPermission(READ_APP_SPECIFIC_LOCALES, message) and throws SecurityException on failure.
- Commit 1, LocaleManagerService.java:enforceReadAppSpecificLocalesPermission: signature changed from no-arg to (String message) so the enforcement message names the calling API; the getApplicationLocales call site is updated to pass "getApplicationLocales".
- Commit 1, LocaleManagerService.java:getOverrideLocaleConfig: the FileInputStream/XML parse block is now wrapped in Binder.clearCallingIdentity() / Binder.restoreCallingIdentity(token) in a finally, so the file read runs with system identity only after the caller has passed the access check.
- Commit 1, LocaleManagerService.java:getXmlFileNameForUser: after constructing file = new File(dir, appPackageName + SUFFIX_FILE_NAME), verifies file.getCanonicalPath().startsWith(dir.getCanonicalPath()); if not, writes a SafetyNet EventLog (tag 0x534e4554, id "495409704", Binder.getCallingUid(), appPackageName) and throws IllegalArgumentException("Invalid package name: ..."); an IOException from canonicalization is also converted to IllegalArgumentException. The check is in the path helper itself, so every call through it is checked.
- Commit 2 (97ec7ba77d17 on 15; 1b9a78c1ed8d on 16), LocaleManagerService.java:getOverrideLocaleConfig: inserts `if (getPackageUid(appPackageName, userId) < 0) return null;` immediately after handleIncomingUser and before the new ownership gate. Per its commit message this fixes a regression from commit 1: isPackageOwnedByCaller threw IllegalArgumentException for packages whose UID is < 0 (not installed for the target user), crashing Settings, which calls getOverrideLocaleConfig via the LocaleConfig constructor. Returning null restores the previous behavior for unknown packages while keeping the access and path checks for installed packages.
- Tests (LocaleManagerServiceTest.java): commit 1 adds testGetOverrideLocaleConfig_arbitraryAppWithoutPermission_fails, testGetOverrideLocaleConfig_pathTraversal_fails and testGetOverrideLocaleConfig_pathTraversal_bypassFirstDefense_provesVulnerability (which asserts the canonical-path check throws even when the package lookup and permission checks are mocked to pass); commit 2 replaces testGetOverrideLocaleConfig_pathTraversal_fails with testGetOverrideLocaleConfig_packageNotFound_returnsNull and adds packageExists_noConfig_returnsNull and otherUser_unauthorized_throwsSecurityException.
Completeness
- Covers the read path getOverrideLocaleConfig: both the missing authorization and the path construction are addressed. The path check sits in the helper getXmlFileNameForUser, so any other caller of that helper would also be checked; the material does not show whether such callers exist.
- The containment check is a plain string prefix test (file.getCanonicalPath().startsWith(dir.getCanonicalPath())) without a trailing separator; a canonical path in a sibling directory whose name starts with the locale_configs directory name would pass. It also permits package names that resolve to subdirectories inside dir. The material shows no such sibling directory, so this is a robustness observation, not a demonstrated gap.
- The access gate mirrors getApplicationLocales exactly (owner, installer, current IME for a foreground app, or READ_APP_SPECIFIC_LOCALES). Cross-user access is still governed only by handleIncomingUser with ALLOW_NON_FULL on the userId argument.
- After commit 2, getOverrideLocaleConfig returns null when getPackageUid(appPackageName, userId) < 0, before the ownership gate and getXmlFileNameForUser; commit 2 replaced the traversal test whose name was mocked as not found with a packageNotFound_returnsNull test, while the bypassFirstDefense test still exercises the path check for a name mocked as found.
- The write side (how override configs are stored) is not shown in the material, so whether it had an equivalent missing check cannot be judged from the diff.
Behavior changes
- getOverrideLocaleConfig now throws SecurityException for callers that do not own the package, are not its installer, are not the current IME querying a foreground app, and lack READ_APP_SPECIFIC_LOCALES.
- getXmlFileNameForUser now throws IllegalArgumentException("Invalid package name: ...") and emits a SafetyNet EventLog entry (0x534e4554, "495409704", calling UID, package name) when the resolved path is outside the locale_configs directory, or when canonicalization fails with IOException.
- After commit 2, getOverrideLocaleConfig returns null for a package not found for the target user instead of throwing (commit 1 alone made this an IllegalArgumentException from isPackageOwnedByCaller, which crashed Settings per the commit message).
- The XML file read in getOverrideLocaleConfig now runs under cleared calling identity.
- The permission-denied message for getApplicationLocales is unchanged; getOverrideLocaleConfig now reports its own name in the SecurityException message.
Per major
- Android 14: same fix: commit 1 (2a2f6ec57954, ownership check + canonical path check + clearCallingIdentity) applied in android-security-14.0.0_r29 with identical hunks at slightly different line offsets; at 14.0.0_r31 the resolver reports 6/8 lines of the patched region present. The material does not show the commit 2 crash fix on 14.
- Android 15: same fix in two commits: a508a0a4dba6 (ownership + path check) in android-security-15.0.0_r17, then 97ec7ba77d17 (package-not-found returns null) in android-security-15.0.0_r19; r19 code context confirms the getApplicationLocales call site passes "getApplicationLocales". Resolver reports 6/8 lines at r19.
- Android 16: commit 2 (1b9a78c1ed8d) is in android-security-16.0.0_r10. Its diff context shows the start of the commit 1 ownership gate in getOverrideLocaleConfig, and a test file index that matches the post-commit-1 state, which suggests commit 1 is also present; the commit 1 diff and the getXmlFileNameForUser path check are not shown for 16. Resolver reports 7/8 lines at r10.
- Android 17: same fix: commit 1 (45c98d340469) applied in android-security-17.0.0_r1 with identical hunks at later line offsets; resolver reports 6/8 lines at 17.0.0_r3. The material does not show the commit 2 crash fix on 17.
Unknowns
- Whether the commit 2 crash fix was also applied to the Android 14 and 17 security branches (only 15 and 16 show it).
- Whether the commit 1 path check in getXmlFileNameForUser is present on Android 16 (only commit 2 is shown there).
- The body of LocaleManagerService.getPackageUid and any other callers of getXmlFileNameForUser (write/delete paths) are not shown. The exact pre-fix behavior for unknown packages, the identity getPackageUid runs under, and the state of the write path come only from the tests and the commit 2 message or remain unknown.
- Why the per-major resolver reports 6/8 (or 7/8) patched-region lines rather than 8/8 at the latest tags is not explained by the material.