<<

DOMtegrity: Ensuring Web Page Integrity against Malicious Browser Extensions

Ehsan Toreini Maryam Mehrnezhad Siamak F. Shahandashti Feng Hao School of Computing Science School of Computing Science Department of Computer ScienceSchool of Computing Science Newcastle University Newcastle University University of York University of Warwick United Kingdom United Kingdom United Kingdom United Kingdom [email protected] [email protected] [email protected] [email protected]

Abstract—In this paper, we address an unsolved problem in some malicious extensions can slip through the vetting pro- the real world: how to ensure the integrity of the web content in cess. Furthermore, the extension update mechanism provides a browser in the presence of malicious browser extensions? The an additional exploit path for the attacker. In 2014, two popular problem of exposing confidential user credentials to malicious extensions has been widely understood, which has prompted and previously vetted Chrome extensions, “Add to Feedly” major banks to deploy two-factor authentication. However, the and “Tweet This Page”, were sold to spammers who updated importance of the “integrity” of the web content has received the extensions to inject advertisements and affiliate into little attention. We implement two attacks on real-world online opened in the browser. banking websites and show that ignoring the “integrity” of the The Problem. The key problem with extensions is that, web content can fundamentally defeat two-factor solutions. To address this problem, we propose a cryptographic protocol called once installed, they possess over-privileged capabilities that DOMtegrity to ensure the end-to-end integrity of the DOM may be abused by attackers. For example, an extension is free structure of a web page from delivering at a web server to to modify the (DOM) of a web page. the rendering of the page in the user’s browser. DOMtegrity is This allows a malicious extension to manipulate the display the first solution that protects DOM integrity without modifying of a web page and deceive users into believing something the browser architecture or requiring extra hardware. It works by exploiting subtle yet important differences between browser false. The change of the web page content may be subtle, but extensions and in-line JavaScript code. We show how DOMtegrity when it is combined with social engineering techniques, it can prevents the earlier attacks and a whole range of man-in- cause significant harm to user security [3]. In SectionII, we the-browser (MITB) attacks. We conduct extensive experiments will demonstrate two attacks on real-world banking websites on more than 14,000 real-world extensions to evaluate the (HSBC and Barclays) to show how a malicious extension may effectiveness of DOMtegrity. Index Terms—Web Page Integrity, Web Crypto API, Browser stealthily steal money from the user’s bank account by making Extension, WebExtension, Man in the Browser, JavaScript, small modifications to the DOM structure of an online banking DOMtegrity web page. Existing solutions to prevent malicious extensions generally I.INTRODUCTION involve changing the browser’s internal design [4], [5], [6], Browser extensions have become the dominant method to strengthening the vetting process of repositories [2], [7], [8], extend browser functionality. All major browsers (Chrome, [9], [10], asking users to install yet another (trusted) extension , , and ) support exten- that detects malicious behaviour of other extensions [11], [12] sions, and host dedicated repositories (“stores”) from which or requiring an external hardware device (e.g., Cronto) that extensions can be downloaded and installed directly from the performs out-of-band transaction verification. arXiv:1905.12951v1 [cs.CR] 30 May 2019 Internet. reports average rates of more than 1 million Our solution. In this paper, we propose a cryptographic Firefox extensions downloaded daily and about 100 new protocol that we call DOMtegrity to ensure the integrity of the extensions created every day throughout 2017 [1]. DOM structure of a web page delivered from a web server to Extensions are normally distributed and executed in con- the rendering of the page at the client browser in the presence trolled environments. All extensions uploaded to a repository of malicious extensions. Compared to previous solutions, ours are subject to a vetting process, which is a mixture of au- does not require changing the browser’s existing internal tomated program analysis and manual code review aiming design; it does not need any external hardware device; it to identify malicious extensions and prevent their spread. is orthogonal to the strengthening of the vetting process; it Furthermore, extensions are run in a restricted (so-called can be easily implemented by embedding in-line JavaScript “sandboxed”) environment and only have access to a prede- code in the web page rather than requiring the user to install fined set of browser . another (trusted) extension. The novelty of our solution lies in However, the vetting process is not bullet-proof. A study exploiting subtle but important differences between extensions conducted by researchers found nearly 10% of ex- and in-line scripts in terms of their rights to access tensions examined to be malicious [2]. By using obfuscation, established between the server and the client. This is combined with leveraging the latest Web Crypto API that is recently Through content scripts, an extension can hide elements of added in all major browsers. the DOM and insert another element in the same location to Contributions. The main contributions of this paper are effectively replace the original element. For example, a text summarized below: box can be placed by a malicious extension in place of a • We propose DOMtegrity, a cryptographic protocol to password text box to capture a user’s password. protect end-to-end integrity of a web page’s DOM from the point of delivery at a server to the final display in a B. Attack Model client’s browser. This is the first solution that works with In the rest of this paper, the attackers implement their threat the standard WebExtensions architecture without needing scenario through a malicious extension installed in the victim’s any external hardware. browser. Thus, the capabilities of a malicious extension are • We present an efficient implementation of DOMtegrity, limited to the context of a browser. We assume attackers have using JavaScript on the client side and .js on the not installed any operating system level malicious server side, and demonstrate that the proposed solution on the victim’s device to extend their capabilities beyond the is effective and only adds a small overhead to the com- browser execution context. putation load and communication bandwidth. In the following demonstration, we assume that a malicious • As part of the evaluation, we implement two attacks on extension is already installed on a client’s browser. This can real-world online banking systems (HSBC and Barclays) be done through disguising malicious extensions as legitimate to show how a malicious extension can compromise the browser extensions, using Trojans to install such extensions, security of the user’s bank account, and how DOMtegrity missing plug-in attacks, or purchasing popular extensions and can prevent such attacks as well as a whole range then adding malicious code during updates [15], [3]. In both of man-in-the-browser (MITB) [13] attacks that involve attacks, the web pages that are presented to the victim are maliciously changing the DOM structure of a web page. from the genuine banking websites via HTTPS. We assume that the attacker has an account that they wish II.MALICIOUS EXTENSION ATTACKS ON ONLINE to move funds to, and the details of this account are either BANKING hard-coded into the or received in real Attacks caused by malicious extensions are often known time from a remote Command & Control (C&C) center [16]. as man-in-the-browser (MITB) attacks. To demonstrate the The attacker’s bank account will eventually be exposed by importance of understanding the threats imposed by malicious checking the victim’s bank transaction records. However, we extensions in modern browsers, we show two proof-of-concept assume this is not any issue for the attacker since he only needs attacks on real-world banking websites, HSBC and Barclays, to prevent the discovery of the fraud for some short timescale by exploiting the capability of browser extensions to modify in which the funds can be withdrawn from the account. the DOM of a web page. The extensions are developed for both Firefox and Chrome based on the standard WebExten- C. HSBC Attack sions framework. In the proof-of-concept demonstration of The first attack shows how a malicious extension can easily the attacks, the money was transferred between the authors’ bypass the two-factor authentication that is adopted by major accounts. All the experiments were approved by Newcastle banks, including HSBC. In this attack, the extension intercepts University’s ethics committee. the victim’s authentication credentials (i.e., login details), A. WebExtensions Capabilities sends them to a remote attacker and redirects the user to a false maintenance page. Depending on the security policy of the Before describing the attacks, we should first explain We- banking web site, this authentication could involve a regular bExtensions1. The WebExtensions framework is a W3C stan- password and an additional one-time password (OTP) as a dard cross-browser architecture [14] for developing browser second factor which is either sent to the user’s mobile phone extensions using HTML, CSS and JavaScript. It is now sup- as an SMS or locally generated using a dedicated device (i.e., ported in all major browsers except Safari. a Chip Authentication Program (CAP) device) provided by the An extension developed based on WebExtensions consists of bank. three components: the background page, the UI pages, and the We developed a proof-of-concept attack that targets the content scripts. The background page is in charge of long-term HSBC online banking web pages. To authenticate their clients, operations that last beyond the lifetime of a particular browser HSBC uses a password-based user authentication augmented window and is provided with access to browser APIs. The UI with an OTP generated by a dedicated device, the HSBC pages put together the extension . Content scripts Physical Secure Key. Our attack works as follows: are JavaScript programs that are run in the context of a web page and are allowed to interact with the page. 1) When the victim requests the login page, the browser Although the background and UI pages do not have access extension content script replaces the username and pass- to the DOM of the page, content scripts can modify the DOM. word text boxes with its own and records the victim’s username and password by communicating with the 1https://developer.chrome.com/extensions/overview extension background page. Fig. 1. The HSBC customer service page modified by the malicious extension to contain a message indicating technical difficulties.

