Cross-Site Request Forgery: The Sleeping Giant. Jeremiah Grossman Founder and CTO, WhiteHat Security

Similar documents
WHY CSRF WORKS. Implicit authentication by Web browsers

Preparing for the Cross Site Request Forgery Defense

Hacking Intranet Websites from the Outside

Advanced Web Technology 10) XSS, CSRF and SQL Injection

Web Application Security. Philippe Bogaerts

Is Browsing Safe? Web Browser Security. Subverting the Browser. Browser Security Model. XSS / Script Injection. 1. XSS / Script Injection

CIS 4360 Secure Computer Systems XSS

Information Security CS 526 Topic 11

Common Websites Security Issues. Ziv Perry

WEB SECURITY: XSS & CSRF

NEW. WhiteHat Website Security Statistics Report. A WhiteHat Security Whitepaper. October 2007 Jeremiah Grossman Founder and CTO, WhiteHat Security

Application vulnerabilities and defences

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

Web insecurity Security strategies General security Listing of server-side risks Language specific security. Web Security.

Provide you with a quick introduction to web application security Increase you awareness and knowledge of security in general Show you that any

CSCD 303 Essential Computer Security Fall 2018

CSC 482/582: Computer Security. Cross-Site Security

CSCD 303 Essential Computer Security Fall 2017

OWASP Top 10 Risks. Many thanks to Dave Wichers & OWASP

Client Side Injection on Web Applications

Information Security CS 526 Topic 8

Abusing Windows Opener to Bypass CSRF Protection (Never Relay On Client Side)

Web basics: HTTP cookies

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

CSCE 813 Internet Security Case Study II: XSS

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

Lecture 17 Browser Security. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Some slides from Bailey's ECE 422

Web 2.0 and AJAX Security. OWASP Montgomery. August 21 st, 2007

OWASP Top 10 The Ten Most Critical Web Application Security Risks

Web basics: HTTP cookies

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach

Lecture Overview. IN5290 Ethical Hacking

Lecture 6: Web hacking 2, Cross Site Scripting (XSS), Cross Site Request Forgery (CSRF), Session related attacks

Robust Defenses for Cross-Site Request Forgery Review

Computer Security CS 426 Lecture 41

CS 161 Computer Security

Solutions Business Manager Web Application Security Assessment

Robust Defenses for Cross-Site Request Forgery

INF3700 Informasjonsteknologi og samfunn. Application Security. Audun Jøsang University of Oslo Spring 2015

P2_L12 Web Security Page 1

The PKI Lie. The OWASP Foundation Attacking Certificate Based Authentication. OWASP & WASC AppSec 2007 Conference

Copyright

OpenID Security Analysis and Evaluation

John Coggeshall Copyright 2006, Zend Technologies Inc.

ISSA: EXPLOITATION AND SECURITY OF SAAS APPLICATIONS. Waqas Nazir - CEO - DigitSec, Inc.

Cross-Site Scripting (XSS) Professor Larry Heimann Web Application Security Information Systems

Computer Security 3e. Dieter Gollmann. Chapter 18: 1

Cross-Site Request Forgery

MWR InfoSecurity Advisory. 26 th April Elastic Path Administrative. Quit. Session Hijacking through Embedded XSS

CS 142 Winter Session Management. Dan Boneh

Web Application Threats and Remediation. Terry Labach, IST Security Team

CSE361 Web Security. Attacks against the client-side of web applications. Nick Nikiforakis

Aguascalientes Local Chapter. Kickoff

This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in

Web Security II. Slides from M. Hicks, University of Maryland

Top 10 Web Application Vulnerabilities

Ruby on Rails Secure Coding Recommendations

Assignment 6: Web Security

Application Layer Attacks. Application Layer Attacks. Application Layer. Application Layer. Internet Protocols. Application Layer.

OWASP Thailand. Proxy Caches and Web Application Security. OWASP AppSec Asia October 21, Using the Recent Google Docs 0-Day as an Example

Domino Web Server Security

OWASP TOP 10. By: Ilia

SECURITY TESTING. Towards a safer web world

Featuring. and. Göteborg. Ulf Larson Thursday, October 24, 13

XSS Homework. 1 Overview. 2 Lab Environment

Penetration Test Report

Cross Site Request Forgery

Your Turn to Hack the OWASP Top 10!

VULNERABILITIES IN 2017 CODE ANALYSIS WEB APPLICATION AUTOMATED

Security Testing White Paper

Security Engineering by Ross Andersson Chapter 18. API Security. Presented by: Uri Ariel Nepomniashchy 31/05/2016

FIREFOX MENU REFERENCE This menu reference is available in a prettier format at

