A broadcast receiver is registered without saying whether other apps may send to it
What it finds
Since Android 14, an app targeting it has to pass RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED when it registers a receiver for broadcasts that are not system broadcasts, and gets a SecurityException otherwise. Without the flag on older versions the receiver is exported, so any app can send it intents.
From the rule's source, receiver_without_export_flag.rs.
fun listen(context: Context, receiver: BroadcastReceiver, filter: IntentFilter) { context.registerReceiver(receiver, filter)tx0 reports: the receiver is registered without RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED) ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED) LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter)} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:receiver-without-export-flag" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:receiver-without-export-flag] reason="..."tx0 explain tx0/kotlin:receiver-without-export-flag shows the same in the terminal. Found a false positive? Report it.