CS526Topic 11: Web Security Part 11 Information Security CS 526 Topic 11 Web Security Part 1.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

Cross-site Request Forgery (CSRF) Attacks
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.
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)
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
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.
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
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)
D ATABASE S ECURITY Proposed by Abdulrahman Aldekhelallah University of Scranton – CS521 Spring2015.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Cookies Cross site scripting
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Lecture 16. OWASP: The Open Web Application Security Project
Prevent Cross-Site Scripting (XSS) attack
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Ladd Van Tol Senior Software Engineer Security on the Web Part One - Vulnerabilities.
JavaScript, Fourth Edition
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.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
1 Internet Browsing Vulnerabilities and Security ECE4112 Final Lab Ye Yan Frank Park Scott Kim Neil Joshi.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JavaScript – Quiz #9 Lecture Code:
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
CSCE 201 Web Browser Security Fall CSCE Farkas2 Web Evolution Web Evolution Past: Human usage – HTTP – Static Web pages (HTML) Current: Human.
1 Welcome to CSC 301 Web Programming Charles Frank.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Building Secure Web Applications With ASP.Net MVC.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University
Lecture 16 Page 1 CS 236 Online Web Security CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
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.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Web Browsing *TAKE NOTES*. Millions of people browse the Web every day for research, shopping, job duties and entertainment. Installing a web browser.
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.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
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.
Building Secure ColdFusion Applications
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
TOPIC: Web Security (Part-4)
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
World Wide Web policy.
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
Cross Site Request Forgery (CSRF)
Presentation transcript:

CS526Topic 11: Web Security Part 11 Information Security CS 526 Topic 11 Web Security Part 1

CS526Topic 11: Web Security Part 12 Readings for This Lecture Wikipedia –HTTP CookieHTTP Cookie –Same Origin PolicySame Origin Policy –Cross Site ScriptingCross Site Scripting –Cross Site Request ForgeryCross Site Request Forgery

Background Many sensitive tasks are done through web –Online banking, online shopping –Database access –System administration Web applications and web users are targets of many attacks –Cross site scripting –SQL injection –Cross site request forgery –Information leakage –Session hijacking CS5263Topic 11: Web Security Part 1

Web Browser and Network Browser Network Browser sends requests Web site sends response pages, which may include code Interaction susceptible to network attacks OS Hardware Web site request reply CS5264Topic 11: Web Security Part 1

Web Security/Privacy Issues Secure communications between client & server –HTTPS (HTTP over Secure Socket Layer) User authentication & session management –Cookies & other methods Active contents from different websites –Protecting resources maintained by browsers Web application security Web site authentication (e.g., anti-phishing) Privacy concerns CS526Topic 11: Web Security Part 15

HTTP: HyperText Transfer Protocol Browser sends HTTP requests to the server –Methods: GET, POST, HEAD, … –GET: to retrieve a resource (html, image, script, css,…) –POST: to submit a form (login, register, …) –HEAD Server replies with a HTTP response Stateless request/response protocol –Each request is independent of previous requests –Statelessness has a significant impact on design and implementation of applications CS5266Topic 11: Web Security Part 1

Use Cookies to Store State Info Cookies –A cookie is a name/value pair created by a website to store information on your computer Browser Server Enters form data Response + cookies Browser Server Request + cookies Returns data Http is stateless protocol; cookies add state CS5267Topic 11: Web Security Part 1

Cookies Fields An example cookie from my browser –Namesession-token –Content"s7yZiOvFm4YymG….” –Domain.amazon.com –Path/ –Send ForAny type of connection –ExpiresMonday, September 08, :19:41 PM CS526Topic 11: Web Security Part 18

Cookies Stored by the browser Used by the web applications –used for authenticating, tracking, and maintaining specific information about users e.g., site preferences, contents of shopping carts –data may be sensitive –may be used to gather information about specific users Cookie ownership –Once a cookie is saved on your computer, only the website that created the cookie can read it CS5269Topic 11: Web Security Part 1

