An implicit intent is broadcast without a receiver permission, so any app can receive it

tx0/kotlin:broadcast-without-permissionstrictwarningsecurity/authn-authzdepth fastsecurity, android, cwe-927

What it finds

A broadcast sent with an implicit intent and no receiver permission reaches every app that registers for its action, including ones installed to listen. Whatever the extras carry, account names, tokens or file paths, is then readable by them, and an ordered broadcast can even be answered by them. Naming the target package or component, or requiring a permission, limits who receives it.

Reported for sendBroadcast, sendOrderedBroadcast and sendStickyBroadcast without a permission (or with null), when the intent is plainly implicit: it is made in the function as Intent(action) or Intent(), without a class, and no setPackage, setClass, setComponent, package or component is applied to it. Intents from parameters or other functions, local broadcasts and files that import nothing from Android are left alone.

From the rule's source, broadcast_without_permission.rs.

Example from the rule's tests
import android.content.Contextimport android.content.Intent class Notifier(private val context: Context) {    fun announce(token: String) {        val intent = Intent("com.example.LOGGED_IN")        intent.putExtra("token", token)        context.sendBroadcast(intent)tx0 reports: the broadcast can be received by any app that asks for its action        context.sendBroadcast(Intent("com.example.PING"), null)tx0 reports: any app        context.sendBroadcast(Intent("com.example.PING"), "com.example.permission.RECEIVE")        val targeted = Intent("com.example.LOGGED_IN")        targeted.setPackage("com.example.partner")        context.sendBroadcast(targeted)        context.sendBroadcast(Intent(context, Receiver::class.java))        context.sendBroadcast(Intent("x").apply { setPackage(context.packageName) })        localBroadcastManager.sendBroadcast(Intent("com.example.LOCAL"))        context.sendBroadcast(Intent(context, providerClass).apply { action = "x" })        val made = Factory.createIntent(context)        context.sendBroadcast(made)        context.sendBroadcast(Intent(Intent.ACTION_VIEW).putExtra("token", token))tx0 reports: any app    }     fun forward(intent: Intent) {        context.sendBroadcast(intent)    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:broadcast-without-permission" = "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:broadcast-without-permission] reason="..."

tx0 explain tx0/kotlin:broadcast-without-permission shows the same in the terminal. Found a false positive? Report it.