CVE-2026-58877 AI-generated analysis
platform/packages/modules/Wifi, Wi-Fi P2P service (WifiP2pServiceImpl, P2pStateMachine)
The fix makes the "internal message" permission bypass in WifiP2pServiceImpl.P2pStateMachine.checkNearbyDevicesPermission conditional on the sending UID being the Wi-Fi service's own UID (Process.myUid()), so a client-supplied EXTRA_PARAM_KEY_INTERNAL_MESSAGE flag no longer skips the nearby-devices permission check.
Root cause
In service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java, P2pStateMachine.checkNearbyDevicesPermission(int uid, String packageName, Bundle extras, String message, Object attributionSource) returned true immediately whenever the extras Bundle contained EXTRA_PARAM_KEY_INTERNAL_MESSAGE == true, skipping both mWifiPermissionsUtil.checkPackage(uid, packageName) and mWifiPermissionsUtil.checkNearbyDevicesPermission(...). The extras Bundle comes from the client's Message (message.getData().getBundle(WifiP2pManager.EXTRA_PARAM_KEY_BUNDLE), see the Message-based overload at lines 5864-5876), so a client able to send a message to the P2P state machine could set that flag and have the nearby-devices permission check bypassed. The flag was intended to mark internal calls, but nothing verified the origin.
How the fix works
- service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java : P2pStateMachine.checkNearbyDevicesPermission(int uid, String packageName, Bundle extras, String message, Object attributionSource): the early-return condition is extended from `extras != null && extras.getBoolean(EXTRA_PARAM_KEY_INTERNAL_MESSAGE)` to additionally require `uid == Process.myUid()`. The uid parameter is message.sendingUid as passed by the Message-based overload. If the sender is not the Wi-Fi service UID, execution falls through to checkPackage and mWifiPermissionsUtil.checkNearbyDevicesPermission as for any ordinary caller.
- service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java : adds testAddLocalServiceFailureWithInternalMessageBypassAttempt, which sends ADD_LOCAL_SERVICE with sendingUid = Process.myUid() + 10000 and EXTRA_PARAM_KEY_INTERNAL_MESSAGE = true, with the permission mock returning false, and asserts ADD_LOCAL_SERVICE_FAILED is delivered and WifiNative.p2pServiceAdd is never called.
Completeness
- The fix is applied in the shared 5-argument checkNearbyDevicesPermission helper, so P2P commands whose permission check routes through it (per index search, via the Message-based overload at lines 5864-5876) are covered, not just ADD_LOCAL_SERVICE. The index search is not exhaustive, so other callers cannot be ruled out.
- The check relies on the uid argument (message.sendingUid) being trustworthy. The material does not show whether any caller invokes the 5-argument overload with a uid derived from something other than the sending UID recorded on the Message.
- The fix does not remove the bypass mechanism; it only restricts it to the service's own UID. Internal callers running under Process.myUid() still skip checkPackage and the nearby-devices check.
- Only the EXTRA_PARAM_KEY_INTERNAL_MESSAGE bypass is addressed; no other extras-driven shortcuts are visible in the provided context, and none are changed.
Behavior changes
- Messages carrying EXTRA_PARAM_KEY_INTERNAL_MESSAGE from a UID other than the Wi-Fi service's UID are now subject to the normal checkPackage and checkNearbyDevicesPermission path; per the test, an ADD_LOCAL_SERVICE request from a caller failing that check now receives ADD_LOCAL_SERVICE_FAILED and the native service add is not performed.
- No change for internal messages from uid == Process.myUid(); the bypass still applies there.
Per major
- Android 14: same fix: commit a579792002a4 in android-security-14.0.0_r31; identical condition change in checkNearbyDevicesPermission (hunk at line 4952) plus the same unit test; resolver reports 7/8 lines of the patched region present at that tag.
- Android 15: same fix: commit 618cb7d37579 in android-security-15.0.0_r19 (cherry-pick of 4f7d1bd3af8c); hunk at line 5878; code at the tag shows the `&& uid == Process.myUid()` condition in place; resolver reports 7/8 lines present.
- Android 16: same fix: commit 2498e631b3ad in android-security-16.0.0_r10; identical change at line 6263 plus the same test; resolver reports 7/8 lines present.
- Android 17: same fix: commit e4258a287f0a in android-security-17.0.0_r3; identical change at line 6307 plus the same test; resolver reports 7/8 lines present.
Unknowns
- What specific information is disclosed (bulletin type is ID) and which P2P commands beyond ADD_LOCAL_SERVICE were of concern; the material only shows the shared helper and the ADD_LOCAL_SERVICE test.
- Which single line of the 8-line patched region the resolver reports as missing at each security tag; the provided code context at android-security-15.0.0_r19 shows the functional change present.
- Where in the Wi-Fi service the EXTRA_PARAM_KEY_INTERNAL_MESSAGE flag is legitimately set, and whether every such internal sender runs under Process.myUid().
- Whether other callers of the 5-argument checkNearbyDevicesPermission exist beyond those surfaced by the index search.