Only allow root/system UIDs to send broadcast to unexported receiver

Android T introduced new flags to specify whether a runtime receiver
should be exported to other apps on the device. Initially, an unexported
runtime receiver could receive broadcasts from any app with a UID
that passed the Process#isCoreUid check, but this behavior differs
from that of unexported manifest receivers which can only receive
broadcasts from the system and root UIDs. This commit updates the
behavior of runtime receivers registered with the RECEIVER_NOT_EXPORTED
flag to only allow broadcasts to be sent from the local app, system, and
root UIDs.

Bug: 225999840
Test: atest ContextTest
Change-Id: Idc2c42dda58d54859e9beb8bd8baf3810aeabefc
This commit is contained in:
Michael Groover
2022-03-21 17:28:33 -07:00
parent 27e35ec6c3
commit 6ea76aa7e5

View File

@@ -869,9 +869,9 @@ public final class BroadcastQueue {
// Ensure that broadcasts are only sent to other apps if they are explicitly marked as
// exported, or are System level broadcasts
if (!skip && !filter.exported && !Process.isCoreUid(r.callingUid)
&& filter.receiverList.uid != r.callingUid) {
if (!skip && !filter.exported && mService.checkComponentPermission(null, r.callingPid,
r.callingUid, filter.receiverList.uid, filter.exported)
!= PackageManager.PERMISSION_GRANTED) {
Slog.w(TAG, "Exported Denial: sending "
+ r.intent.toString()
+ ", action: " + r.intent.getAction()