Project 2: Web Security

Web Security. Thierry Sans

Web Security, Summer Term 2012

Web Security, Summer Term 2012

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

NET 311 INFORMATION SECURITY

EasyCrypt passes an independent security audit


Title: Multiple Remote Command Execution vulnerabilities on Avaya Intuity Audix LX (plus some client-side bugs)

Cross-Site Request Forgery in Cisco SG220 series

Preventing Image based Cross Site Request Forgery Attacks

CORS Attacks. Author: Milad Khoshdel Blog: P a g e. CORS Attacks

HTTP Security Headers Explained

Web Security: Vulnerabilities & Attacks

Content Security Policy

Progress Exchange June, Phoenix, AZ, USA 1


Network Security - ISA 656 Web Security

Andrew Muller, Canberra Managing Director, Ionize, Canberra The challenges of Security Testing. Security Testing. Taming the Wild West

Kishin Fatnani. Founder & Director K-Secure. Workshop : Application Security: Latest Trends by Cert-In, 30 th Jan, 2009

Web Application Vulnerabilities: OWASP Top 10 Revisited

MTAT Research Seminar in Cryptography The Security of Mozilla Firefox s Extensions

COMP9321 Web Application Engineering

Automatically Checking for Session Management Vulnerabilities in Web Applications

Avoiding Web Application Flaws In Embedded Devices. Jake Edge LWN.net URL for slides:

COMP9321 Web Application Engineering

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

Transcription:

Cross-Site Request Forgery: The Sleeping Giant Jeremiah Grossman Founder and CTO, WhiteHat Security

Cross-Site Request Forgeries (CSRF) 1. Session Riding 2. Client-Side Trojans 3. Confused Deputy 4. Web Trojans. Confused? Every year, for the past several years, the exact same Web attack is discovered, analyzed, and subsequently renamed. Whatever it s called, it all means the same thing: An attacker is forcing an unsuspecting user s browser to send requests they didn t intend and potentially compromising their own banking, e-commerce or other website accounts. Attackers have begun to actively exploit CSRF vulnerabilities across the Web. Why now? Because it s incredibly easy and the vast majority of websites are vulnerable to it. How do you stop an attack originating from a real user, who could be properly logged-in, from making a legitimate request - except the problem is they did not intend to make the request? For those familiar with Cross-Site Scripting, Chris Shiflett (principal of OmniTI) said it best: Cross-Site Request Forgeries are an almost opposite style of attack. Rather than exploiting the trust that a user has for a website, they (CSRF attacks) exploit the trust that a website has for a user. 5 Here s an example of how a CSRF attack works: Let s say you re logged-in to your online bank, which has a Transfer Funds feature. To transfer money from one account to another, you would fill out a Web-form similar to the one in Figure 1. After specifying the appropriate From account, To account, and dollar amount, you click the Continue button. For our purposes, let s say the From account is 314159265, the To account is 011235813, and we re transferring $5,000. Figure 1: Transfer Funds Web-form: When the button is pressed, your Web browser issues an HTTP request (Figure 2) to the Web server executing the process. Notice that the form values are located within the POST body of the HTTP request and the session credential (Cookie) in the headers. Cross-Site Request Forgery 2

POST http://webbank/transfer_funds.cgi HTTP/1.1 Host: webbank User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-us;) Firefox/1.4.1 Cookie: JSPSESSIONID= 4353DD35694D47990BCDF36271740A0C from=314159265&to=011235813&amount=5000&date=11072006 Figure 2: Transfer Funds POST Request If the request was successful, $5,000 would be transferred from account 314159265 to account 01123581. What s interesting is that many Web applications, such as transfer_funds.cgi, do not distinguish between parameters sent using GET or POST. The same Transfer Funds request could be updated to use GET and work just fine. In Figure 3, notice the POST method has been replaced by GET and the parameters in the HTTP body have been added to the query string. GET http://webbank/transfer_funds.cgi? from=314159265&to=011235813&amount=5000&date=11072006 HTTP/1.1 Host: webbank User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-us;) Firefox/1.4.1 Cookie: JSPSESSIONID= 4353DD35694D47990BCDF36271740A0C Diagram 3: Transfer Funds GET Request When bank customers are still logged-in, they may stumble across a Web page containing the HTML in Figure 4. A customer may find this link in a phishing email, message board post, instant message spam, etc. Notice the SRC attribute of the IMG tag has a similar URL value to that of Figure 3. similar in that the To parameter value has been updated with another account number. <IMG SRC=http://webbank/transfer_funds.cgi? from=314159265&to=1618&amount=5000&date=11072006&re=0>unt=5000&date=11072006&re=0> Diagram 4: http://hacker/foo.html When the Web browser loads this page, the IMG tag forces a forged request with the URL specified and, if the customer is still logged-in, $5,000 from account 314159265 will instead to be sent to account 1618, belonging to the hacker. To the online bank the request completely legitimate. CSRF attacks succeed because the customer is the one who is actually making the request by automatically sending the session credentials (cookies). Just about every important feature of every website has the potential for being exploited in this way. Cross-Site Request Forgery 3

