WWW 2008 / Refereed Track: Security and Privacy - Web Client Security April 21-25, 2008 · Beijing, China CompoWeb: A Component-Oriented Web Architecture Rui Guo Beihang University Beijing, China Bin B. Zhu, Min Feng, Aimin Pan Microsoft Research Asia Beijing, China Bosheng Zhou Beihang University Beijing, China imguorui@gmail.com ABSTRACT {binzhu, minfeng, aiminp}@microsoft.com bszhou@acm.org In this paper, client-site Web mashups are studied from component-oriented perspective, and CompoWeb, a componentoriented Web architecture, is proposed. In CompoWeb, a Web application is decomposed into Web components called gadgets. A gadget is an abstraction of functional or logical Web component. It is isolated from other gadgets for security and reliability. Contract-based channels are the only way to interact with each other. An abstraction of contract-based channels supported or required by a gadget is also presented. It enables binding of gadgets at deployment, and promotes interchangeable gadgets. Unlike the model of a normal function call where the function logic is executed in caller's context, CompoWeb ensures that the function logic is executed in callee's context so that both the caller and callee are protected. Implementation of a prototype CompoWeb system and its performance are also presented. Categories and Subject Descriptors D.1.5 [Object-oriented Programming], D.2 [Software Engineering]: D.2.12 Interoperability ­ distributed objects, D.2.13 Reusable Software ­ reuse models; D.3.3 [Programming Languages]: Language Constructs and Features ­ classes and objects, frameworks, Inheritance. D.4.6 [Operation System]: Security and Protection. In a Web mashup application, contents from different sources are integrated together to achieve the desirable functionality. This can be compared to a desktop application built on top of binary components from different vendors. A component is a unit of program structure that encapsulates its implementation behind an interface used to communicate across the components. The explicit declaration of a component's requirements increases reuse by decoupling components from their operating environment. Component-oriented programming has established itself as the predominant software development methodology over the last decade. It breaks a system down into binary components for greater reusability, extensibility, and maintainability. Several component technologies, such as COM/DCOM, CORBA, Java Beans, and .NET, have been used widely to allow an application with interchangeable code modules, and promote "black box reuse", which allows using an existing component without caring about its internals, as long as the component complies with some predefined set of interfaces. In this paper, we examine Web mashup applications from component perspective. Component-oriented paradigm is introduced and applied to Web applications for programming efficiency, manageability, functionality, and security. A new Web component called gadget 1 is proposed in this paper. A gadget plays the same role in Web applications as a component in component-oriented programming paradigm. A gadget provides an abstraction to a functional Web component isolated from others except contract-based channels used to interact with others. An abstraction of contract-based channels that a gadget can implement or query is also introduced. The actual implementation of a gadget is encapsulated. Gadgets can be nested: a gadget contains another gadget. With gadgets, a complex Web application can be decomposed into gadgets. Those gadgets, possible distributed or hosted by other Web sites, can be easily glued to deliver a designated functionality, which is exactly a mashup application. Due to its efficiency in developing an application, reusability, and ease in management, we believe that more and more Web applications will be built with gadgets. In our project CompoWeb, we aim to design and build a component-oriented gadget system for rapid development of rich Web applications. We focus on specifications and execution of a gadget-level abstraction with contract-based interactions, and protection of running environment from attacks and interference by others. General Terms Security, Standardization, Languages. Keywords Mashup, Web, browser, component, same-origin policy, security, protection, isolation, encapsulation, reuse, delayed-binding, interface. 1. INTRODUCTION We have witnessed dramatic progresses in Web applications in the past decade. Web pages have evolved from static HTML documents to dynamical content using client-side scripting, from creating content from a single site to integrating contents from different Web sites seamless to offer an enriched Web experience. For example, housingmaps.com uses Web mashups to link the craigslist housing database to the Google Maps, creating a new Web service that was not originally envisaged by either source. Another mashup example is iGoogle [1] and Windows Live [2] where gadgets from different sources can be aggregated into a personally customized portal page. A gadget is a component containing both HTML content and scripting code. Due to its tremendous power and flexibility, Web mashups will soon be widely adopted and prevail in Web applications. 1.1 Design Requirements To achieve the goal of this project, a gadget should meet the following requirements. Contact author: Bin B. Zhu (binzhu@microsoft.com). Copyright is held by the International World Wide Web Conference Committee (IW3C2). Distribution of these papers is limited to classroom use, and personal use by others. WWW 2008, April 21­25, 2008, Beijing, China. ACM 978-1-60558-085-2/08/04. 1 Note that gadget defined in this paper is different from the gadget used by iGoogle or Windows Live, as it will become apparent later in the paper. 545 WWW 2008 / Refereed Track: Security and Privacy - Web Client Security · Encapsulation: The implementation detail of a gadget should be encapsulated. The actual data and code inside a gadget are hidden from others. A gadget behaves like a black box to others except the contract-based services it provides to others. Separation of implementation and contract-based services are highly desirable in Web applications. Delayed Binding: When a gadget is implemented, the developer does not have to bind it to another gadget. An abstraction of supported and required contract channels is supported so that binding two gadgets together can be delayed until running time. This delayed binding offers a great flexibility in writing gadgets and gluing them together for a Web application. Isolation of running environment: A gadget is an abstraction in Web applications that no running state is shared between two gadgets. Each gadget runs in its own execution environment isolated from others. The only communications between two gadgets are through the contract-based channels. This guarantees the security of a gadget at running time even if some gadgets come from untrusted sources, and avoids any interference from other lousily implemented and crash-prone gadgets. Therefore security and reliability of the Web application are ensured. Easy adoption and incremental deployment. The design of gadget-level abstraction should ensure easy adoption and allow incremental deployment. Our system should be built on top of the existing Web standards and browser implementations with minimized changes. There should be an easy way to provide a fallback mechanism for legacy browsers which do not support our gadget-level abstraction without undesirable consequences. April 21-25, 2008 · Beijing, China Our CompoWeb has much more in common with Singularity than with a traditional OS: · · A gadget resembles a SIP in Singularity: a gadget runs in an environment isolated from other gadgets by a browser. Contract-based channels are the only way to communicate between two gadgets. This resembles contract-based channels to communicate between two SIPs A gadget can describe what contract-based channels it requires and supports, verifiable by a machine. This property is used in CompoWeb to delay binding of a gadget with other gadgets until its deployment. A gadget is interchangeable with another one with the same required and supported contract-based channels. This resembles the Singularity's manifest which describes the program's dependencies and desired capabilities, and is machineverifiable. · · · 1.3 Organization of the Paper This paper is organized as follows: Section 2 introduces the background for the paper, including the method that current Web applications are developed, the binary trust model that modern browsers have adopted, and Web mashups. In Section 3 gadgets and detailed specifications and design of CompoWeb are presented. The implementation details for a prototype of CompoWeb are provided in Section 4, and experimental results with the implemented prototype are reported in Section 5. Related work is presented in Section 6, and future work is described in Section 7. The paper concludes in Section 8. · 2. BACKGROUND Rapid advance of Web technologies has completely changed the Web from static, single-source HTML documents in the early days to dynamic, interactive, and multiple-source services nowadays. Applications delivered by the Web appear more and more like desktop applications, and will rival even finally replace desktop applications we are using today. Compared to the technologies used in desktop applications, Web applications still lags far behind. Although a Web page can mashup content from different sources, the Web is still a monolithic architecture that does not support component-level abstraction. A binary trust model is used in access control of contents from different sources. In this section, relevant Web technologies are briefly summarized. By meeting the above requirements, gadget-oriented Web development attains much greater reusability, extensibility, and maintainability, and greatly improves security and reliability. These benefits can, in turn, lead to shorter time to market, more robust and highly scalable applications, and lower development and long-term maintenance costs. 1.2 Similarity with Singularity Although our approach to client-side Web mashups is from the software component perspective, it is also possible to look at it from the Operating System (OS) perspective. For a client mashup application, a browser resembles a multi-user OS: mutually distrusting Web sites interact programmatically in a single page on the client side and share the underlying browser resources for the browser, while mutually distrusting users share the host resources for the OS. Such an OS approach has been adopted by Wang et al. in their MashupOS [3][4] to build a browser-based multi-principal operation system for client-side mashups. Looking from the OS perspective, the system presented in this paper resembles Singularity [5], a research OS with a more reliable and flexible OS architecture, and offering the following three key features as compared to a traditional OS: · · · Software-Isolated Processes (SIP) for protection of programs and system services. Contract-based channels for communications between two SIPs. Manifest-based programs for verification of system properties. 2.1 Monolithic Architecture Web applications are still implemented with a monolithic architecture: each functional part is glued statically at implementation time. With today's Web standards and browsers, scripting from other sources can be used and contents from different sources can be aggregated, but the implementation is not separated from the contract-based services that the implementation provides. Delayed binding and module interchangeability are not supported. Those unsupported features are widely used in component-oriented software development. 2.2 Binary Trust Model The binary trust model, either no trust or full trust, is used by today's Web standards and browsers, governed by the SameOrigin Policy (SOP) which prohibits documents or scripts of one origin from accessing documents or scripts of a different origin [6]. SOP is needed to protect against Cross Site Scripting (XSS) attacks. An origin consists of the domain name, protocol, and port. Two Web pages have the same origin if and only of their domain 546 WWW 2008 / Refereed Track: Security and Privacy - Web Client Security names, protocols, and the ports are all the same. Each browser window, or