Skip to main content
Be Bitwise

Intent & URL Scheme Injection

Mobile Application Vulnerability Classes · Mobile Application Security track

13 min read

In this module

How Mobile Apps Talk to Each Other

Desktop apps talk to each other through familiar plumbing: pipes, sockets, shared memory, the windowing system's clipboard. Mobile platforms threw all of that out. Because mobile apps live inside sandboxes with strict process isolation, the OS hands them a structured messaging system to chat through instead. On Android that system is intents. On iOS it's URL schemes and Universal Links.

These channels are why your phone feels seamless. A browser opening Maps, a messaging app pushing content into Instagram, a password manager autofilling into another app — that's all this machinery. It's also a fat attack surface. Apps that don't validate incoming messages, or that send sensitive data over the wrong channel, hand attackers the ability to intercept, redirect, and forge.

Android Intents: The Basics

An Android intent is a messaging object describing an operation. It bundles an action string (what to do), data (a URI), extras (key-value pairs), an optional component name, and a category. Intents are the lingua franca for both intra-app and inter-app communication on Android.

Two flavours:

Explicit intents name the target component outright (package + class). They're how internal app communication happens. Other apps can't intercept them, because the system delivers them straight to the named recipient.

Implicit intents describe what they want done but don't name a target. Android resolves them by matching against intent filters declared by every installed app. Any app whose filter matches becomes a candidate handler.

xml
<!-- An app declares it can handle VIEW actions for https URLs -->
<activity android:name=".LinkHandlerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" android:host="example.com" />
</intent-filter>
</activity>
Intent Resolution

When you send an implicit intent, Android compares its action, data, and category against every intent filter declared on the device. One match: delivered straight there. Multiple matches: the chooser dialog pops up and the user picks. That resolution dance is what makes intents flexible — and exactly where the security problems live.

Intent Filters and Exported Components

Declare an intent filter on a component and you implicitly export it. Other apps can now poke it. The android:exported attribute lets you spell that out in the manifest, but for years plenty of developers had no idea declaring a filter was exporting them.

Android 12 (API 31) closed the trapdoor: any component with an intent filter now has to set android:exported explicitly. The whole change was a response to how many production apps had accidentally exported components without realising.

Try it on a manifest. The app below targets API 30, before the Android 12 rule kicked in. Which components can another app start?

xml
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TransferActivity">
<intent-filter>
<action android:name="com.bank.app.TRANSFER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity" />
<service android:name=".SyncService" android:exported="true" />
<receiver android:name=".PushReceiver" android:exported="false">
<intent-filter>
<action android:name="com.bank.app.PUSH" />
</intent-filter>
</receiver>
Show the answer

MainActivity, TransferActivity and SyncService are reachable. The two activities are exported implicitly because they declare intent filters, and SyncService says so outright. SettingsActivity has no filter and no attribute, so it defaults to private. PushReceiver has a filter, but the explicit exported="false" wins. From a shell, adb shell am start -n com.bank.app/.TransferActivity --es recipient attacker_account --ed amount 10000 fires the vulnerable activity in the next section, no malicious app required. (--ed for double extras arrived in Android 13's am; older builds only offer --ef for floats.)

Intent Injection Attacks

Intent injection happens when an attacker fires a crafted intent at an exported component that doesn't bother to validate what it receives. Same shape as command injection on the web: input gets treated as instructions instead of data.

Picture a banking app with an exported activity that processes transfers:

java
// Vulnerable: exported activity processes intent data without validation
public class TransferActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String recipient = intent.getStringExtra("recipient");
double amount = intent.getDoubleExtra("amount", 0.0);
// Processes transfer without verifying caller identity
processTransfer(recipient, amount);
}
}

A malicious app on the same device can construct and send an intent to this activity:

java
// Attacker's malicious app
Intent attack = new Intent();
attack.setComponent(new ComponentName(
"com.bank.app", "com.bank.app.TransferActivity"));
attack.putExtra("recipient", "attacker_account");
attack.putExtra("amount", 10000.0);
startActivity(attack);

The bank app happily moves the money. It never asked who sent the intent.

PendingIntent Vulnerabilities

A PendingIntent is a token wrapping an intent and lending another app the right to execute it on your behalf. Notifications, alarms, and widget updates all run on PendingIntents.

Trouble starts when an app builds a PendingIntent around a mutable base intent and hands it off to a component it doesn't trust. The recipient can edit the mutable fields before firing it — different action, different data, different target.

java
// Vulnerable: mutable PendingIntent with implicit base intent
Intent base = new Intent("com.example.ACTION");
// FLAG_MUTABLE allows the recipient to fill in unspecified fields
PendingIntent pi = PendingIntent.getActivity(
this, 0, base, PendingIntent.FLAG_MUTABLE);

The fix: FLAG_IMMUTABLE plus an explicit intent as the base. No mutability, no redirection. Android 12 doesn't make immutability the default, by the way: apps targeting API 31 or later have to pass either FLAG_IMMUTABLE or FLAG_MUTABLE explicitly, and the call throws if they pass neither.

Activity Hijacking

Activity hijacking abuses the implicit-intent resolution path. When a legit app fires off an implicit intent, a malicious app that registered a matching filter can swoop in and grab it.

The attack is particularly effective when:

  • The user selects the malicious app from the chooser dialog (social engineering)
  • The malicious app is the only match (the legitimate handler was uninstalled or not yet installed)
  • The intent carries sensitive data in extras (authentication tokens, personal information)