Web Authentication via Cookies HTTP is stateless –How does the server recognize a user who has signed in? Servers can use cookies to store state on client –After client successfully authenticates, server computes an authenticator and gives it to browser in a cookie Client cannot forge authenticator on his own (session id) –With each request, browser presents the cookie –Server verifies the authenticator CS52610Topic 11: Web Security Part 1

A Typical Session with Cookies clientserver POST /login.cgi Set-Cookie:authenticator GET /restricted.html Cookie:authenticator Restricted content Verify that this client is authorized Check validity of authenticator Authenticators must be unforgeable and tamper-proof (malicious clients shouldn’t be able to modify an existing authenticator) How to design it? CS52611Topic 11: Web Security Part 1

Cross Site Scripting CS526Topic 11: Web Security Part 112

Client Side Scripting Web pages (HTML) can embed dynamic contents (code) that can be executed on the browser JavaScript –embedded in web pages and executed inside browser Java applets –small pieces of Java bytecodes that execute in browsers Browser extensions (plug-ins) provide further client-side programming abilities –E.g., Flash CS52613Topic 11: Web Security Part 1

HTML and Scripting … var num1, num2, sum num1 = prompt("Enter first number") num2 = prompt("Enter second number") sum = parseInt(num1) + parseInt(num2) alert("Sum = " + sum) … Browser receives content, displays HTML and executes scripts CS52614Topic 11: Web Security Part 1

Scripts are Powerful Client-side scripting is powerful and flexible, and can access the following resources –Local files on the client-side host read / write local files –Webpage resources maintained by the browser Cookies Domain Object Model (DOM) objects –steal private information –control what users see –impersonate the user –Communicating with websites (via XMLHttpRequest) CS52615Topic 11: Web Security Part 1

CS526Topic 11: Web Security Part 116 Domain Object Model (DOM) Object-oriented model to represent webpages that allow programming access in Javascript

Browser as an Operating System Web users visit multiple websites simultaneously A browser serves web pages (which may contain programs) from different web domains –i.e., a browser runs programs provided by mutually untrusted entities –Running code one does not know/trust is dangerous –A browser also maintains resources created/updated by web domains Browser must confine (sandbox) these scripts so that they cannot access arbitrary local resources Browser must have a security policy to manage/protect browser-maintained resources and to provide separation among mutually untrusted scripts CS526Topic 11: Web Security Part 117

Sandbox A security mechanism for separating/limiting running programs –Running untrusted programs. E.g., javascripts in webpages, mobile apps –Running programs that are likely to be exploited. E.g., network daemon programs Implementation: Clearly identify what resources a program needs and cut off the rest –Examples include operating system–level virtualization (such as Unix chroot), virtual machine monitors (VMMs), Java applets, CS526Topic 11: Web Security Part 118

Same Origin Policy The basic security model enforced in the browser SoP isolates the scripts and resources downloaded from different origins –E.g., evil.org scripts cannot access bank.com resources Use origin as the security principal –Note that the concept of user accounts does not apply here as security principals Origin = domain name + protocol + port –all three must be equal for origin to be considered the same CS52619Topic 11: Web Security Part 1

Security Principals A security principal is an entity that can be authenticated by a computer system or network. –Security principals, in addition to being able to be authenticated, are typically capable of being assigned rights and privileges over resources in the network. Unit to which information security policies can apply. Not to be confused with security principles. Choosing the right security principal is important. CS526Topic 11: Web Security Part 120

Same Original Policy: What it Controls Same-origin policy applies to the following accesses: –manipulating browser windows –URLs requested via the XmlHttpRequest –manipulating frames (including inline frames) –manipulating documents (included using the object tag) –manipulating cookies CS52621Topic 11: Web Security Part 1

Problems with S-O Policy Poorly enforced on some browsers –Particularly older browsers Limitations if site hosts unrelated pages –Example: Web server often hosts sites for unrelated parties –Same-origin policy allows script on one page to access properties of document from another Can be bypassed in Cross-Site-Scripting attacks Usability: Sometimes prevents desirable cross-origin resource sharing CS52622Topic 11: Web Security Part 1

