Skip to content
XSS Write-up Intermediate

Execution Of Arbitrary Javascript In Android Application

The blog describes how exported WebView activities with JavaScript enabled can be exploited via ADB or deep links to execute arbitrary JavaScript. An attacker could inject malicious scripts that run in the context of the WebView, potentially accessing Java interfaces.

WeSecureApp Follow

Published on infosecwriteups.com

In this blog, we will learn about the possible ways to find cross-site scripting by abusing JavaScript in Android applications. Cross-site scripting (XSS) in an Android application occurs when an attacker successfully injects malicious scripts (usually JavaScript) into the application’s user interface, which is then…

WeSecureApp, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the exported WebView activities accept a URL parameter and load it with JavaScript enabled, without validating the URL or restricting JavaScript.

Impact

An attacker could execute arbitrary JavaScript in the context of the app's WebView, potentially accessing exposed Java interfaces, but the blog does not demonstrate specific data theft or further compromise.

What the attacker needed

Android device with the vulnerable app installed; ADB access to the device; Ability to host a malicious HTML file

The fix

The app should avoid exporting WebView activities unnecessarily, validate URLs loaded into WebViews, and disable JavaScript unless required.

How it was found

  1. Use Jadx to decompile the APK and inspect AndroidManifest.xml for exported activities.
  2. Identify a WebView activity that has setJavaScriptEnabled(true).
  3. Host a malicious HTML file containing JavaScript on a local server exposed via Ngrok.
  4. Use ADB to start the exported WebView activity with the URL of the hosted file as an extra string.
  5. Observe the JavaScript executing within the app.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A WebView is a mini-browser inside an Android app. If an app lets other apps or links open a WebView that runs JavaScript, an attacker can make it load a page with harmful code. That code runs inside the app and can do things the app allows, like calling Java functions.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by WeSecureApp

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.