Session Management Dan Boneh CS 142 Winter 2009. Sessions A sequence of requests and responses from one browser to one (or more) sites Session can be.

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.
ForceHTTPS: Protecting High-Security Web Sites from Network Attacks Collin Jackson and Adam Barth.
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.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
ATTACKING AUTHENTICATION The Web Application Hacker’s Handbook, Ch. 6 Presenter: Jie Huang 10/31/2012.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Online Security Tuesday April 8, 2003 Maxence Crossley.
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.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Web Security: Session Management
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.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
 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)
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Security.NET Chapter 1. How Do Attacks Occur? Stages of attack Examples of attacker actions 1. FootprintRuns a port scan on the firewall 2. PenetrationExploits.
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.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
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.
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
Feedback #2 (under assignments) Lecture Code:
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.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
Ram Santhanam Application Level Attacks - Session Hijacking & Defences
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
1 Robust Defenses for Cross-Site Request Forgery Adam Barth, Collin Jackson, John C. Mitchell Stanford University 15th ACM CCS.
Web Database Programming Week 7 Session Management & Authentication.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
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.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
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,
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
Carrie Estes Collin Donaldson.  Zero day attacks  “zero day”  Web application attacks  Signing up for a class  Hardening the web server  Enhancing.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Group 18: Chris Hood Brett Poche
Building Secure ColdFusion Applications
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Avishai Wool Slides credit: Dan Boneh, John Mitchell
Cross-Site Forgery
Cross-Site Request Forgeries: Exploitation and Prevention
Auditing Etsy The Security of Etsy
CSC 495/583 Topics of Software Security Intro to Web Security
Web Security Advanced Network Security Peter Reiher August, 2014
John Mitchell (based on Dan’s previous slides)
Cross Site Request Forgery New Attacks and Defenses
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Cross-Site Scripting Attack (XSS)
Cross Site Request Forgery (CSRF)
Presentation transcript:

Session Management Dan Boneh CS 142 Winter 2009

Sessions A sequence of requests and responses from one browser to one (or more) sites Session can be long (Gmail - two weeks) or short without session mgmt: users would have to constantly re-authenticate Session mgmt: Authorize user once; All subsequent requests are tied to user

Pre-history: HTTP auth HTTP request:GET /index.html HTTP response contains: WWW-Authenticate: Basic realm="Password Required“ Browsers sends hashed password on all subsequent HTTP requests: Authorization: Basic ZGFddfibzsdfgkjheczI1NXRleHQ=

HTTP auth problems Hardly used in commercial sites User cannot log out other than by closing browser  What if user has multiple accounts?  What if multiple users on same computer? Site cannot customize password dialog Confusing dialog to users Easily spoofed

Session tokens BrowserWeb Site GET /index.html set anonymous session token GET /books.html anonymous session token POST /do-login Username & password elevate to a logged-in session token POST /checkout logged-in session token check credentials (CS155) Validate token

Storing session tokens: Lots of options (but none are perfect) Browser cookie: Set-Cookie: SessionToken=fduhye63sfdb Embedd in all URL links: ? SessionToken=kh7y3b In a hidden form field: Window.name DOM property

Storing session tokens: problems Browser cookie: browser sends cookie with every request, even when it should not (CSRF) Embed in all URL links: token leaks via HTTP Referer header In a hidden form field: short sessions only Best answer: a combination of all of the above. why? next lecture.

The HTTP referer header Referer leaks URL session token to 3 rd parties

SESSION HIJACKING Attacker waits for user to login; then attacker obtains user’s Session Token and “hijacks” session

1. Predictable tokens Example: counter (Verizon Wireless)  user logs in, gets counter value, can view sessions of other users Example: weak MAC (WSJ) token = {userid, MAC k (userid) } Weak MAC exposes k from few cookies. Apache Tomcat: generateSessionID() MD5(PRG) … but weak PRG [GM’05]. Predictable SessionID’s Session tokens must be unpredicatble to attacker: Use underlying framework. Rails: token = MD5( current time, random nonce )

2. Cookie theft Example 1: login over SSL, but subsequent HTTP What happens as wireless Café ? Other reasons why session token sent in the clear:  HTTPS/HTTP mixed content pages at site  Man-in-the-middle attacks on SSL Example 2: Cross Site Scripting (XSS) exploits Amplified by poor logout procedures: Logout must invalidate token on server

Session fixation attacks Suppose attacker can set the user’s session token: For URL tokens, trick user into clicking on URL For cookie tokens, set using XSS exploits Attack: (say, using URL tokens) 1. Attacker gets anonymous session token for site.com 2. Sends URL to user with attacker’s session token 3. User clicks on URL and logs into site.com  this elevates attacker’s token to logged-in token 4. Attacker uses elevated token to hijack user’s session.

Session fixation: lesson When elevating user from anonymous to logged-in, always issue a new session token Once user logs in, token changes to value unknown to attacker.  Attacker’s token is not elevated.

Generating session tokens Goal: prevent hijacking and avoid fixation

Option 1: minimal client-side state SessionToken = [random unpredictable string] (no data embedded in token) Server stores all data associated to SessionToken: userid, login-status, login-time, etc. Can result in server overhead: When multiple web servers at site, lots of database lookups to retrieve user state.

Option 2: lots of client-side state SessionToken: SID = [ userID, exp. time, data] where data = (capabilities, user data,...) SessionToken = Enc-then-MAC (k, SID) (as in CS255) k: key known to all web servers in site. Server must still maintain some user state: e.g. logout status (should be checked on every request) Note that nothing binds SID to client’s machine

Binding SessionToken to client’s computer; mitigating cookie theft Client IP Address: Will make it harder to use token at another machine But honest client may change IP addr during session  client will be logged out for no reason. Client user agent: A weak defense against theft, but doesn’t hurt. SSL session key: Same problem as IP address (and even worse) approach: embed machine specific data in SID

MORE ON CROSS SITE SCRIPTING (XSS)

Recall: reflected XSS search field on victim.com: ? term = apple Server-side implementation of search.php: Echo search term directly into HTML response To exploit, attacker crafts a URL containing a script ? term = do_something_bad (no filtering of user input)

Reflected XSS: the exploit browserattacker site.com user logs in send XSS URL click on URL respond with attacker’s script Bad things happen: site.com session token sent to attacker rewrite site.com DOM rewrite links and persist boom

Persistent XSS XSS script is injected into blog, message board, etc. When user’s view the block, the malicious script runs in their browser  blogs must filter uploaded content The famous MySpace Samy worm: (2005) Bypassed MySpace script filters Script spread from user to user making everyone Samy’s friend

Persistent XSS using images Suppose pic.jpg on web server contains HTML !  request for results in: HTTP/ OK … Content-Type: image/jpeg fooled ya  IE will render this as HTML (despite Content-Type) Consider photo sharing sites that support image uploads What if attacker uploads an “image” that is a script?

Universal XSS Adobe PDF viewer “feature” : (version <= 7.9) # whatever=javascript: --- code – viewer will execute the javascript in origin of current domain! Any site that hosts a single PDF is vulnerable to XSS ! (in fact, PDF files in Windows can also be used)