Quick viewing(Text Mode)

Iframes/Popups Are Dangerous in Mobile Webview: Studying and Mitigating Differential Context Vulnerabilities

Iframes/Popups Are Dangerous in Mobile Webview: Studying and Mitigating Differential Context Vulnerabilities

Iframes/Popups Are Dangerous in Mobile WebView: Studying and Mitigating Differential Context Vulnerabilities GuangLiang Yang, Jeff Huang, and Guofei Gu, Texas A&M University https://www.usenix.org/conference/usenixsecurity19/presentation/yang-guangliang

This paper is included in the Proceedings of the 28th USENIX Security Symposium. August 14–16, 2019 • Santa Clara, CA, USA 978-1-939133-06-9

Open access to the Proceedings of the 28th USENIX Security Symposium is sponsored by USENIX. Iframes/Popups Are Dangerous in Mobile WebView: Studying and Mitigating Differential Context Vulnerabilities

GuangLiang Yang, Jeff Huang, Guofei Gu Texas A&M University {ygl, jeffhuang, guofei}@tamu.edu

Abstract Inconsistencies Between Browsers and WebView. How- ever, in WebView, a totally different working environment In this paper, we present a novel class of Android Web- is provided for iframes/popups, due to WebView’s own pro- View vulnerabilities (called Differential Context Vulnerabili- gramming and UI features. Although these features improve ties or DCVs) associated with web iframe/popup behaviors. app performance and user experience, they extensively impact To demonstrate the security implications of DCVs, we de- iframe/popup behaviors and introduce security concerns. In vise several novel concrete attacks. We show an untrusted particular, WebView enables several programming APIs (Fig- web iframe/popup inside WebView becomes dangerous that ure1) to help developers customize iframe/popup behaviors. it can launch these attacks to open holes on existing defense For example, the setting APIs allow developers to configure solutions, and obtain risky privileges and abilities, such as their WebView instances. In the customized web environment breaking integrity, stealthily accessing sensi- (WebView), it is unclear whether existing iframe/popup pro- tive mobile functionalities, and performing phishing attacks. tection solutions are still effective. Then, we study and assess the security impacts of DCVs on real-world apps. For this purpose, we develop a novel tech- Furthermore, WebView UI is designed in a simple style nique, DCV-Hunter, that can automatically vet Android apps (Figure2) that only one UI area for rendering web content is against DCVs. By applying DCV-Hunter on a large number provided. Due to the lack of the address bar, it is difficult for of most popular apps, we find DCVs are prevalent. Many high- users to learn what web content is being loaded; due to the profile apps are verified to be impacted, such as Facebook, lack of the tab bar, it is unknown how multiple WebView UI Instagram, Facebook Messenger, Google News, Skype, Uber, instances (WUIs) are managed. Therefore, if an iframe/popup Yelp, and U.S. Bank. To mitigate DCVs, we design a multi- has abilities to secretly navigate the main (the top level solution that enhances the security of WebView. Our frame) or put their own WUI to the foremost position for evaluation on real-world apps shows the mitigation solution overlaying the original WUI, phishing attacks occur and may is effective and scalable, with negligible overhead. cause serious consequences. Consider the scenario shown in Figure3 and4. The Huntington banking app (one million+ 1 Introduction downloads) uses WebView to help users reset passwords (Fig- ure3-a,b). Inside WebView, the main frame contains an iframe Nowadays, mobile app developers enjoy the benefits of the for isolatedly loading untrusted third-party tracking content amalgamation of web and mobile techniques. They can easily (Figure4). However, if the untrusted web content inside the and smoothly integrate all sorts of web services in their apps iframe obtains the ability of stealthily redirecting the main (hybrid apps) by embedding the browser-like UI component frame to a fake (Figure3-c), serious security risks are “WebView”. WebView is as powerful as regular web browsers posed. For example, users’ personal (e.g., SSN info and Tax (e.g., desktop browsers), and well supports web features, in- ID) and bank account information may be stolen, and further cluding the utilization of iframes/popups. financial losses may also be caused. In the web platform, iframes/popups are frequently used, but also often the root cause of several critical security is- Differential Context Vulnerability (DCV). Motivated by sues (e.g., frame hijacking [11] and clickjacking [23, 43]). above security concerns, we conduct the first security study of In past years, in regular browsers, their behaviors have been iframe/popup behaviors in the context of Android WebView. well studied, and a variety of mature iframe/popup protec- In this paper, we use the term “context” to refer to a web tion solutions (e.g., Same Origin Policy (SOP) [6], HTML5 environment that includes GUI elements (e.g., the address iframe sandbox [4], and navigation policies [11]) have been and tab bars), corresponding web management APIs (e.g., the deployed. setting APIs in WebView), and security policies (e.g., SOP

USENIX Association 28th USENIX Security Symposium 977 Table 1: A Summary of Differential Context Vulnerabilities (DCVs) Critical Features Different Contexts Attacks Explanations Consequences & Behaviors Browsers WebView Sensitive functionalities behind postMessage and JavaScript Bridges can be leveraged, Main-Frame Address Special common origins Java APIs Origin Hiding Attack which may cause the leakage of sensitive Creation Bar (e.g., null) Of Main-Frame information (e.g., location), and risky access on Hardware (e.g., camera and microphone) Management of Android WUI overlap attack No protection on the WUI Tab Bar new popups Frameworks WUI closure attack rendering sequence Traditional navigation Permissive navigation Phishing attacks based attack policies Main-Frame Address Java APIs Harmful conflict between Navigation Bar Privileged navigation WebView Customizations attack and web APIs and navigation policies). As a consequence, our study uncovers a novel class of vulnerabilities and design flaws in WebView. These vulner- abilities are rooted in the inconsistencies between different contexts of regular browsers and WebView. As summarized in Table1, several critical web features and behaviors (i.e., main- frame creation, popup creation, and main-frame navigation) Figure 1: WebView Programming Features are involved (see more details in Section3). These features and behaviors are harmless or even safe in the context of regular browsers, but become risky and dangerous in the con- 1) For origin-hiding attacks, existing defense solutions for text of WebView. To demonstrate their security implications, postMessage [11, 44, 47, 52] and web-mobile bridges we devise several concrete attacks. We show through these [18, 21, 38, 45, 49] usually provide security enforcement attacks, remote adversaries (e.g., web or network attackers relying on origin validation. However, unfortunately, the on iframes/popups) can obtain several unexpected and risky key origin information of the untrusted iframe/popup can privileges and abilities: be hidden during attacks, which leads to the bypass of the security enforcement. Origin-Hiding 1) : hiding the origin when 2) For WUI redressing attacks, they are similar to Android • breaking the integrity of web messaging (i.e., postMes- UI redressing attacks [15, 20, 35]. However, the associ- sage) [8], which allows the communication between ated Android UI protection solutions (e.g., [13, 41]) are mutually distrusted web frames; and circumscribed to prevent WUI addressing attacks. This is • secretly accessing web-mobile bridges [21], which link mainly because that these protections work by monitoring mobile native the web layer with the or layer (e.g., Java exceptional Android UI state changes between different for Android) (Figure1); apps, while the WUI state change occurs within an app Existing work has shown that postMessage’s message during attacks. receivers [44, 47] and web-mobile bridges [21, 49, 53] 3) For main-frame navigation attacks, one related solution is often carry sensitive functionalities. Thus, these function- the iframe sandbox security mechanism, which can effec- alities can be further stealthily accessed by the untrusted tively limit the navigation capability of an arbitrary iframe. iframe/popup through the attack. As a result, sensitive However, through DCV attacks, an untrusted iframe can information (e.g., GPS location) may be stolen, and impor- still break the above limitation and cause privilege escala- tant hardware (e.g., microphone) may be unauthorizedly tion. accessed. 2) WebView UI Redressing: performing phishing attacks by More details about the vulnerabilities and the weakness of overlapping the foremost benign WUI with an untrusted existing defense solutions are presented in Section3. For WUI; convenience, considering the root reason of this new type of 3) (Privileged) Main-Frame Navigation: freely redirecting vulnerability (i.e., the inconsistencies between the contexts of the main frame to a fake website. regular browsers and WebView), we refer to the vulnerabili- ties as Differential Context Vulnerabilities or DCVs, and the Moreover, we examine the effectiveness of existing protec- associated attacks as DCV attacks. tion solutions, which include not only the solutions designed for regular browsers (inherited by WebView), but also the DCV-Hunter & Findings. We next study and assess the se- solutions proposed for Android UI and WebView. We find curity impact of DCVs on real-world hybrid apps. To achieve that these solutions are ineffective to defend against the above the goal, we develop a novel static vulnerability detection tech- attacks: nique, DCV-Hunter, to automatically vet given apps against