A clever attacker plays middleman: receive the intent, skim the sensitive bits, then forward it on to the real handler. The user sees the app behave exactly as expected. The attacker quietly siphons the data.

iOS Custom URL Schemes

iOS leans on URL schemes for inter-app communication. An app registers a custom scheme (myapp://) in its Info.plist, and from then on anything that opens a URL with that scheme — another app, a website, an email — launches the registered app with the URL as input.

xml
<!-- Info.plist registration -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>

Custom URL Scheme Hijacking

The fatal weakness of custom URL schemes: no ownership check. Any app can claim any scheme. Two apps both register myapp:// and iOS doesn't make any guarantees about who wins. Drop a malicious app on the device that grabs the same scheme as a legit one and you can quietly intercept URLs meant for the real app.

This is particularly dangerous for OAuth authentication flows. Many apps use URL schemes as redirect URIs in OAuth:

  1. The app opens a browser to the OAuth provider's authorisation page
  2. The user authenticates and authorises the app
  3. The OAuth provider redirects to myapp://callback?code=AUTH_CODE
  4. The app receives the authorisation code and exchanges it for a token

If a malicious app has snuck onto the device and grabbed myapp://, it pockets the authorisation code instead. From there, it has everything it needs to swap that code for a token and pretend to be the user.

Unless the real app used PKCE. Follow the sequence to the token request: without PKCE the stolen code is all the attacker needs, but with it the token endpoint also wants the secret code_verifier, which never left the real app.

PKCE makes the stolen code worthless. It doesn't stop the interception itself, and that's what Universal Links fix.

Key Concept
URL Scheme Hijacking

Custom URL schemes on iOS have no ownership verification. Any app can register any scheme, and if a malicious app registers the same scheme as a legitimate app, it may intercept URLs intended for the legitimate app. This is especially dangerous for OAuth flows where authorisation codes are delivered via URL scheme redirects. Universal Links provide a verified alternative.

To plug the hijacking hole, Apple shipped Universal Links in iOS 9 and Google shipped App Links in Android 6.0. Same idea on both sides: the developer proves they own a domain by hosting a verification file on their HTTPS server.

iOS Universal Links require an apple-app-site-association file at https://example.com/.well-known/apple-app-site-association. This JSON file lists the app's bundle identifier and the URL paths the app should handle. iOS downloads and caches this file when the app is installed, and only the verified app can handle those URLs.

Android App Links require an assetlinks.json file at https://example.com/.well-known/assetlinks.json that contains the app's package name and signing certificate fingerprint. Android checks it when the app is installed or updated. From Android 12, a web link only opens straight into the app if that check passed; otherwise it goes to the browser. The user still gets the last word, though: the per-app "Open by default" settings let them approve or revoke link handling for a domain by hand.

Because the verification file lives on the domain's HTTPS server, hijacking a link means popping the web server. That's a much higher bar than registering a URL scheme on a local device.

Verified deep links don't save you from your own parser. The link parameters are still attacker-controlled input, no different from query strings on a web app.

Common bypass techniques include:

Path traversal in deep links: If the app uses the deep link path to load a local file or navigate to an internal screen without sanitisation, an attacker can craft a link that accesses unintended resources.

Parameter injection: Deep link parameters may be passed to internal APIs, WebViews, or database queries without validation. A deep link like https://example.com/app/page?url=javascript:alert(1) might load attacker-controlled content in a WebView if the url parameter is not validated.

The usual fix for that WebView case is a domain check before loading the URL, and the usual bug is checking the wrong thing. The parsing is plain string handling, so it runs fine in C. Three checks, five URLs:

Try itPredict each ALLOW and deny before running, then add a URL of your own that slips past the prefix check.
C (GCC 9.2.0)

Intent redirection through deep links: On Android, a deep link handler might create a new intent based on parameters in the deep link URL. If the attacker can control the target component or action of this secondary intent, they can redirect execution to arbitrary components.

java
// Vulnerable: deep link handler creates intent from URL parameters
Uri data = getIntent().getData();
String targetClass = data.getQueryParameter("component");
Intent redirect = new Intent();
redirect.setClassName(getPackageName(), targetClass);
startActivity(redirect);

Hand the deep link component=com.app.PrivateSettingsActivity and the attacker fires up non-exported activities from inside the app's own process, sailing past the access controls that were supposed to keep them locked away.

Deep Link Input Validation

Treat deep link parameters with the same suspicion as anything off the network. Path components, query parameters, fragments — all of it gets validated against an allowlist of expected values. Never use deep link data to build file paths, choose intent targets, or compose SQL without strict sanitisation.

Defensive Recommendations

Locking down inter-app communication takes several overlapping practices:

  • Use explicit intents for anything internal. The moment your target lives in the same app, you should be naming it directly.
  • Validate caller identity in exported components. getCallingActivity() plus PackageManager will tell you which package is on the other end and what signature it carries, but only when the caller used startActivityForResult(). For a plain startActivity() it returns null, so don't build your only check on it. For services and providers, Binder.getCallingUid() gives you the caller's UID to look up, and a signature-level permission on the component lets the system do the check for you.
  • Mark PendingIntents immutable unless you have a real reason not to. Always pair them with an explicit base intent.
  • Prefer Universal Links and App Links over custom URL schemes wherever sensitive data is in play, especially OAuth callbacks.
  • Treat every deep link parameter as untrusted. Allowlist it, sanitise paths, and never let deep link data choose internal components on the fly.
  • Set android:exported="false" on anything that doesn't actually need to receive cross-app intents.
  • Use signature-level permissions to gate exported components, so only apps you signed yourself can talk to them.