2) When the victim is prompted for an OTP, the browser Fig. 2. The Barclays instructions page modified by the malicious extension extension records what the victim enters in a similar to include the attacker’s account number (redacted as XXXXXXXX) as the manner. REF number. The modified area is represented in the green box. 3) The victim is then redirected to a genuine customer ser- vice page. However, the content of the page is changed on the fly by the extension content script to include a Barclays uses the strongest of transaction authen- message indicating that the website is temporarily un- tication (the so-called full transaction authentication [17]) available for maintenance or due to technical difficulties in which the unique transaction authorization code (i.e., the as shown in Figure1. transaction-specific OTP) is cryptographically bound to the 4) The stolen login credentials are sent to the attacker who transaction data. The authorization code is calculated by can then log into the victim’s online banking account. a dedicated device provided by Barclays called PINsentry. Alternatively, the user can use the functionally equivalent We have implemented the attack by developing extensions Mobile PINsentry application on her smartphone. PINsentry for both Firefox and Chrome based on WebExtensions. Our is a battery-powered device consisting of a numeric keypad, extensions were able to perform the attack successfully with- a small LCD screen, a card reader and a processor. When a out being detected by the bank server. Consequently, we were transaction is requested through Internet banking, the user is able to impersonate the victim and log into his or her bank required to manually enter the transaction details, including account on a separate machine. the payee account number and the amount, on PINsentry (or Mobile PINsentry) and then enter the PINsentry produced D. Barclays Attack authorization code on the internet banking web page. However, The second attack shows how a malicious extension can in the following we show how a malicious extension can defeat defeat transaction-specific user authorization, which is added this security measure by combining social engineering and by many banks such as Barclays as an extra layer of security DOM modifications. The attack works as follows: on top of two-factor authentication. Here, when an already 1) When the victim requests a funds transfer, she is pre- authenticated user requests a transaction, she is required to sented a form to provide the details of the funds transfer, provide a transaction-specific authorization code which is including the payee account number and the amount. either sent to the user out of band or generated by a dedicated The malicious extension content script replaces the text device upon unique transaction-specific input. This transaction box where the victim is supposed to enter the account authentication is designed to prevent modification of transac- number of the intended payee with its own text box and tion data (e.g., recipient and amount) by man-in-the-browser records the entered account number by communicating attackers. with the extension background page. 2) Then the user is presented with a dialogue confirming the transaction details and instructing her how to get Operating System a transaction authorization code from PINsentry. The instructions include asking the user to “Enter the payee’s Browser API account number as your REF:” followed by the payee’s Limited Access account number. The malicious extension content script replaces this instruction with “Enter this REF number:” Internet Zone Chrome Zone followed by the attacker’s account number, as shown in Boundary Security Step 3 of the instructions in Figure2 with real bank Page Content Background details suitably redacted. DOM Script Script & UI Pages 3) A non-expert user, trusting the HTTPS page to be secure and failing to notice the above subtle change, then enters Interface the attacker’s bank details in PINsentry and provides a code authorizing the funds transfer to the attacker’s account. Plugin 4) The browser extension changes the final confirmation page before it is displayed to the user so that it shows the account details of the original intended payee rather than that of the attacker. The key issue that we were able to exploit is that PINsentry Fig. 3. The Internet and Chrome zones of a modern browser and how web pages, extensions, and plug-ins interact [19] prompts the user for two pieces of transaction information: “REF” and “Amount”. The only information about what “REF” means is present on the website, which can be modified The main reason for the isolation is to prevent malicious in- by the extension. We have responsibly disclosed our attack to line scripts from exploiting the vulnerabilities that may exist Barclays and since then Mobile PINsentry has been updated in extension content scripts [19]. However, as we will explain, and the prompt on the app has been fixed to explicitly ask the the isolation is also useful in defending against malicious user for the payee’s account number instead of a REF number. extensions when the in-line scripts are from a legitimate source. III.OUR PROPOSED SOLUTION:DOMTEGRITY Permissions. Every extension must provide a “manifest” in In this section, we propose a solution, called DOMtegrity, the JSON format which defines the resources and the corre- to address MITB attacks such as those demonstrated in the sponding permissions for each component of the extension. previous section. Our solution is designed based on the We- Based on this manifest, users are asked to grant the required bExtensions framework, which is now the standard extension permissions at the time the extension is installed, and once development architecture recommended by W3C and adopted installed, the extension’s access to browser APIs is limited to by , Mozilla Firefox, Edge and these permissions. Opera. B. Design Overview DOMtegrity is designed to enable the server to detect any A. WebExtensions Security Model unexpected modification of the DOM by extensions when the The WebExtensions security model as implemented in mod- web page is rendered in the browser. The underlying idea is ern browsers is based on the model proposed by Reis et al. [18] that DOMtegrity securely records all the modifications made who discussed the real-world security issues experienced by to the web page DOM until the final rendering of the page and Google Chrome and advocated a systematic method to prevent then securely communicates the recorded modifications to the these attacks. Here we discuss parts of this model that are server. The server is then in a position to decide whether or not necessary for the description of our protocol. the client’s browser has parsed the page as the server expected. Browser Zones. In modern browsers, the execution envi- DOMtegrity is implemented as a JavaScript program, called ronment is divided into two zones: an unprivileged Internet pid.js, which is then embedded as an in-line script (within zone in which web pages are executed, and a privileged a

Web Analytics