<<

Using Replicated Execution for a More Secure and Reliable

Hui Xue Nathan Dautenhahn Samuel T. King University of Illinois at Urbana Champaign huixue2, dautenh1, kingst @uiuc.edu { }

Abstract Unfortunately, hackers actively exploit these vulnerabil- ities as indicated in reports from the University of Wash- Modern web browsers are complex. They provide a ington [46], [61], and Google [49, 48]. high-performance and rich computational environment Both industry and academia have improved the se- for web-based applications, but they are prone to nu- curity and reliability of web browsers. Current com- merous types of security vulnerabilities that attackers modity browsers make large strides towards improving actively exploit. However, because major browser plat- the security and reliability of plugins by using sandbox- forms differ in their implementations they rarely exhibit ing techniques to isolate plugins from the rest of the the same vulnerabilities. browser [62, 33]. However, these browsers still scatter In this paper we present Cocktail, a system that uses security logic throughout millions of lines of code, leav- three different off-the-shelf web browsers in parallel to ing these systems susceptible to browser-based attacks. provide replicated execution for withstanding browser- Current research efforts, like Tahoma [32], the OP web based attacks and improving browser reliability. Cock- browser [36], the web browser [59], and the Illi- tail mirrors inputs to each replica and votes on browser nois Browser [58] all propose build- states and outputs to detect potential attacks, while con- ing new web browsers to improve security. Although tinuing to run. The net effect of Cocktail’s architecture these browsers represent a vast improvement in security is to shift the security burden of the system from complex over monolithic commodity browsers, they require re- browsers to a simplified layer of . We demon- implementing large portions of the browser to withstand strate that Cocktail can withstand real-world browser attacks. Additionally, all of these browsers exhibit fail- exploits and reliability issues, such as browser crashes, stop behavior when encountering a bug or attempted ex- while adding only 31.5% overhead to page load latency ploit, making them susceptible to browser crashes. times on average, and remaining compatible with popu- This paper presents Cocktail, a system that uses repli- lar web sites. cated execution of multiple existing web browsers to help withstand browser bugs and security vulnerabili- ties. Cocktail runs three different off-the-shelf browsers, 1 Introduction including different plugins, in parallel with the assump- tion that any two of them are unlikely to be vulnerable at The near of access has put a wealth the same time or exploited by the same malicious page. of information and ever-increasing opportunities for Cocktail replicates user interaction and network requests social interaction at the fingertips of users. Driving in each of the three browsers, then votes on network this revolution is the modern web browser, which has outputs and browser states to detect any modifications evolved from a relatively simple client application de- resulting from browser bugs or web-based attacks. By signed to display static HTML data into a complex net- mirroring inputs to three different browsers and voting worked operating system tasked with managing the myr- on outputs, Cocktail shifts most of the browser’s secu- iad of web-based applications people use daily. Support rity enforcement into a thin and simple software layer, for dynamic content, multimedia data, and extensibil- while reusing the mature, fast, and feature-rich imple- ity has greatly enriched user’s experiences at the cost of mentation of existing web browsers. increasing the complexity of the browser itself. As a Replicated execution [24, 25, 31] is conceptually result, current web browsers are plagued with security simple, but it is extremely expensive to implement in vulnerabilities, as evidenced by , , Google practice for security purposes. To prevent replicas from Chrome, , and reporting 374 new falling victim to the same attack, each replica must be a security vulnerabilities in 2009 and 500 in 2010 [18]. distinct implementation of the same specification, which requires significant development resources. For exam- ple, N-version programming [30] usually requires three !"!#$%&'()* times as many software developers. In contrast Cocktail +"!#$*01##.././* takes advantage of a form opportunistic N-version pro- gramming by using three off-the-shelf browsers directly. !"!#$%&'()* In Cocktail’s case the specification is provided by web !"!#$%&'()* standards bodies [20, 13, 2, 19, 12, 3], and the imple- +"!#$*01##.././* mentations are represented by three major web browsing !"!#$%&'()* +"!#$*,!-)./* systems: Firefox, Opera, and . !"!#$%&'()* Although modern web browsers respect common standards like HTML, HTTP, CSS, JavaScript, and the !"!#$%&'()*

