πŸ˜‚Vulnerability #12: Insecure Webview Properties Enabled

The WebView class is an extension of Android’s View class that allows you to display web pages as a part of your activity layout. Take note that webviews are not fully fleged browsers, but only shows a web page in the activity. In our target application, we have three activities that utilize webviews:

  • com.insecureshop.WebViewActivity

  • com.insecureshop.WebView2Activity

  • com.insecureshop.PrivateActivity

Webviews are widely used in most android apps, but misconfigurations in these components can lead to dangerous vulnerabilities. Let’s try to analyze some of the webview settings in com.insecureshop.WebView2Activityarrow-up-right

This configuration is dangerous, since combining javaScriptEnabled = true + allowUniversalAccessFromFileURLs = true with the ability to load any arbitrary url can lead to the theft of arbitrary files:

pwned.html

The file above is the html code that will retrieve the contents of the vulnerable application’s share preferences which contains user credentials and exfiltrates it to a remote server. Our code below will write the file into the device’s sdcard directory then start up the vulnerable webview to load the payload file.

MainActivity.kt

The same exploit can be used for the other vulnerabilities in activities where webviews are used.

Last updated