CVE-2026-58867 AI-generated analysis
platform/packages/modules/Wifi, Wi-Fi P2P service (WifiP2pServiceImpl)
Adds a mWifiPermissionsUtil.checkPackage(callerUid, packageName) call in WifiP2pServiceImpl.getMessenger so that a caller whose supplied package name evaluates as system is verified against its uid before a custom display ID is read from the extras bundle.
Root cause
In WifiP2pServiceImpl.getMessenger, the caller-supplied packageName is passed to mWifiPermissionsUtil.isSystem(packageName, callerUid) and, if that returns true, the service reads WifiP2pManager.EXTRA_PARAM_KEY_DISPLAY_ID from the caller-supplied extras as the caller's display ID (otherwise Display.DEFAULT_DISPLAY). Before the fix nothing in that block verified that packageName belongs to callerUid, which per the commit message allowed "registering custom display IDs for unauthorized package names".
How the fix works
- service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java:getMessenger: inside the `if (mWifiPermissionsUtil.isSystem(packageName, callerUid))` block, a call to mWifiPermissionsUtil.checkPackage(callerUid, packageName) is inserted before extras.getInt(WifiP2pManager.EXTRA_PARAM_KEY_DISPLAY_ID, Display.DEFAULT_DISPLAY). On this branch the check is unconditional; the commit message states the feature flag check (mFeatureFlags.validateCallerPackage()) was removed as a merge-conflict resolution because the feature flag system is not present on this branch.
- service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java:DeathHandlerData: the mDisplayId field is annotated @Deprecated with a TODO(b/515051007) stating it is unused and should be removed. No functional change; the field is still assigned by the constructor.
- The commit references a test in FrameworksWifiTests WifiP2pServiceImplTest, but no test changes are included in the shown diff.
Completeness
- Covers only the isSystem branch of getMessenger: the package/uid binding is checked only when isSystem(packageName, callerUid) returns true; in the shown code the non-system path keeps Display.DEFAULT_DISPLAY and does not read the display ID extra.
- The DeathHandlerData.mDisplayId field is only marked deprecated, not removed; the TODO signals follow-up work.
- Whether other call sites in WifiP2pServiceImpl use isSystem(packageName, callerUid) with an unverified caller-supplied package name is not shown in the material.
- The behavior of checkPackage on mismatch (whether it throws or only logs) is not shown in the material; the fix's effectiveness depends on it rejecting the call.
Behavior changes
- Callers of getMessenger whose supplied packageName evaluates as system now go through mWifiPermissionsUtil.checkPackage(callerUid, packageName) before the display ID extra is read; the exact outcome for a package/uid mismatch is not shown in the material.
- Legitimate system callers passing their own package name are expected to be unaffected.
- No change for non-system callers.
Per major
- Android 14: same change: commit 070a115e4b1b in android-security-14.0.0_r31, identical 3-line change (unconditional checkPackage call plus @Deprecated/TODO on mDisplayId) at different line offsets; 8/8 patched lines present.
- Android 15: same change: commit 17148822e366 in android-security-15.0.0_r19, cherry-picked from 129a667d459d; per its commit message the mFeatureFlags.validateCallerPackage() check was removed so checkPackage runs unconditionally; 8/8 patched lines present.
- Android 16: same change: commit 2a2f6bc16ce8 in android-security-16.0.0_r10, identical unconditional checkPackage change (no feature flag in the shown diff); 8/8 patched lines present.
- Android 17: same change: commit 6633ea047ae0 in android-security-17.0.0_r3, identical unconditional checkPackage change (no feature flag in the shown diff); 8/8 patched lines present.
Unknowns
- The full body of getMessenger and how the resulting displayId is consumed (including whether it is passed into DeathHandlerData) are not shown.
- Implementation of mWifiPermissionsUtil.isSystem and checkPackage is not in the material, so the exact failure mode on mismatch is not confirmed.
- The source commit 129a667d459d with the feature flag gate, and its branch, are not shown.
- Whether the 14/16/17 commits had the same merge-conflict adaptation is not shown (only their diffs).
- The test change referenced in the commit message is not included.