CVE-2026-58866 AI-generated analysis
platform/frameworks/base, Accessibility (services/accessibility, AccessibilityWindowManager)
Adds a caller-ownership check to AccessibilityWindowManager.setAccessibilityWindowAttributes. Only the UID that owns the target window's accessibility connection (compared after re-homing into the resolved user), or the system UID, can now set that window's accessibility title and locale attributes.
Root cause
AccessibilityWindowManager.setAccessibilityWindowAttributes took a caller-supplied integer windowId. After resolving the user id via mSecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked, it only checked that a window token existed for that windowId (getWindowTokenForUserAndWindowIdLocked != null). It never compared the calling UID with the UID that owns the window. It then stored the attributes in mWindowAttributes and, if the window info was found, triggered computeWindowsForAccessibility. The entry point AccessibilityManagerService.setAccessibilityWindowAttributes is annotated @RequiresNoPermission and simply forwards to the window manager (per index search). Per the commit message, a malicious app could therefore overwrite the accessibility title and locale of another window by guessing its windowId.
How the fix works
- services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java:setAccessibilityWindowAttributes: reads the caller through a new overridable hook getCallingUid() (which returns Binder.getCallingUid()) before taking mLock.
- Same function: replaces the token-existence check with a lookup of the window's RemoteAccessibilityConnection via getConnectionLocked(resolvedUserId, windowId). If no connection exists, it still returns silently as before.
- Same function: computes resolvedUid = UserHandle.getUid(resolvedUserId, UserHandle.getAppId(callingUid)). It throws SecurityException("Calling UID ... does not own windowId ...") when resolvedUid != connection.getUid(), unless callingUid == android.os.Process.SYSTEM_UID. Only when the check passes are the attributes stored in mWindowAttributes and the window recomputation scheduled.
- AccessibilityWindowManager.java: adds @VisibleForTesting protected int getCallingUid() so tests can spy on the caller identity.
- services/tests/servicestests/.../AccessibilityWindowManagerTest.java: updates the existing title test to mock a matching caller UID, and adds setAccessibilityWindowAttributes_notOwner_shouldThrowSecurityException and setAccessibilityWindowAttributes_systemUid_succeeds. The commit message also mentions a CTS/STS test, AccessibilityWindowMetadataTest, which is not part of this frameworks/base diff.
Completeness
- The ownership check covers the single write path, setAccessibilityWindowAttributes into mWindowAttributes. No other method is changed in this commit.
- The comparison does not use the raw calling UID. It uses the caller's app ID re-homed into resolvedUserId (UserHandle.getUid(resolvedUserId, UserHandle.getAppId(callingUid))). As a result, a caller that passes resolveCallingUserIdEnforcingPermissionsLocked for another user is matched against the same app ID in that user.
- Callers whose UID is exactly Process.SYSTEM_UID are intentionally exempted (the code comment says the system UID may set attributes for windows of other UIDs).
- The null-connection case still returns silently rather than throwing, while a windowId owned by someone else now produces an exception.
Behavior changes
- A SecurityException is now thrown back to the Binder caller when the calling UID does not own the target window and is not the system UID. Before the fix, the call succeeded silently.
- The condition for applying attributes changed from 'a window token exists for the windowId' to 'a RemoteAccessibilityConnection exists for (resolvedUserId, windowId)'.
- New protected method getCallingUid() on AccessibilityWindowManager (test seam only).
Per major
- Android 14: same fix: commit 3dfa9781cb4f in android-security-14.0.0_r31. The service change is identical. The test diff is adapted to the older test file (it replaces a TextUtils-based assertion).
- Android 15: same fix: commit a5ab3adab7c9 in android-security-15.0.0_r19 (the commit analysed here).
- Android 16: same fix: commit 8e0e0f7728ff in android-security-16.0.0_r10. The service change is identical; the test hunks sit at different offsets.
- Android 17: same fix: commit a84ccbdd9c61 in android-security-17.0.0_r3. The service change is identical; the test hunks sit at different offsets.
Unknowns
- The material does not show whether other code paths write to mWindowAttributes or expose window metadata without an owner check.
- The CTS test AccessibilityWindowMetadataTest named in the commit message is not in the provided diffs, so its content and project are unknown.
- Whether the cross-user app-ID matching in the check is intended is not stated in the material.
- The material does not explain the per-major metric '7/8 lines of the patched region present'. All four branches contain the same security change in their diffs.