Robust Defenses for Cross-Site Request Forgery

Robust Defenses for Cross-Site Request Forgery

Robust Defenses for Cross-Site Request Forgery Adam Barth Collin Jackson John C. Mitchell Stanford University Stanford University Stanford University [email protected] [email protected] [email protected] ABSTRACT to cross-site scripting, which has received a great deal of Cross-Site Request Forgery (CSRF) is a widely exploited attention [13], and the effective mitigation of SQL injec- web site vulnerability. In this paper, we present a new vari- tion through parameterized SQL queries [7], cross-site re- ation on CSRF attacks, login CSRF, in which the attacker quest forgery has received comparatively little attention. In forges a cross-site request to the login form, logging the vic- a CSRF attack, a malicious site instructs a victim's browser tim into the honest web site as the attacker. The severity to send a request to an honest site, as if the request were of a login CSRF vulnerability varies by site, but it can be part of the victim's interaction with the honest site, lever- as severe as a cross-site scripting vulnerability. We detail aging the victim's network connectivity and the browser's three major CSRF defense techniques and find shortcomings state, such as cookies, to disrupt the integrity of the vic- with each technique. Although the HTTP Referer header tim's session with the honest site. could provide an effective defense, our experimental obser- For example, in late 2007 [41], Gmail had a CSRF vul- vation of 283;945 advertisement impressions indicates that nerability. When a Gmail user visited a malicious site, the the header is widely blocked at the network layer due to pri- malicious site could generate a request to Gmail that Gmail vacy concerns. Our observations do suggest, however, that treated as part of its ongoing session with the victim. In the header can be used today as a reliable CSRF defense November 2007, a web attacker exploited this CSRF vul- over HTTPS, making it particularly well-suited for defend- nerability to inject an email filter into David Airey's Gmail ing against login CSRF. For the long term, we propose that account [1]. This filter forwarded all of David Airey's email browsers implement the Origin header, which provides the to the attacker's email address, which allowed the attacker to security benefits of the Referer header while responding to assume control of davidairey.com because Airey's domain privacy concerns. registrar used email authentication, leading to significant in- convenience and financial loss. In this paper, we examine the scope and diversity of CSRF Categories and Subject Descriptors vulnerabilities, study existing defenses, and describe incre- K.6.5 [Management of Computing and Information mental and new defenses based on headers and web appli- Systems]: Security and Protection cation firewall rules. We introduce login cross-site request forgery attacks, which are currently widely possible, dam- General Terms aging, and under-appreciated. In login CSRF, an attacker uses the victim's browser to forge a cross-site request to the Security, Design, Experimentation honest site's login URL, supplying the attacker's user name and password. A vulnerable site will interpret this request Keywords and log the victim into the site as the attacker. Many web sites, including Yahoo, PayPal, and Google, are vulnerable Cross-Site Request Forgery, Web Application Firewall, HTTP to login CSRF. The impact of login CSRF attacks vary by Referer Header, Same-Origin Policy site, ranging from allowing the attacker to mount XSS at- tacks on Google to allowing the attacker to obtain sensitive 1. INTRODUCTION financial information from PayPal. Cross-Site Request Forgery (CSRF) is among the twenty There are three widely used techniques for defending against most-exploited security vulnerabilities of 2007 [9], along with CSRF attacks: validating a secret request token, validating Cross-Site Scripting (XSS) and SQL Injection. In contrast the HTTP Referer header, and validating custom headers attached to XMLHttpRequests. None of these techniques are satisfactory, for a variety of reasons. Permission to make digital or hard copies of all or part of this work for 1. The most popular CSRF defense is to include a secret personal or classroom use is granted without fee provided that copies are token with each request and to validate that the re- not made or distributed for profit or commercial advantage and that copies ceived token is correctly bound to the user's session, bear this notice and the full citation on the first page. To copy otherwise, to preventing CSRF by forcing the attacker to guess the republish, to post on servers or to redistribute to lists, requires prior specific session's token. There are a number of variations on permission and/or a fee. CCS’08, October 27–31, 2008, Alexandria, Virginia, USA. this approach, each fraught with pitfalls, and even sites Copyright 2008 ACM 978-1-59593-810-7/08/10 ...$5.00. that implement the technique correctly often overlook their login requests because login request lack a session 2. A study of current browser behavior, including exper- to which to bind the token. imental measurement of Referer header suppression based on 283;945 advertising impression on two adver- 2. The simplest CSRF defense is to validate the HTTP tisement networks. Based on our experimental data, Referer header, preventing CSRF by accepting re- we propose a refinement to Referer validation: employ quests only from trusted sources. While effective in HTTPS and strict Referer validation. This technique principle, this technique must deal with requests that is secure because browsers ensure the integrity of the lack a Referer header entirely. Sites can either pro- Referer header and is compatible with 99:9% of the cess these requests or block them. If a site processes web users we observed in our experiment. requests that lack a Referer header, the defense is inef- fective because the Referer header can be suppressed 3. A proposal for an Origin header that contains only the by an attacker. If the site refuses to process these re- the scheme, host, and port parts of the referring URL, quests, our experimental measurements indicate that addressing the privacy concerns of the Referer header the site will exclude an appreciable fraction of users. while containing the information necessary for CSRF defense. For browsers, we have implemented this pro- 3. XMLHttpRequest's popularity has increased recently posal as a 466-line extension to Firefox and as a eight- with more sites implementing AJAX interfaces. Sites line patch to WebKit. For sites, we have implemented can defend against CSRF by setting a custom header Origin validation in three lines of ModSecurity, a web via XMLHttpRequest and validating that the header application firewall for Apache. is present before processing state-modifying requests. Although effective, this defense requires sites to make 4. A study of related session initialization vulnerabilities all state-modifying requests via XMLHttpRequest, a and defenses for OpenID, PHP cookieless sessions, and requirement that prevents many natural site designs. HTTPS cookies. We implement our cookie defense as a 202-line extension to Firefox. Referer validation is an appealing CSRF defense, but the technique is hampered by the widespread suppression of the Referer header. To evaluate this defense, we conducted an Organization. The remainder of the paper is organized as experiment to determine how frequently, and under what follows. Section 2 reviews the threat model. Section 3 pro- circumstances, Referer header is blocked. We placed adver- vides examples of login CSRF. Section 4 analyzes existing tisements on two different advertising networks that caused defenses using experimental data. Section 5 proposes the 283;945 browsers displaying the advertisements to issue net- Origin header as a defense mechanism. Section 6 general- work requests to servers in our laboratory. Our results show izes login CSRF to other session initialization vulnerabilities. that although the Referer header is suppressed often over Section 7 describes related work. Section 8 concludes. HTTP, the header is rarely suppressed over HTTPS, let- ting current sites prevent CSRF by using HTTPS and strict 2. CSRF DEFINED Referer validation. To create a robust CSRF defense, we propose that browsers In a cross-site request forgery (CSRF) attack, the attacker include an\Origin"header with POST requests. This header disrupts the integrity of the user's session with a web site provides the security benefits of the Referer header while by injecting network requests via the user's browser. The addressing the privacy concerns that have lead to the wide- browser's security policy allows web sites to send HTTP spread suppression of the Referer header. The Origin header requests to any network address. This policy allows an at- lets sites defend against CSRF by deploying a few simple web tacker that controls content rendered by the browser to use application firewall rules. This mechanism also protects lo- resources not otherwise under his or her control: gin forms without requiring additional effort from the site's 1. Network Connectivity. For example, if the user developers. is behind a firewall, the attacker is able to leverage Although CSRF defenses are necessary to protect session the user's browser to send network requests to other integrity, other session integrity attacks are possible, even machines behind the firewall that might not be directly against sites without XSS or CSRF vulnerabilities. We de- reachable from the attacker's machine. Even if the user scribe other attacks on session initialization in which the is not behind a firewall, the requests carry the user's user becomes authenticated to the honest site as the at- IP address and might confuse services relying on IP tacker. Although similar to login CSRF, these attacks do address authentication [35].

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 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