Skip to content

Commit b2e9b71

Browse files
authored
Merge pull request #1207 from HackTricks-wiki/research_update_src_mobile-pentesting_android-app-pentesting_android-task-hijacking_20250729_162414
Research Update Enhanced src/mobile-pentesting/android-app-p...
2 parents 2a7b979 + cde5269 commit b2e9b71

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

src/mobile-pentesting/android-app-pentesting/android-task-hijacking.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,45 @@ The vulnerability reported in the **Caller ID (caller.id.phone.number.block)** a
7474
7575
---
7676

77+
### StrandHogg 2.0 (CVE-2020-0096) – Reflection-based task hijack
78+
79+
Google’s May-2020 security bulletin fixed a more advanced variant dubbed **StrandHogg 2.0**. The exploit **does not rely on `taskAffinity` at all**; instead it uses *reflection* to dynamically insert the attacker’s activity at the top of *every* running task, completely bypassing the “shared-UID” restriction introduced by Android 11.
80+
81+
Key points:
82+
83+
* A zero-permission malicious app can, once opened, iterate over running tasks and call hidden APIs to **re-parent** its own activity into any task.
84+
* Because the activity is inserted after run-time, neither `launchMode` nor static manifest analysis can detect the attack in advance.
85+
* Patched by back-porting a check into **Android 8.0/8.1/9** (May 2020 SPL). **Android 10 and later are not affected.**
86+
87+
Detection on pre-patched devices can be performed with `adb shell dumpsys activity activities` and watching for suspicious activities whose package name differs from the task’s *affinity*.
88+
89+
Mitigation for legacy devices is the same as classic Task Hijacking **plus** run-time verification (e.g. calling [`ActivityManager#getRunningTasks`](https://developer.android.com/reference/android/app/ActivityManager#getRunningTasks(int)) and validating your own package name).
90+
91+
---
92+
7793
## Detection & Exploitation checklist
7894

79-
1. Pull `AndroidManifest.xml` from the target APK and check that each `<activity>` (or the global `<application>` element) contains `android:taskAffinity=""` (empty) **or** a customised value.
80-
2. If not, craft a malicious app:
81-
- `android:taskAffinity` = victim package name.
82-
- Provide a `MAIN/LAUNCHER` intent so the user can open it once.
83-
- Optionally call `moveTaskToBack(true)` to hide immediately.
84-
3. Let the victim open their legitimate application → hijack.
95+
1. **Static review** – Pull `AndroidManifest.xml` from the target APK and check that each `<activity>` (or the global `<application>` element) contains `android:taskAffinity=""` (empty) **or** a customised value. Tools such as:
96+
```bash
97+
# Using apkanalyzer (Android SDK)
98+
apkanalyzer manifest print app.apk | grep -i taskaffinity
99+
100+
# Using AXMLPrinter2
101+
java -jar AXMLPrinter2.jar AndroidManifest.xml | grep taskAffinity
102+
```
103+
2. **Dynamic review** – On the device open the target app and list tasks:
104+
```bash
105+
adb shell dumpsys activity activities | grep -A3 "TASK" | grep -E "Root|affinity"
106+
```
107+
A task whose root affinity equals the victim package but whose top activity belongs to a *different* package is a red flag.
108+
3. Craft a malicious app as described above, or use **[Drozer](https://github.com/WithSecureLabs/drozer)**:
109+
```bash
110+
drozer console connect
111+
run app.activity.start --component com.victim/.MainActivity --action android.intent.action.MAIN
112+
run app.activity.info com.victim
113+
```
114+
115+
---
85116

86117
## Mitigation
87118

@@ -90,6 +121,14 @@ Developers should:
90121
* Explicitly set `android:taskAffinity=""` at the `<application>` level (recommended) **or** give each activity a unique, private affinity.
91122
* For highly sensitive screens, combine the above with `android:launchMode="singleInstance"` or modern [`setLaunchMode`](https://developer.android.com/reference/android/content/pm/ActivityInfo#launchMode) protections.
92123
* Upgrade the app’s `targetSdkVersion` and enforce **Android 11** behavioural changes where tasks are not shared across packages by default.
124+
* Target **Android 12 (API 31) or higher** so that the mandatory `android:exported` attribute forces developers to audit every externally-reachable component.
125+
* Consider run-time self-defence: periodically query `ActivityTaskManager` to ensure that your top activity’s package matches your own.
126+
127+
---
128+
129+
## Related UI-Hijacking techniques
130+
131+
Task hijacking is often combined with or replaced by **tapjacking** (overlay-based UI deception). The 2025 **TapTrap** research showed that fully transparent *animation-driven* activities can bypass the overlay-touch restrictions introduced in Android 12–14 and still trick users into granting dangerous permissions. While TapTrap is not strictly *task* hijacking, the end-goal (phishing clicks) is identical – so modern assessments should check for both attack surfaces.
93132

94133
---
95134

@@ -99,5 +138,7 @@ Developers should:
99138
- [https://blog.takemyhand.xyz/2021/02/android-task-hijacking-with.html](https://blog.takemyhand.xyz/2021/02/android-task-hijacking-with.html)
100139
- [Android Manifest Misconfiguration Leading to Task Hijacking in Caller ID app](https://github.com/KMov-g/androidapps/blob/main/caller.id.phone.number.block.md)
101140
- [https://medium.com/mobile-app-development-publication/the-risk-of-android-strandhogg-security-issue-and-how-it-can-be-mitigated-80d2ddb4af06](https://medium.com/mobile-app-development-publication/the-risk-of-android-strandhogg-security-issue-and-how-it-can-be-mitigated-80d2ddb4af06)
141+
- [Promon – StrandHogg 2.0 (CVE-2020-0096) technical write-up](https://promon.io/resources/downloads/strandhogg-2-0-new-serious-android-vulnerability)
142+
- [USENIX 2025 – TapTrap: Animation-Driven Tapjacking on Android](https://www.usenix.org/conference/usenixsecurity25/presentation/beer)
102143

103144
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)