Cross-App Scripting (Untrusted Intent -> Exported Activity -> WebView JS)

← Improper Platform Usage

cross_app_scripting   HARD

CategoryImproper Platform Usage
OWASP Mobile (2024)M4
MASVSMASVS-PLATFORM-2MASVS-CODE-4
MASWEMASWE-0035MASWE-0032
MASTG (v2 tests)iOSMASTG-TEST-0332AndroidMASTG-TEST-0031
MASTG demosiOSMASTG-DEMO-0095AndroidNone published
CWECWE-79CWE-749CWE-940
PlatformAndroid

Description

An exported activity takes an attacker-controlled Intent value and passes it to WebView loadUrl()/evaluateJavascript() without validation, giving JS execution in the trusted origin (Google’s named Cross-App Scripting class; Element CVE-2024-26131/26132, FireDown CVE-2024-31974, TikTok CVE-2024-45240).

How it works

An exported activity reads an attacker-controlled Intent extra (a URL string) and hands it straight to a WebView via loadUrl() or evaluateJavascript() with no validation. The WebView is already authenticated to the trusted first-party origin, so a “javascript:” payload from a co-resident malicious app executes in that trusted origin and can read the victim’s cookies and session (Google’s Cross-App Scripting class; Element CVE-2024-26131/26132, FireDown CVE-2024-31974, TikTok CVE-2024-45240). On Android a “javascript:” payload is actually run inside a real in-app WebView committed to the trusted origin, so it executes in that origin and can read the victim’s session. The offline model records what executed and in which origin. The secure path rejects the “javascript:” scheme and only navigates to https URLs on the trusted-origin allowlist.

How to exercise it. DVMA is the harness - open this module from the home index and tap the demo action. The screen ships the malicious input and simulates the attacker (e.g. the companion app, crafted intent, or scanned payload) in-process, and the evidence panel prints the proof. The Tools (optional) and Attack inputs below are only needed to reproduce the exploit end-to-end on a real device.

Exploit steps

  1. Set up. Build DVMA with a flavor that enables the Improper Platform Usage category (e.g. --dart-define-from-file=config/flavors/dev.json) and run on an Android emulator you control. The demo needs no external tooling; for the optional on-device reproduction the relevant tools are: adb, drozer, jadx.
  2. Locate the target. From the home index, open Cross-App Scripting (Untrusted Intent -> Exported Activity -> WebView JS) (cross_app_scripting). The How it works section above describes this module’s specific weakness; the screen states the intended-secure behavior and exposes the vulnerable action.
  3. Exploit. From a co-resident/attacker context (adb shell am start/drozer, or a crafted deep link / QR), send the untrusted input to the exported component or WebView and confirm the app performs the unsafe action (navigation, JS execution, file/URI access) with no validation.
  4. Observe the evidence. Trigger the vulnerable action and read the evidence panel - it prints the concrete proof (leaked value, accepted replay, executed payload, or unauthorized result).
  5. Contrast with the secure path. Run the module’s secure/hardened action (where provided) and confirm the same attack is rejected - this is what a correct implementation should do.
  6. Map it back. Cross-reference the MASTG v2 test(s) MASTG-TEST-0332, MASTG-TEST-0031 for the canonical procedure and remediation.

Tools (optional)

Real-world references

Concrete public disclosures that match this vulnerability class: