23
WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONS Erika Chin and David Wagner UC Berkeley

WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONS

Erika Chin and David Wagner

UC Berkeley

Page 2: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

2

Page 3: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

ORGANIZATION

¢ WebViews

¢ Danger of WebViews

¢ Bifocals

¢ Results

¢ Common developer confusion

¢ Recommendations 3

Page 4: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

WEBVIEWS

¢ Allow the developer to display web content within their own app

¢  70% of applications use WebViews

4

Page 5: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

WEBVIEWS

5

iPhone

Android

Kindle Fire

Web app

Page 6: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

ABILITY OF WEBVIEWS

6

¢ Developers can allow JavaScript in the WebView to invoke application code

¢ Gives websites access to system resources and data

Page 7: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

EXAMPLE

Mobile app code: myWebView.addJavascriptInterface(!

! ! ! !new MobileClass(),!! ! ! !“Mc”);!

Web app code: <script>!

!Mc.mobileFunction(x,y,z);!</script>!

7

Page 8: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

EXCESS AUTHORIZATION VULNERABILITY

¢ Code access is granted to any JavaScript loaded in the WebView1

¢ Web content can contain malicious JavaScript �  Frames �  User Navigation

¢ Network can be malicious (http vs. https) �  Man-in-the-middle attacker

8

1Luo, ACSAC

Page 9: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

ALIVE APP EXAMPLE

9 Website

WebView

Page 10: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

ALIVE APP EXAMPLE

10

WebView

App

3rd party content

Links

MITM Attacker

Page 11: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

BIFOCALS

Two-part tool: Mobile and Web

1.  Statically analyzes app’s WebViews 2.  Dynamically analyzes loaded websites

11

Static Analysis

Exposes Interfaces

Web crawler URIs Vuln.

WebViews

Page 12: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

BIFOCALS, PT. 1

¢ Flow-sensitive interprocedural static analysis

¢ Analyzes apps’ WebViews to determine: �  URI loaded �  Ability to navigate the web

�  Whether it grants access to code and privileged resources ¢ Transitive calls ¢ Returned objects ¢ Inheritance ¢ Java reflection

12

Page 13: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

BIFOCALS, PT. 2

¢ Crawls websites to a nested depth of 3

¢ Dynamically analyzes loaded websites for: �  Insecure communication (http://) �  Third-party content

¢ Ads (via AdBlock) ¢ Frames ¢ Links

13

Page 14: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

EVALUATION: PREVALENCE

¢ Ran our tool on ~1000 applications

¢  70% of applications use WebViews

¢  20% of applications with WebViews expose interfaces

¢  11% of apps with WebViews are vulnerable �  11% via network attacker (MITM) �  9% via web attacker

Over half of apps that register interfaces are vulnerable 14

Page 15: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

EVALUATION: IMPACT

¢ By permission use

¢  56% of vulnerable apps give attackers access to privileged resources �  Access to unique device ID �  Access to the SD card �  Keeping the phone awake

15

Page 16: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

SOURCE OF CONFUSION

¢ Registering an interface may expose more code than intended �  Any public method in the interface �  Transitive calls �  Parent classes �  Returned objects’ methods

16

Page 17: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

SOURCE OF CONFUSION

¢ Developers may give more websites access to the mobile app than intended �  Embedded content – frames, ads �  Navigation

¢  Implicit changes to navigation policy ¢  Difficulties implementing policy

17

Page 18: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

IMPLICIT CHANGES TO NAVIGABILITY

!

!

WebView webview = new WebView(…);!!webview.setWebViewClient(new ! !

!WebViewClient());!

18

Page 19: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

NAVIGATION POLICY: UNNECESSARY CODE Default: public boolean shouldOverrideUrlLoading(WebView

!view, String url)!{! return false;!}! Overridden: public boolean shouldOverrideUrlLoading(WebView!

!view, String url)!{! view.loadUrl(url);! return true;!}! 19

Page 20: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

DEVELOPER RECOMMENDATIONS

¢ Limit JavaScript in WebViews

¢ Limit navigability

¢ Limit access to application code

20

Page 21: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

PLATFORM RECOMMENDATIONS

¢ Use a domain-based policy for interface access

¢ Approach �  Infer trusted domain �  Supplement with a whitelist

¢ Patches 60% of vulnerabilities found

21

Page 22: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

CONCLUSION

¢ Mobile platforms provide powerful APIs to enable rich interaction in apps

¢ Developers may not realize the consequences of their design

¢ We need to help developers create secure apps

22

Page 23: WEBVIEW VULNERABILITIES IN ANDROID APPLICATIONSscrub.cs.berkeley.edu/wp-content/uploads/2013/05/Web... · 2013. 5. 30. · Android Kindle Fire Web app . ABILITY OF WEBVIEWS 6 ! Developers

Thank you!

[email protected]

23