Browser Architecture: One Process versus Multiple Processes Most processes (e.g., Firefox, Internet Explorer) use one process for a web browser –Multiple threads are used for rendering different webpages Chrome uses multiple processes –Use OS protection mechanism to ensure that webpages from different sites cannot easily interact Because they run in different processes –Reliability advantage: crashing in rendering one website doesn’t affect another –Security advantage: vulnerability in rendering does not compromise other sites; isolate plug-ins –Uses 3 types of processes: browser, renderers, plug- ins CS526Topic 11: Web Security Part 123

What will the following program output? #include void main() { int x; int y; y = (x = 3) + (x = 4); printf("%d %d\n", x, y); } CS526Topic 11: Web Security Part 124

Cross Site Scripting (XSS) Recall the basics –scripts embedded in web pages run in browsers –scripts can access cookies get private information –and manipulate DOM objects controls what users see –scripts controlled by the same-origin policy Why would XSS occur –Web applications often take user inputs and use them as part of webpage (these inputs can have scripts) CS52625Topic 11: Web Security Part 1

How XSS Works on Online Blog Everyone can post comments, which will be displayed to everyone who view the post Attacker posts a malicious comment that includes scripts (which reads local authentication credentials and send of to the attacker) Anyone who view the post can have local authentication cookies stolen Web apps will check that posts do not include scripts, but the check sometimes fail. Bug in the web application. Attack happens in browser. CS526Topic 11: Web Security Part 126

Effect of the Attack 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. Can infect other users: MySpace.com worm. CS52627Topic 11: Web Security Part 1

MySpace.com (Samy worm) Users can post HTML on their pages –MySpace.com ensures HTML contains no,, onclick, –However, attacker find out that a way to include Javascript within CSS tags: 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. More info: CS52628Topic 11: Web Security Part 1

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

Avoiding XSS bugs (ASP.NET) ASP.NET 1.1: –Server.HtmlEncode(string) Similar to PHP htmlspecialchars –validateRequest: (on by default) Crashes page if finds in POST data. Looks for hardcoded list of patterns. Can be disabled: CS52630Topic 11: Web Security Part 1

CS526Topic 11: Web Security Part 131 Cross site request forgery

Cross site request forgery (abbrev. CSRF or XSRF) Also known as one click attack or session riding Effect: Transmits unauthorized commands from a user who has logged in to a website to the website. Recall that a browser attaches cookies set by domain X to a request sent to domain X; the request may be from another domain –Site Y redirects you to facebook; if you already logged in, the cookie is attached by the browser CS52632Topic 11: Web Security Part 1

CSRF Explained Example: –User logs in to bank.com. Forgets to sign off. –Session cookie remains in browser state –Then user visits another site containing: … document.F.submit(); –Browser sends user auth cookie with request Transaction will be fulfilled Problem: –The browser is a confused deputy; it is serving both the websites and the user and gets confused who initiated a request CS52633Topic 11: Web Security Part 1

Real World CSRF Vulnerabilities Gmail NY Times ING Direct (4 th largest saving bank in US) YouTube Various DSL Routers Purdue WebMail PEFCU Purdue CS Portal … CS52634Topic 11: Web Security Part 1

Prevention Server side: –use cookie + hidden fields to authenticate a web form hidden fields values need to be unpredictable and user- specific; thus someone forging the request need to guess the hidden field values –requires the body of the POST request to contain cookies Since browser does not add the cookies automatically, malicious script needs to add the cookies, but they do not have access because of Same Origin Policy User side: –logging off one site before using others –selective sending of authentication tokens with requests (may cause some disruption in using websites) CS52635Topic 11: Web Security Part 1

CS526Topic 11: Web Security Part 136 Coming Attractions … More Web Security Issues –SQL injection –Side channel information leakage –Cookie privacy issues