The Confusion over CSRF Solutions Well-meaning researchers have posited various solutions to the CSRF problem. However, CSRF is a particularly difficult issue to resolve and it is important to understand what really works and how. Let s take a look at some common suggestions and why they don t work before digging into an effective solution. 1. Some online guidance says CSRF is solvable by forcing all sensitive requests over POST while denying GETs. The thinking is you can only automatically force the user s browser to send GET requests, via the IMG tag for instance, and not POST. But, this is not the case. JavaScript is fully capable of sending POST requests via form submissions. It s not to say that sensitive should not be restricted to POST for other valid security reasons, just not CSRF protection. 2. XSS vulnerabilities are capable of rendering any CSRF solution as useless. In fact, the Samy Worm 6 that targeted MySpace managed to circumvent the website s CSRF protections by using XSS to acquire the tokens ahead of time. The bottom line is if you plan to add CSRF protections, you must address any XSS issues as well to achieve the value. 3. Another suggested solution to CSRF is the use of HTTP Request Referers. The rational is that CSRFs have offdomain referers, since they are generated on another website other than the legitimate one. Normally, client-side data should never be trusted for security purposes. But, in the case of CSRF, it s been thought that attackers cannot modify the referer on behalf of the user. However, it has been found this in fact can be done through the use of certain browser 7 and flash exploits 8. For this reason, the method is not reliable, but perhaps can be viewed as another incremental roadblock. A Real Solution The best defense against CSRF attacks is unpredictable tokens, a piece of data the server can use to validate the request which an attacker can t guess. For example, an important request could contain a digest of the user s session credential, which is different for every user. And, for a little extra security, add a timestamp to the token to limit the window of opportunity as specified in the POST body of Figure 5: token = md5(session + timestamp). POST http://webbank/transfer_funds.cgi HTTP/1.1 Host: webbank User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-us;) Firefox/1.4.1 Cookie: JSPSESSIONID= 4353DD35694D47990BCDF36271740A0C from=314159265&to=011235813&amount=5000&date=11072006&token=4e0fc1a82c3ca3b9d2a146 2570f6c674&timestamp=1184001456 Diagram 5: Transfer Funds POST Request with Token Cross-Site Request Forgery 4

Unless the attacker can obtain the user s session credential, which they should never be able to do, they can t manufacture a valid request even if they knew the scheme. This method can also be applied to either GET or POST requests. There are two other solutions worth mentioning: The first is limiting the time in which a user s session credential is valid. By enforcing inactivity timeouts, you limit the window of opportunity for a successful CSRF attack. (This is independent of whether the user decides to logout or not.) The second method is password re-verification, in which the user must type in their password when requesting a particularly critical function. Notes: 1 http://en.wikipedia.org/wiki/cross-site_request_forgery 2 http://www.securenet.de/papers/session_riding.pdf 3 http://www.zope.org/members/jim/zopesecurity/clientsidetrojan 4 http://www.cap-lore.com/captheory/confuseddeputy.html 5 http://phpsec.org/projects/guide/2.html 6 http://www.namb.la/ 7 http://www.securityfocus.com/archive/1/411823 8 http://www.webappsec.org/lists/websecurity/archive/2006-07/msg00069.html Cross-Site Request Forgery 5

About the Author Jeremiah Grossman is the founder and CTO of WhiteHat Security, a world-renowned expert in website vulnerability management, co-founder of the Web Application Security Consortium, and recently named to InfoWorld s Top 25 CTOs for 2007. Mr. Grossman is a frequent speaker at industry events including the BlackHat Briefings, ISACA, CSI, OWASP, Vanguard, ISSA, OWASP, Defcon, etc. He has authored of dozens of articles and white papers, credited with the discovery of many cutting-edge attack and defensive techniques and is co-author of the book XSS Exploits. Mr. Grossman is frequently quoted in major media publications such as InfoWorld, USA Today, PCWorld, Dark Reading, SC Magazine, SecurityFocus, C-Net, SC Magazine, CSO, and InformationWeek. Prior to WhiteHat he was an information security officer at Yahoo! Copyright 2009 WhiteHat Security, Inc. Product names or brands used in this publication are for identification purposes only and may be trademarks or brands of their respective companies. 09.09