Skip to content
Mobile Write-up Intermediate

Analyzing an Android WebView exploit

On Android versions older than 4.2, the WebView addJavascriptInterface method exposed all public Java methods of an injected object to any web page loaded in the view. An attacker could host a malicious page that, when opened in a vulnerable app, calls those Java methods to install software, send SMS messages or steal personal data.

blogs.avg.com

Published on blogs.avg.com

{{media:0}}There’s a vulnerability that affects WebView control in AndroidTM applications installed on Android devices running versions older than 4.2.

The author, on blogs.avg.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 addJavascriptInterface bridge exposed every public Java method of the injected object to untrusted web content, with no restriction to methods the developer intended to share.

Impact

An attacker could install malicious software, send SMS messages and steal personal information, though actions like sending SMS only work if the vulnerable app already holds the matching permission.

What the attacker needed

Android older than 4.2; app uses addJavascriptInterface; app loads attacker-controlled page; victim opens a malicious link

The fix

Android 4.2 changed the behaviour so only methods annotated with @JavascriptInterface are reachable from JavaScript, and developers should avoid exposing unsafe functions.

How it was found

  1. The user opens a link in a vulnerable app that loads web pages in a WebView.
  2. The WebView loads the attacker's page, which contains JavaScript commands.
  3. The JavaScript calls the injected Java object's methods.
  4. The device performs the actions the page ordered, such as sending SMS or installing software.

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.

An Android app can show web pages inside itself using a component called WebView. Older Android versions let any web page shown there reach into the app's own Java code, so a page written by an attacker could make the app do things like send texts or install apps. Newer Android versions only expose methods the developer explicitly marks as safe.

What is Mobile?

Flaws specific to Android and iOS apps: exported components, deep links, WebViews and data left on the device.

Similar reports

View all

Same bug class and techniques, clearest first.

Mobile app vulnerabilities

The lesson behind this report.

Flaws specific to Android and iOS apps: exported components, deep links, WebViews and data left on the device.