Domain Object Model (DOM), most browsers imple- !"!#$%&'()* +"!#$*,!-)./* ment slight modifications to these standard web pro- tocols. These differences require Cocktail to abstract Figure 1. Results of the same exploit being states and to cope with non-determinism between the served!"!#$%&'() to* four different browsers. browsers in order to extract reliable features to vote on for security. Designing these techniques is challeng- ing because developers did not build browsers with N- Version programming in mind. During our experiments, we ran this exploit on Fire- Our experiments show that Cocktail is practical, pre- fox 3.5 and confirmed the existence of the successful vents real attacks, and withstands both reliability issues attack. However, when we opened this same malicious and injected faults. Cocktail’s replicas run in parallel, so page using Internet Explorer, Safari, Chrome, or Opera, there is almost no performance loss. While more sys- these browsers safely avoid the attack, as illustrated in tem resources are required, multi-core systems continue Figure 1, because none of these browsers had this same to gain popularity, making this style of security practical bug. Surprisingly, even older versions of Firefox on on modern computer systems. Windows XP were unaffected by this attack. This differ- Our contributions are: ence in processing the malicious payload motivates our architecture that uses three different browsers to with- Cocktail is the first system to show how to use mul- • stand attacks. tiple browsers as a form of opportunistic N-Version programming for improved security through repli- cated execution. 3 Problem statement, threat model, and We show how to abstract browser states and cope assumptions • with non-determinism to enable the use of existing browsers in Cocktail, despite differences in their Cocktail focuses on providing protection for implementations. browsers and plugins by running different browser implementations in parallel and detecting any inconsis- We demonstrate that Cocktail can withstand a wide • tencies between these browsers. We use three distinct range of real world attacks with little overhead to off-the-shelf browsers and Flash player plugins. the overall browsing experience. We focus on attacks on browsers themselves where an attacker can compromise a browser vulnerability and 2 A motivating example control the browser. In our threat model, we assume that an attacker has On July 13 2009, researchers published a public taken over a web site and can serve arbitrary data to proof-of-concept exploit for Firefox 3.5 [7]. This exploit Cocktail. This data can come via a web site that the attacks a heap overflow vulnerability found in the new user visits directly, or it can come indirectly through a JavaScript just-in-time compiler that developers web site that serves off-site network resources, like ads. introduced in Firefox 3.5. With just a single visit to a We assume that this malicious data can result in a com- malicious web page, the attacker can run arbitrary in- promise to any of the browser replicas executing within structions on the victim’s Windows XP computer. With Cocktail, which implies that the attacker has the ability a few minor modifications, this exploit can also com- to execute arbitrary instructions with the full privileges promise the Firefox browser on and Mac OS X to of the replica. execute arbitrary instructions on these platforms as well Currently, Cocktail does not provide any protection [9, 8]. against bugs in web-based applications. Fundamentally, bugs like cross-site scripting [35] and cross-site request To see this more clearly take, for instance, the state forgery [65] result from bugs in the server-side code. abstraction of network requests. If at least two of the The resulting attacks operate within current browser se- three replicas attempt to fetch an image at location curity policies, putting them beyond the scope of Cock- foo.com/image.jpg, then Cocktail will fetch the tail. resource and return the data back to the requesting repli- We trust the layers upon which Cocktail is built. This cas. However, if none of the replicas request the same includes the network component and the visual voter in image then Cocktail will deny the request because it UI component, the libraries that the output component does not reach consensus. By using network requests uses, the Systrace tool we use to build browser sandbox- as a key state abstraction Cocktail effectively thwarts all ing, the underlying operating system, and the underlying attacks that require additional network resources to suc- hardware. If an attacker can compromise any of these ceed. layers, they are likely to be able to defeat Cocktail. Conceptually, we view Cocktail as a black box with two channels of communication in and out. One chan- 4 Design principles nel, the display, represents the agreed upon visual out- put from the three replicas. The other channel, network requests, represents the agreed upon network commu- Cocktail’s design is guided by the following three nications by the replicas. Given our assumption that at principles: most one replica is compromised, reaching consensus 1. Use different existing browser implementations for on a network request implies that at least one uncom- diversity. We use the high performance, feature promised browser made this individual network request, rich, standards compliant – yet different – imple- and reaching consensus on the display implies that the mentations of existing browsers. This balance pro- browser, from the user’s perspective, produces output vides improved security without sacrificing perfor- that is equivalent to an uncompromised browser. Thus, mance or functionality. the browser’s observable behavior is consistent with that of an uncompromised browser. If Cocktail’s behavior is 2. Avoid changing the replica’s implementation. Ad- consistent with an uncompromised browser, then it has hering to this principle provides two key benefits. effectively thwarted the effects of potential attacks. In First, avoiding changing replicas enables Cock- other words, if Cocktail looks like an uncompromised tail to use closed-source browsers such as Opera. browser, and it acts like an uncompromised browser, Second, avoiding implementation specific details then it is an uncompromised browser independent of about the replicas enables Cocktail to remain sta- what is inside of the black box. ble across updates of individual browsers. Cocktail’s state abstractions provide rigorous de- fenses against attacks, but have the potential to incur 3. Focus equivalence testing on security features. The false positives on non-malicious sites. The problem is browsers we use are off-the-shelf products from that there are several valid reasons for a given browser different providers with millions of lines of code state to deviate from the other two replica states. For in each of them. Though certain standards, such example, ad networks provide randomized content to as HTTP and HTML, are available, it is still hard end users. This content represents a major class of non- to find perfect abstractions to dictate their equiva- determinism that should not be considered an indicator lence. However, if we focus on security features, of malice. Therefore, one of our primary design con- we can find a layer of abstraction that omits large siderations is to identify and eliminate sources of non- amounts of browser-implementation details while determinism in each browser so that the requested re- still preserving strong security guarantees. sources are as consistent, avoiding false positives. In In designing Cocktail the most significant issue we Section 9.4 we show that our approach handles this and address is that of security state selection. The decisions other forms of non-determinism while maintaining com- we make with respect to this impact both the overall patibility with existing websites. Many of the design security improvements and architecture of Cocktail. In challenges faced by Cocktail stem from this problem, Cocktail we strive to select state representations that are and are discussed in Section 5. not too implementation specific, yet maintain potency in deterring real-world attacks. The fundamental method 5 Cocktail design challenges we use in Cocktail to provide security is to require a ma- jority vote before any given state is permitted to persist Cocktail is comprised of a UI component, a replica in the browser. If a majority is not obtained then the component, and a network component, as shown in Fig- given action producing the invalid state is rejected. ure 2. The UI component is responsible for providing defined database data to be the state of the system, and EnvyFS [23] combines different file system implemen- tations and considers the file system data to be the state of the system. However, as distinct UI oriented soft- ware platforms without table or inode-like natural state representations, abstracting states for Firefox, Google

