You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- App A expects a sensitive result from App B using an implicit Intent (e.g., an OAuth redirect, a document picker result, an IMAGE_CAPTURE return, or a custom callback action).
208
+
- Attacker App C publishes an exported component with a matching `<intent-filter>` for the same `action`/`category`/`data`. When B resolves the implicit Intent, the resolver may present a chooser; if the user picks C (or sets it as default), the payload is delivered to the attacker component instead of A.
- Match specificity matters (action + categories + data). The more specific C’s filter is to B’s outgoing Intent, the higher the chance it is shown or auto-selected.
239
+
- This also applies to deep links (`VIEW` + `BROWSABLE`) when apps expect another app to handle a URL and return something back.
240
+
241
+
Pentest guidance
242
+
- Grep the target for `startActivity`/`startActivityForResult`/`registerForActivityResult` calls using non-explicit Intents.
243
+
- Inspect Intents carrying tokens in `extras`, `clipData`, or `getData()` and see whether a third-party could register a compatible filter.
244
+
- Recommend replacing implicit flows with explicit Intents (set `setPackage()`/`setComponent()`), or requiring caller-permission/signed permissions on exported receivers/services.
When you control the sender, add `Intent.FLAG_DEBUG_LOG_RESOLUTION` to an implicit Intent to make Android log how resolution happens and which component will be selected.
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/webview-attacks.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -383,6 +383,41 @@ xhr.open(
383
383
xhr.send(null)
384
384
```
385
385
386
+
## WebView XSS via Intent extras → loadData()
387
+
388
+
A frequent vulnerability is reading attacker-controlled data from an incoming `Intent` extra and injecting it directly into a WebView via `loadData()` with JavaScript enabled.
389
+
390
+
Vulnerable pattern (exported Activity reads extra and renders it as HTML):
391
+
```java
392
+
String data = getIntent().getStringExtra("data");
393
+
if (data ==null) { data ="Guest"; }
394
+
WebView webView = findViewById(R.id.webview);
395
+
webView.getSettings().setJavaScriptEnabled(true);
396
+
webView.setWebChromeClient(newWebChromeClient());
397
+
String userInput ="\n\n# Welcome\n\n"+"\n\n"+ data +"\n\n";
If that Activity is exported (or reachable through an exported proxy), a malicious app can supply HTML/JS in the `data` extra to achieve reflected XSS:
402
+
```bash
403
+
# Replace package/component with the vulnerable Activity
404
+
adb shell am start -n com.victim/.ExportedWebViewActivity --es data '<img src=x onerror="alert(1)">'
405
+
```
406
+
407
+
Impact
408
+
- Arbitrary JS in the app’s WebView context: enumerate/use `@JavascriptInterface` bridges, access WebView cookies/local storage, pivot to file:// or content:// depending on settings.
409
+
410
+
Mitigations
411
+
- Treat all Intent-derived inputs as untrusted. Escape (`Html.escapeHtml`) or reject HTML; prefer rendering untrusted text as text, not HTML.
412
+
- Keep JavaScript disabled unless strictly required; do not enable `WebChromeClient` for untrusted content.
413
+
- If you must render templated HTML, use `loadDataWithBaseURL()` with a safe base and CSP; separate trusted/untrusted WebViews.
414
+
- Avoid exposing the Activity externally or protect it with permissions when not needed.
415
+
416
+
Related
417
+
- See Intent-based primitives and redirection in: [Intent Injection](intent-injection.md)
418
+
419
+
420
+
386
421
## References
387
422
388
423
-[Review of Android WebViews file access attack vectors](https://labs.integrity.pt/articles/review-android-webviews-fileaccess-attack-vectors/index.html)
0 commit comments