978 28th USENIX Security Symposium USENIX Association Figure 4: Attack Scenario

Figure 2: UI Comparison

Figure 5: Attacking Facebook Messenger Figure 3: Attacking the Huntington Bank App Instagram. In addition to the vulnerable library, we find this DCVs. Then, by applying DCV-Hunter on a number of most design flaw is shared by many other popular apps that are not popular apps, we show that DCVs are prevalent. More specif- equipped with that library, such as Kakao Talk (100 million+ ically, we find 38.4% of 11,341 hybrid apps are potentially downloads). vulnerable, including 13,384 potentially vulnerable WebView instances and 27,754 potential vulnerabilities. Up to now, the We have reported our findings to the Android security team potentially impacted apps have been downloaded more than and many app developers. Up to now, a number of them (e.g., 19.5 Billion times in total. Furthermore, our evaluation shows the Android and Facebook security teams) have confirmed DCV-Hunter is scalable and effective, and has relatively low our findings. false positives (~1.5%). DCV Mitigation. DCVs are not caused by programming mis- We also manually verify that many high-profile apps are takes. It is extremely difficult for developers to eliminate the vulnerable (a list of video demos of our attacks can be found DCV security issues, especially considering the existence of online [2]), including Facebook, Instagram, Facebook Messen- the limitations in WebView (Section 3.6). To mitigate the ger, Google News, Skype, Uber, Yelp, WeChat, Kayak, ESPN, problem, we propose a multi-level protection solution by McDonald’s, Kakao Talk, and Samsung Mobile Print. Several enhancing the security of WebView programming and UI popular third-party development libraries, such as Facebook features. Our defense solution is implemented by instrument- and Facebook React Native, are also vul- ing WebView’s independent library, but without touching the nerable and they influence hundreds of apps. Several special source code of Android frameworks. Our solution is easy sensitive categories of apps are affected including leading to use, and can simply work after developers involve our password management apps (such as dashlane, lastpass, and instrumented library, and provide a list of trusted domains. 1password), and popular banking apps (such as U.S. bank, Our evaluation on real-world apps shows that our solution Huntington bank, and Chime mobile bank). is effective and scalable, and introduces negligible overhead. In our analysis, we also find that some apps implement their Furthermore, considering the Android version fragmentation own URL address and title bars, which reduce the inconsisten- issue, we also test the compatibility of our solution. The re- cies between regular browsers and WebView. However, these sult shows our solution is available in many major popular home-brewed URL bars hardly eliminate DCVs due to several Android versions (5.0+), and covers almost 90% of Android limitations. One major limitation is that their implementation devices in use. is often error-prone. For example, Facebook Messenger (Fig- ure5, one billion+ downloads) is equipped with the library Contributions. In sum, we make the following contributions: “Facebook Mobile Browser” to handle URLs contained in • We investigate the security of iframe/popup in Android messages (e.g., SMS). The browser library implements its WebView, and discover several novel and fundamental own address bar (Figure5-b) to reflect the change of web design flaws and vulnerabilities in WebView (i.e., DCVs). content (Figure5-c) and mitigate DCV attacks (e.g., the WUI • We design a novel automatic vulnerability detection tool overlap attack). However, this address bar contains a design “DCV-Hunter” to quantify the prevalence of DCVs. flaw (race condition). By combining a couple of DCV attacks, • We apply DCV-Hunter on a set of popular apps, and con- untrusted iframes/popups can still launch phishing attacks firm that DCVs have severe security impacts. (Figure5-d). Due to the inclusion of the vulnerable library, • We further propose a multi-level solution to mitigate DCV many high-profile apps are impacted, such as Facebook and attacks.

USENIX Association 28th USENIX Security Symposium 979 2 Background and Threat Model iness: any navigation can be explicitly reflected by URL indicators (e.g., the URL address bar). Before we dive into our study of iframe/popup security, we first introduce necessary background information and our 2.2 WebView and Related Protections threat model. WebView is an embedded, browser-like UI component. An- 2.1 Iframes/Popups and Related Protections droid WebView is equipped with the newest kernel of the regular browser “Chrome/Chromium”, and performs as pow- Iframes/popups are frequently used in web apps, for example, erful as regular browsers. to view files in various formats (e.g., images, videos and As discussed in Section1, there are several inconsistencies PDFs), or load third-party untrusted web content (e.g., ads). between regular browsers and WebView. First, WebView UI They are easy to use. To create an iframe, developers can 1) is like a small and compacted version of a regular browser. It either use the HTML element