((."-/*01(( Chrome, and Opera is hard. )*+#*,",-( The goal in defining browser states is to find states 23()*+#*,",-( that are (1) meaningful to users, (2) low-level enough to detect a wide range of attacks, and (3) high-level enough to be uniform across different browser implementations. !"#$%&'( )*+#*,",-( 5.2 Solution: Network and on-screen states

Figure 2. Cocktail overview. We define two states for all browsers: network and display states. Network states include the HTTP re- quests and headers, and browser cookies that are in- cluded in network requests. Browser cookies are a the interface between the user and Cocktail, routing user mechanism for HTTP servers to store key-value pairs on input to each replica, and voting on the display states client machines persistently. Browser cookies are a first- of each replica. The replica component maintains each class part of modern browsers and are generally consis- browser replica, which all run in sandboxed environ- tent across different browser implementations. Thus, in- ments. The network component is responsible for han- cluding browser cookies in our network state abstraction dling network requests from the replicas and voting on was an easy design decision. network requests. We describe the details of these com- Cocktail also uses the visual output of the browser ponents in Section 6. as a state because the it is the most meaningful state The first challenge in Cocktail is defining appropri- to users. The browser display can also indicate severe ate state abstractions to enable Cocktail to behave like security problems, especially when the attack requires an uncompromised browser even if an attacker com- user interaction. For instance, in Sept. 2009, a vul- promises one replica. This challenge is the basis for nerability [10] found in Firefox 3.0.x(x<14) pops up a the security assurances in Cocktail. The second and dialog trying to coax users into installing a malicious third challenges are to remove enough sources of non- PKCS11 module. This vulnerability does not affect Sa- determinism from the server and in our browser repli- fari, Google Chrome, Opera or Internet Explorer and cas to enable Cocktail to process web sites correctly. they showed no dialog box. This is a typical example For these challenges Cocktail does not need to remove where a visual difference in one browser can indicate all sources of non-determinism. Cocktail only has to the existence of an active security exploit. remove enough non-determinism so that Cocktail can Although dictate how a browser reach a consensus for the states encountered on a wide should render and display a web page, small implemen- range of web sites because of the natural redundancy in- tation differences can cause visual discrepancies. For herent in our system. example, browsers might use different libraries, causing small discrepancies in how the browser displays 5.1 Challenge: Browser state abstraction text. These discrepancies make it difficult to do a pixel- by-pixel comparison of two browsers. Other researchers It is hard to abstract meaningful common states from have applied vision algorithms to web browsers to quan- different software. Most works [28, 63, 40] from Byzan- tify visual similarity [57], they use the SIFT algorithm tine Fault Tolerance community provide state abstrac- [41] for comparing the rendering results from the same tion examples for replicas running the same software. browser for offline analysis. However, the SIFT algo- Although this type of replication does improve the relia- rithm takes tens of seconds to compare browser displays, bility and availability of these systems, they provide few making it unsuitable for real-time analysis. The key security improvements because software exploits mani- attribute that makes SIFT attractive is that it works on fest as correlated failures [54]. Other systems combine more coarse-grained visual information in an image, al- independent implementations and rely on clear abstrac- lowing SIFT to match similar pages despite small differ- tions of states. For example, BASE [53] combines dif- ences in the rendering of the page. ferent database implementations and considers the well- In Cocktail we try to blend the high-level feature ex- traction properties of SIFT with an algorithm that can [14]. The HTTPS proxy establishes one encrypted con- run in real time. In our algorithm, we apply Gaussian nection with the web browser and another encrypted smoothing methods to mute small pixel differences in connection with the requested HTTPS site while relay- browsers and we use Canny edge detection [27] to pull ing clear text data in between the two encrypted chan- out higher-level features of each replica’s display. These nels. As a result, the proxy is able to read the unen- techniques are computationally efficient, allowing us to crypted web traffic and replicate it to all of the browser take periodic snapshots of each replica’s display, and we replicas. can detect coarse-grained changes to a page, like an at- tacker who overlays content on top of a web page. How- 5.5 Challenge: Client-side non-determinism ever, our technique is unable to detect small changes to a web page, like an attacker who changes a few words Our third challenge is avoiding client-side non- on an existing web page. determinism that can cause our browsers to generate dif- ferent abstract states for the same HTML and JavaScript 5.3 Challenge: Server-side non-determinism inputs. Based on our observations, browsers exhibit and side effects three types of client-side non-determinism. First, standard JavaScript functions may return non- deterministic or random values. The two most common Our second challenge is coping with server-side non- examples of these functions are Math.random() and determinism and side effects. Each time a browser Date.getTime(). In practice, web pages use these makes an HTTP request, the server can return different functions to select random advertisements for a given results. For example, each time one visits a news site content pane. the main page will include any recently updated news Second, some browsers include standard functions stories. Furthermore, some HTTP requests have side that return implementation specific results, and some effects, like sending a friend a message on facebook. browsers include non-standard JavaScript interfaces to These issues cause problems for Cocktail because we provide extended functionality. For example, the run three browsers in parallel, so we must ensure that navigator.userAgent property will disclose the each browser sees the same network data to create the identity of the browser and the window.opera ob- same browser states, and we must ensure that HTTP ject exposes Opera-specific functionality not found on requests avoid inducing unanticipated side effects and other browsers. navigator.language also dif- maintain current browser semantics. fers slightly between Opera and Firefox. Browser Our goal for coping with server-side non- locale setting differences make Opera indicate En- determinism and side effects is to mask these ef- glish as “en” whereas Firefox and Chrome both in- fects from our browser safely and efficiently without dicate “en-US”. Similar differences also exist for modifying the implementation of the browser replica. document.characterSet which has value “utf-8” on Opera whereas “UTF-8” on Chrome. 5.4 Solution: Local web proxy Third, users interact with the browser via input de- vices, such as the mouse and keyboard. These user in- Our solution to this challenge is to implement a lo- terface actions induce computation in the browser and cal web proxy that interposes on all network connec- can result in non-determinism if the system delivers UI tions made from our browsers. This local proxy runs events to the incorrect UI widget or with varied timing. as a separate user-mode process and makes network re- Our two goals in coping with client-side non- quests on behalf of the Cocktail replicas as shown in the determinism are to remove enough sources of non- network component in Figure 3. To cope with server determinism to enable Cocktail to render a wide range non-determinism, our local web proxy buffers the results of web pages correctly, and to remove these sources of of HTTP requests in its cache component and uses this non-determinism without modifying the implementation buffered data to ensure that all replicas receive the same of the replicas or eliminating browser features. result for all requests. To avoid inducing side effects on the server, the local web proxy makes only a single out- 5.6 Solution: Browser extensions and configu- going HTTP request for all equivalent requests from the rations replicas. To handle encrypted HTTPS traffic, we install our Our primary mechanism for coping with client-side own self-signed certificate in each of our browser repli- non-determinism is to overwrite non-deterministic func- cas to implement a man-in-the-middle proxy, similar to tions by injecting JavaScript into every page via browser the SSL-MITM proxy by Boneh, Inguava, and Baker extensions. The goal is to eliminate non-determinism aeteeatbosr uha the as such browser, exact indi- the existence cate whose attributes browser-specific move hswyec fterpia eeaetesm return same In the to generate call intervals. replicas each second for the value three of in each way tick this clock the make and Date.getTime() rvddb the by as provided such Date.getTime() functions, dom positives. false preventing for anism do we that 3. in Figure shown in as component replicas replica browser the our of implemented each We non- for into normalize browser. extensions exten- and JavaScript the overwrite of use inject to features We to visit deterministic we replicas that our browser. pages of all the range each in wide in events a sions to and access are states have Extensions of and JavaScript pages. in web common written remov- select One for from NoScript JavaScript is visit. ing extension browser they a that ex- of pages example to modify ability of the and form users tend a gives are that extensions extensibility Browser browser replica. each across hsoewiigtcnqeas nbe st re- to us enables also technique overwriting This neto ybosretnin ok o ran- for works extensions browser by Injection is JavaScript injected our of property important One 23()*+#*,",-( ."-/*01()*+#*,",-( !"#$%&'()*+#*,",-( iue3 okalarchitecture. Cocktail 3. Figure C/D+/4,(( not E+/+/( !"#$%&'( F?4*;"0( >$&%/( H&,/1( :;"4<( @<1&A/( M',/#4?&#( @&9L,"?;( rs hscd tsre oeya mech- a as solely serves it – code this trust Date )#*+,-(./0%&"1$23&+4/ C/D+/4,(( H&,/1( Date.getTime() eemnsi edsrtz time discretize we deterministic swl sohrfunctions other as well as

!"#$%&'( 3"#"G/1( F?4*;"0( 51&'0 bet nodrt make to order In object. !78$/9( M',/#4?&#( :;"4<( :?1/8&'( @&9L,"?;( I/A%/$( ( :/,9 marginheight="0" scrolling="no" frameborder="0" height="250" width="300" ***** TID} hoo.com%2Fads%2F792600119%2Flrec%2F,&CB={REQUES ...... 0%2F%2A%24,http%3A%2F%2Fadjax.flickr.ya ...AAAAAA=,http%3A%2F%2Fglobal.ard.yahoo.com... e2,0%3B%3B%3B1410192806,5jBaAEmJEgC.5m...... ium.com/clk?2,13%3B738a290b44284f0c%3B12c3705b5 -b3c1-b9863e5ab24e&clicktag=http://ads.bluelith tegoryhtml.aspx?userfeedguid=948fbed8-69ae-4659 http://www.adfusion.com/Adfusion.PartnerSite/ca src="