Preventing Common Vulnerabilities in Web Applications Using Programming Language Abstractions (Invited Paper)

Preventing Common Vulnerabilities in Web Applications Using Programming Language Abstractions (Invited Paper)

Preventing Common Vulnerabilities in Web Applications using Programming Language Abstractions (Invited Paper) Dachuan Yu, Ajay Chander, and Liang Fang DOCOMO USA Labs 3240 Hillview Avenue, Palo Alto, CA, 94304, USA fyu,chander,[email protected] ABSTRACT Input login information The Web of today is commonly used as a platform for hosting sophisticated applications. A key component of such Select service web-based applications is the programs running on the web servers. With the growing popularity of web applications, Show balance Get payment details Log out especially those which manage sensitive data and perform Set up payment critical functionalities (e.g., online banking), the security of server programs has become a major concern. The BASS project at DOCOMO USA Labs aims to understand what a Figure 1: Idealistic work flow of online banking suitable model is for programming web applications, and pre- vent common vulnerabilities using proper programming lan- this paper, we review basic BASS ideas, present a new BASS guage abstractions. In this paper, we give a status update on prototype deployed as a Python library, and discuss ongoing BASS, including a review of previous results, an introduction efforts on a deployment on Google App Engine. to a new prototype, and a discussion on ongoing efforts. 2 Background Keywords: Cloud computing, programming language ab- straction, web application security. 2.1 Server-Side Scripting 1 Introduction Web applications face more security threats than desktop applications [7], [18]. Some representative ones include com- Cloud computing gives users access to powerful computing mand injection [20], cross-site scripting (XSS) [15], cross-site resources through relatively lightweight client-side software request forgery (CSRF) [3], and session fixation [14]. Any of (e.g., a browser). Among other use cases, it is very helpful these could cause serious consequences: sensitive user infor- in the context of mobile computing—users may leverage the mation could be stolen, data and associated belongings could computing power on the cloud to compensate for the physical be damaged, or service availability could be compromised. limitations (e.g., hardware) of mobile devices. We use an online-banking example to explain what is in- Web applications, as an important component of cloud- volved in secure server-side scripting, and how proper ab- based services, are software applications running on the cloud. stractions can help. This application provides two services: They alleviate the burden of software maintenance, because showing the account balance (the “balance” service) and set- code is installed and maintained on web servers. Users access ting up a payment (the “payment” service). A user must be these applications typically through the use of web browsers. logged in to access the services. Unfortunately, it is notoriously difficult to program a solid Although serving multiple users, this web application logi- web application. Besides addressing web interactions, state cally deals with one client at a time. In an ideal view, there are maintenance, and whimsical user navigation behaviors, pro- multiple orthogonal instances of the server program running, grammers must also avoid a minefield of security vulnerabili- each taking care of a single client. Every single instance of ties. The problem is twofold. On the one hand, we lack a clear the program can be viewed as a sequential program of a con- understanding of the new computation model underlying web ventional application. A work flow graph following this ideal applications. On the other hand, we lack proper abstractions view is shown in Figure 1. for hiding common and subtle coding details that are orthog- The above ideal view cannot be directly implemented, be- onal to the functional logic of specific web applications. cause of some limitations of the underlying HTTP mecha- The BASS project at DOCOMO USA Labs aims to address nism for web interactions. In particular, there is no persistent these issues using declarative server-side scripting. It allows channel for a server program to obtain input from a client. programmers to work in an ideal world equipped with new ab- Instead, HTTP supports a one-shot request-response model stractions to tackle problematic aspects of web programming. where a client requests resource identified by a URL, and a Early results on BASS have been published at WWW’08.1 In server responds with the resource if the request is accepted. 1Sections 2, 3, 6, and 7 are adapted from the authors’ paper titled Better Abstractions for Secure Server-Side Scripting at WWW’08. Prog0 Prog1 Prog2 Prog3 be malicious, or attackers may trick innocent clients into mak- Send login Parse login Parse selection Parse payment ing mistakes. Indeed, there have been many common vulner- form (PC=Prog1) abilities identified. Secure programming solutions exist, but Send service Send balance Send payment Set up payment form & service form form a programmer must be aware of all the issues involved and (PC=Prog2) (PC=Prog2) (PC=Prog3) Send confirmation implement the related defenses. Most of the defenses are or- & service form (PC=Prog2) thogonal to the functional logic of specific web applications. Their handling further complicates server-side scripting. We now briefly overview some representative security issues. Figure 2: Actual work flow of online banking CSRF: An attacker may forge a request as if it were in- tended by a user. This is applicable when SIDs are stored in Using HTTP, web interactions are typically carried out as a cookies. Given a vulnerable banking program, CSRF can be sequence of requests (form submissions providing user input) launched if a user, while logged in, opens a malicious email and responses (web pages presenting information): containing a crafted image link. Trying to load the image, the user’s browser may follow the link and send a request asking for a payment to be set up to the attacker. HTTP 0 ! HTML 0 ! HTTP 1 ! HTML 1 ! HTTP 2 ! HTML 2 ::: XSS: An attacker may inject code into the web page that a server program sends to a user. For example, an attacker Using this model, a server program is split into multiple frag- sends to a user a crafted link with JavaScript code embedded; ments, each taking an HTTP request and producing an HTML when the user loads the link, a vulnerable server program may response. In the response, there can be a web form with an propagate the code into the HTML response. The code, now embedded URL pointing to the next fragment, so that the next coming from the server, gains the privilege of the server do- request is targeted correctly. Therefore, the server work flow main. It may then read the cookie set by the server and send it of our banking application is more accurately described as to the attacker. There are also second-order attacks [17] that in Figure 2. There are 4 program fragments connected with do not require the use of forged requests. URL embeddings, as indicated by the dashed lines. In par- Session fixation: An attacker may trick a user into inter- ticular, because the payment service requires user input, the acting with the server using a fixed SID. This is applicable structure of the service loop in the ideal view can no longer if SIDs are embedded in URLs. A user may follow a link be coded as an explicit loop. Instead, a goto-style structure is in an email which claims to be from our banking site. The exhibited through URL embeddings. Such fragmentation and link takes the user to our site, but using an SID fixed by an low-level control structures obscure the control flow. attacker. If the server programs use the same SID for later Besides obscurity, there is a bigger issue: since HTTP is interactions after the user logs in, the knowledge of the SID stateless, server programs must maintain program states on will grant the attacker the user’s privileges. their own. In the example, the user name obtained from the login input must be saved and restored explicitly across the Others: Many other aspects affect security [18]. Since later web interactions. In addition, one must somehow cor- a web application is implemented as multiple program frag- relate incoming requests with specific clients, since multiple ments, each fragment is open as a service interface. An at- clients may be interacting with the server at the same time, tacker could make up requests to the interfaces without fol- although in logically separate transactions. lowing the links in server responses. Using crafted requests, In general, a web application needs to encode states at a they could poison program states (e.g., by modifying na¨ıve level above HTTP. Typically, a virtual concept of “a session” implementations of client-side states), inject malformed input is used to refer to a logical transaction. Every session is asso- (e.g., by exploiting insufficient input validation), or circum- ciated with a unique ID, called SID. Saved program states and vent work flows (e.g., by using the “back” button). incoming client requests are both identified by the SID. As a Programmers need to be aware of all these issues and fol- result, much code in server programs is dedicated to manag- low the relevant security practices. In the result code, func- ing sessions. Before generating a response, a server program tional logic is intertwined with security manipulations. Con- must save state and embed the SID in the response. Upon re- sequently, secure web programming is difficult, and web pro- ceiving a request, the server program must obtain an SID from grams are hard to maintain. the request and load state. Based on the application, some parts of the state should be saved on the server, whereas others 3 BASS should be on the client via cookie or URL embedding.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us