Android platform checks

PendingIntent and intent redirection security

Some Android bugs let another app act with your app's identity. Mutable PendingIntents and forwarded intents are the usual cause.

Two related problems

A PendingIntent is a token that lets another app, such as the notification system or a widget host, send an intent as if it came from your app. If the PendingIntent is mutable and its base intent does not name a component, the receiver can fill in the target and extras and reach components that are not exported.

Intent redirection happens when an exported component reads an Intent from its extras and passes it to startActivity, startService or sendBroadcast. The caller can then launch private components or receive URI permission grants. Both belong to MASVS-PLATFORM.

Platform changes to know

  • Apps targeting Android 12 (API 31) or later must declare FLAG_IMMUTABLE or FLAG_MUTABLE on every PendingIntent.
  • Apps targeting Android 14 (API 34) or later cannot create a mutable PendingIntent with an implicit intent; the platform throws an exception unless the app explicitly opts in.
  • StrictMode can report unsafe intent launches during development.

See the Android documentation on pending intent risks and intent redirection.

Static check

Search for PendingIntent.getActivity, getService, getBroadcast and getActivities. For each call, note the flags and whether the base intent sets an explicit component. Then search exported components for code that reads getParcelableExtra or getParcelableExtra(..., Intent.class) and launches the result.

Runtime check

For redirection candidates, build a small unprivileged test app that sends the exported component an intent containing a nested intent aimed at a non-exported activity, and record whether the private screen opens. For PendingIntents, confirm which ones are reachable by another app, such as through notifications, widgets or media sessions.

Commands run from adb shell have shell privileges that a normal app does not; repeat important results from an unprivileged test app before reporting them.

Fix and report

Use FLAG_IMMUTABLE unless mutability is required, and always set an explicit component on the base intent. Do not forward intents received from other apps; if you must, validate the target component and strip URI grant flags. Report the component, the delivery path and the private component that was reached. Related entry points are covered in the deep links guide.

Related reading