Skip to content
Commitwise
Menu

What are the main security risks of exported components, intents and WebViews on Android?

AndroidSenior

In shortExported components accept input from any app, so they must be minimal and validate everything; internal communication uses explicit intents and immutable PendingIntents; WebViews must not load untrusted URLs with JavaScript bridges enabled.

Model answer

  • Exported components: since API 31 android:exported must be explicit. Export only real entry points (launcher, App Links, share targets); protect internal IPC with signature-level permissions.
  • Validate input: every extra, URI and action from an exported component is attacker-controlled. Check types, ranges, schemes and hosts. Never forward a received Intent (or one taken from its extras) to startActivity: that’s intent redirection, which lets other apps reach your unexported components.
  • PendingIntents: use FLAG_IMMUTABLE and explicit intents, so whoever holds the PendingIntent can’t change its target or data.
  • Providers: ContentProviders and FileProvider paths must not allow path traversal or expose more than intended; grant URI permissions narrowly.
  • WebViews: JavaScript off unless needed; no addJavascriptInterface for untrusted origins (use origin-restricted addWebMessageListener); allowlist navigation; allowFileAccess = false; open third-party pages in Custom Tabs.
  • Network: release builds trust only system CAs (Network Security Config), with pinning for high-value APIs.
  • Server side: the device can be compromised; Play Integrity verdicts with a nonce and server-side checks decide trust for sensitive operations.

What they're looking for

Knowledge of exported (explicit since API 31), intent validation and intent redirection, PendingIntent mutability, ContentProvider and FileProvider path issues, WebView hardening, and server-side trust with Play Integrity.

Common mistakes

  • Exporting activities "just in case".
  • Forwarding a received Intent extra to startActivity.
  • Using addJavascriptInterface on pages loaded from intent extras.

More android questions

Esc

Type to search the whole site.