Rapid7 Vulnerability & Exploit Database

Android Browser and WebView addJavascriptInterface Code Execution

Back to Search

Android Browser and WebView addJavascriptInterface Code Execution

Disclosed
12/21/2012
Created
05/30/2018

Description

This module exploits a privilege escalation issue in Android < 4.2's WebView component that arises when untrusted Javascript code is executed by a WebView that has one or more Interfaces added to it. The untrusted Javascript code can call into the Java Reflection APIs exposed by the Interface and execute arbitrary commands. Some distributions of the Android Browser app have an addJavascriptInterface call tacked on, and thus are vulnerable to RCE. The Browser app in the Google APIs 4.1.2 release of Android is known to be vulnerable. A secondary attack vector involves the WebViews embedded inside a large number of Android applications. Ad integrations are perhaps the worst offender here. If you can MITM the WebView's HTTP connection, or if you can get a persistent XSS into the page displayed in the WebView, then you can inject the html/js served by this module and get a shell. Note: Adding a .js to the URL will return plain javascript (no HTML markup).

Author(s)

  • jduck <jduck@metasploit.com>
  • joev <joev@metasploit.com>

Platform

Android,Linux

Architectures

dalvik, x86, armle, mipsle

Development

References

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/android/browser/webview_addjavascriptinterface
msf exploit(webview_addjavascriptinterface) > show targets
    ...targets...
msf exploit(webview_addjavascriptinterface) > set TARGET < target-id >
msf exploit(webview_addjavascriptinterface) > show options
    ...show and set options...
msf exploit(webview_addjavascriptinterface) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;