Vulnerability #12: Insecure Webview Properties Enabled
Last updated
Last updated
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
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.