Lecture 15 Page 1 CS 136, Spring 2016 Web Security Computer Security Peter Reiher May 24, 2016.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

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.
 Natural consequence of the way Internet is organized o Best effort service means routers don’t do much processing per packet and store no state – they.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
Lecture 2 Page 1 CS 236, Spring 2008 Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher Spring, 2008.
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.
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.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
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.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Lecture 7 Page 1 CS 236 Online Password Management Limit login attempts Encrypt your passwords Protecting the password file Forgotten passwords Generating.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
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.
Reliability & Desirability of Data
© 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
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
Browser Security Evaluation IE6 vs. IE7 vs. Firefox 3.0 Gowri Kanugovi.
Protecting Internet Communications: Encryption  Encryption: Process of transforming plain text or data into cipher text that cannot be read by anyone.
Lecture 15 Page 1 Advanced Network Security Perimeter Defense in Networks: Firewalls Configuration and Management Advanced Network Security Peter Reiher.
Feedback #2 (under assignments) Lecture Code:
Chapter 10 Security and Encryption. Objectives Explain the nature of a threat model Be able to construct a threat model Be aware of common threats to.
Lecture 16 Page 1 Advanced Network Security Perimeter Defense in Networks: Virtual Private Networks Advanced Network Security Peter Reiher August, 2014.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Lecture 15 Page 1 CS 136, Fall 2014 Web Security Computer Security Peter Reiher December 9, 2014.
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
CIS 450 – Network Security Chapter 4 - Spoofing. Definition - To fool. In networking, the term is used to describe a variety of ways in which hardware.
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.
Lecture 19 Page 1 CS 236 Online Advanced Research Issues in Security: Web Security and Privacy CS 236 On-Line MS Program Networks and Systems Security.
Lecture 16 Page 1 CS 236 Online Web Security CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Chapter 12: How Private are Web Interactions?. Why we care? How much of your personal info was released to the Internet each time you view a Web page?
Lecture 16 Page 1 CS 236 Online Exploiting Statelessness HTTP is designed to be stateless But many useful web interactions are stateful Various tricks.
Lecture 19 Page 1 CS 136, Spring 2009 Web Security and Privacy CS 136 Computer Security Peter Reiher June 4, 2009.
Lecture 17 Page 1 Advanced Network Security Network Denial of Service Attacks Advanced Network Security Peter Reiher August, 2014.
Lecture9 Page 1 CS 236 Online Operating System Security, Con’t CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Secure Transactions Chapter 17. The user's machine No control over security of user's machine –Might be in very insecure: library, school, &c. Users disable.
Lecture 12 Page 1 CS 136, Spring 2009 Network Security: Firewalls CS 136 Computer Security Peter Reiher May 12, 2009.
Lecture 2 Page 1 CS 236 Online Security Policies Security policies describe how a secure system should behave Policy says what should happen, not how you.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Lecture 9 Page 1 CS 236 Online Firewalls What is a firewall? A machine to protect a network from malicious external attacks Typically a machine that sits.
Protecting Memory What is there to protect in memory?
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
World Wide Web policy.
Protecting Memory What is there to protect in memory?
Web Security CS 136 Computer Security Peter Reiher December 3, 2013
Protecting Memory What is there to protect in memory?
Password Management Limit login attempts Encrypt your passwords
Web Security Computer Security Peter Reiher March 2, 2017
Outline What does the OS protect? Authentication for operating systems
SQL Injection Attacks Many web servers have backing databases
Outline What does the OS protect? Authentication for operating systems
Web Security Lots of Internet traffic is related to the web
CSC 495/583 Topics of Software Security Intro to Web Security
Web Security Advanced Network Security Peter Reiher August, 2014
Groups for This Week Golita Benoodi, Zhen Huang, Ioannis Pefkianakis
Web Security Advanced Network Security Peter Reiher August, 2014
Web Security CS 136 Computer Security Peter Reiher November 29, 2012
Web Security CS 136 Computer Security Peter Reiher March 11, 2010
Advanced Research Issues in Security: Web Security and Privacy CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Presentation transcript:

Lecture 15 Page 1 CS 136, Spring 2016 Web Security Computer Security Peter Reiher May 24, 2016

Lecture 15 Page 2 CS 136, Spring 2016 Web Security Lots of Internet traffic is related to the web Much of it is financial in nature Also lots of private information flow around web applications An obvious target for attackers

Lecture 15 Page 3 CS 136, Spring 2016 The Web Security Problem Many users interact with many servers Most parties have little other relationship Increasingly complex things are moved via the web No central authority Many developers with little security experience Many critical elements originally designed with no thought to security Sort of a microcosm of the overall security problem

Lecture 15 Page 4 CS 136, Spring 2016 Aspects of the Web Problem

Lecture 15 Page 5 CS 136, Spring 2016 Who Are We Protecting? The server From the client The client From the server The clients From each other A client’s interaction with one server From his interaction with another server Everyone From the network

Lecture 15 Page 6 CS 136, Spring 2016 What Are We Protecting? The client’s private data The server’s private data The integrity (sometimes also secrecy) of their transactions The client and server’s machines Possibly server availability –For particular clients?

Lecture 15 Page 7 CS 136, Spring 2016 Some Real Threats Buffer overflows and other compromises –Client attacks server Web based social engineering attacks –Client or server attacks client SQL injection –Client attacks server Malicious downloaded code –Server attacks client

Lecture 15 Page 8 CS 136, Spring 2016 More Threats Cross-site scripting –Clients attack each other Threats based on non-transactional nature of communication –Client attacks server Denial of service attacks –Threats on server availability (usually)

Lecture 15 Page 9 CS 136, Spring 2016 Yet More Threats Browser security –Protecting interactions from one site from those with another –One server attacks client’s interactions with another Data transport issues –The network attacks everyone else Certificates and trust issues –Varied, but mostly server attacks client

Lecture 15 Page 10 CS 136, Spring 2016 Compromise Threats Much the same as for any other network application Web server might have buffer overflow –Or other remotely usable flaw Not different in character from any other application’s problem –And similar solutions

Lecture 15 Page 11 CS 136, Spring 2016 What Makes It Worse Web servers are complex They often also run supporting code –Which is often user-visible Large, complex code base is likely to contain such flaws Nature of application demands allowing remote use

Lecture 15 Page 12 CS 136, Spring 2016 Solution Approaches Patching Use good code base Minimize code that the server executes Maybe restrict server access –When that makes sense Lots of testing and evaluation –Many tools for web server evaluation

Lecture 15 Page 13 CS 136, Spring 2016 Compromising the Browser Essentially, the browser is an operating system –You can do almost anything through a browser –It shares resources among different “processes” But it does not have most OS security features While having some of the more dangerous OS functionality –Like arbitrary extensibility –And supporting multiple simultaneous mutually untrusting processes

Lecture 15 Page 14 CS 136, Spring 2016 But My Browser Must Be OK... After all, I see the little lock icon at the bottom of the page Doesn’t that mean I’m safe? Alas, no What does that icon mean, and what is the security implication?

Lecture 15 Page 15 CS 136, Spring 2016 The Lock Icon This icon is displayed by your browser when a digital certificate checks out A web site provided a certificate attesting to its identity The certificate was properly signed by someone your browser trusts That’s all it means

Lecture 15 Page 16 CS 136, Spring 2016 What Are the Implications? All you know is that the web site is who it claims to be –Which might not be who you think it is –Maybe it’s amozon.com, not amazon.com –Would you notice the difference? Only to the extent that a trusted signer hasn’t been careless or compromised –Some have been, in the past

Lecture 15 Page 17 CS 136, Spring 2016 Another Browser Security Issue What if you’re accessing your bank account in one browser tab And a site showing silly videos of cats in another? What if one of those videos contains an attack script? Can the evil cat script steal your bank account number?

Lecture 15 Page 18 CS 136, Spring 2016 Same Origin Policy Meant to foil such attacks Built into all modern browsers –And also things like Flash Basically, pages from a single origin can access each other’s stuff Pages from a different origin cannot Particularly relevant to cookies

Lecture 15 Page 19 CS 136, Spring 2016 Web Cookies Essentially, data a web site asks your browser to store Sent back to that web site when you ask for another service from it Used to set up sessions and maintain state (e.g., authentication status) Lots of great information about your interactions with sites in the cookies

Lecture 15 Page 20 CS 136, Spring 2016 Same Origin Policy and Cookies Script from one domain cannot get the cookies from another domain –Prevents the evil cat video from sending authenticated request to empty your bank account Domain defined by DNS domain name, application protocol –Sometimes also port

Lecture 15 Page 21 CS 136, Spring 2016 SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages are built (in part) based on queries to a database –Possibly using some client input...

Lecture 15 Page 22 CS 136, Spring 2016 SQL Injection Mechanics Server plans to build a SQL query Needs some data from client to build it –E.g., client’s user name Server asks client for data Client, instead, provides a SQL fragment Server inserts it into planned query –Leading to a “somewhat different” query

Lecture 15 Page 23 CS 136, Spring 2016 An Example “select * from mysql.user where username = ‘ “. $uid. “ ‘ and password=password(‘ “. $pwd “ ‘);” Intent is that user fills in his ID and password What if he fills in something else? ‘or 1=1; -- ‘

Lecture 15 Page 24 CS 136, Spring 2016 What Happens Then? $uid has the string substituted, yielding “select * from mysql.user where username = ‘ ‘ or 1=1; -- ‘ ‘ and password=password(‘ “. $pwd “ ‘);” This evaluates to true –Since 1 does indeed equal 1 –And -- comments out rest of line If script uses truth of statement to determine valid login, attacker has logged in

Lecture 15 Page 25 CS 136, Spring 2016 Basis of SQL Injection Problem Unvalidated input Server expected plain data Got back SQL commands Didn’t recognize the difference and went ahead Resulting in arbitrary SQL query being sent to its database –With its privileges Unvalidated input

Lecture 15 Page 26 CS 136, Spring 2016 Some Example Attacks 130 million credit card numbers stolen in 2009 with SQL injection attack Used to steal 1 million Sony passwords Florida’s election site compromise by a SQL injection attack (2016) Successful SQL injections on Bit9, British Royal Navy, PBS Ruby on Rails had built-in SQL injection vulnerability in 2012

Lecture 15 Page 27 CS 136, Spring 2016 Solution Approaches Carefully examine all input Avoid using SQL in web interfaces Parameterized variables

Lecture 15 Page 28 CS 136, Spring 2016 Examining Input for SQL SQL is a well defined language Generally web input shouldn’t be SQL So look for it and filter it out Problem: proliferation of different input codings makes the problem hard Problem: some SQL control characters are widely used in real data –E.g., apostrophe in names

Lecture 15 Page 29 CS 136, Spring 2016 Avoid SQL in Web Interfaces Never build a SQL query based on user input to web interface Instead, use predefined queries that users can’t influence Typically wrapped by query-specific application code Problem: may complicate development

Lecture 15 Page 30 CS 136, Spring 2016 Use Parameterized Variables SQL allows you to set up code so variables are bound parameters Parameters of this kind aren’t interpreted as SQL Pretty much solves the problem, and is probably the best solution

Lecture 15 Page 31 CS 136, Spring 2016 Malicious Downloaded Code The web relies heavily on downloaded code –Full language and scripting language –Mostly scripts Instructions downloaded from server to client –Run by client on his machine –Using his privileges Without defense, script could do anything

Lecture 15 Page 32 CS 136, Spring 2016 Types of Downloaded Code Java –Full programming language Scripting languages –JavaScript –VB Script –ECMAScript –XSLT

Lecture 15 Page 33 CS 136, Spring 2016 Drive-By Downloads Often, user must request that something be downloaded But not always –Sometimes visiting a page or moving a cursor causes downloads These are called drive-by downloads –Since the user is screwed just by visiting the page

Lecture 15 Page 34 CS 136, Spring 2016 Solution Approaches Disable scripts in your browser Use secure scripting languages Isolation mechanisms Virus protection and blacklist approaches Parameterized variables

Lecture 15 Page 35 CS 136, Spring 2016 Disabling Scripts Browsers (or plug-ins) can disable scripts –Selectively, based on web site The bad script is thus not executed Problem: Cripples much good web functionality –So users re-enable scripting

Lecture 15 Page 36 CS 136, Spring 2016 Use Secure Scripting Languages Some scripting languages are less prone to problems than others Write your script in those Problem: secure ones aren’t popular Problem: many bad things can still be done with “secure” languages Problem: can’t force others to write their scripts in these languages

Lecture 15 Page 37 CS 136, Spring 2016 Isolation Mechanisms Architecturally arrange for all downloaded scripts to run in clean VM –Limiting the harm they can do Problem: they might be able to escape the VM Problem: what if a legitimate script needs to do something outside its VM?

Lecture 15 Page 38 CS 136, Spring 2016 Signatures and Blacklists Identify known bad scripts Develop signatures for them Put them on a blacklist and distribute it to others Before running downloaded script, automatically check blacklist Problem: same as for virus protection

Lecture 15 Page 39 CS 136, Spring 2016 Cross-Site Scripting XSS Many sites allow users to upload information –Blogs, photo sharing, Facebook, etc. –Which gets permanently stored –And displayed Attack based on uploading a script Other users inadvertently download it –And run it...

Lecture 15 Page 40 CS 136, Spring 2016 The Effect of XSS Arbitrary malicious script executes on user’s machine In context of his web browser –At best, runs with privileges of the site storing the script –Often likely to run at full user privileges

Lecture 15 Page 41 CS 136, Spring 2016 Non-Persistent XSS Embed a small script in a link pointing to a legitimate web page Following the link causes part of it to be echoed back to the user’s browser Where it gets executed as a script Never permanently stored at the server

Lecture 15 Page 42 CS 136, Spring 2016 Persistent XSS Upload of data to a web site that stores it permanently Generally in a database somewhere When other users request the associated web page, They get the bad script

Lecture 15 Page 43 CS 136, Spring 2016 Some Examples Word Press bug allowed XSS (2016) Other XSS vulnerabilities discovered on sites run by Yahoo, Symantec, PayPal, Facebook, LinkedIn, Adobe, Apple App Store, Google Gmail, Fortinet, the Scientology website, thousands of others D-Link router flaw exploitable through XSS

Lecture 15 Page 44 CS 136, Spring 2016 Why Is XSS Common? Use of scripting languages widespread –For legitimate purposes Most users leave them enabled in their browsers Sites allowing user upload are very popular Only a question of getting user to run your script

Lecture 15 Page 45 CS 136, Spring 2016 Typical Effects of XSS Attack Most commonly used to steal personal information –That is available to legit web site –User IDs, passwords, credit card numbers, etc. Such information often stored in cookies at client side

Lecture 15 Page 46 CS 136, Spring 2016 Solution Approaches Don’t allow uploading of anything Don’t allow uploading of scripts Provide some form of protection in browser

Lecture 15 Page 47 CS 136, Spring 2016 Disallowing Data Uploading Does your web site really need to allow users to upload stuff? Even if it does, must you show it to other users? If not, just don’t take any user input Problem: Not possible for many important web sites

Lecture 15 Page 48 CS 136, Spring 2016 Don’t Allow Script Uploading A no-brainer for most sites –Few web sites want users to upload scripts, after all So validate user input to detect and remove scripts Problem: Rich forms of data encoding make it hard to detect all scripts Good tools can make it easier

Lecture 15 Page 49 CS 136, Spring 2016 Protect the User’s Web Browser Similar solutions as for any form of protecting from malicious scripts With the same problems: –Best solutions cripple functionality Firefox Content Security Policy –Allows web sites to specify where content can be loaded from

Lecture 15 Page 50 CS 136, Spring 2016 Cross-Site Request Forgery CSRF Works the other way around An authenticated and trusted user attacks a web server –Usually someone posing as that user Generally to fool server that the trusted user made a request

Lecture 15 Page 51 CS 136, Spring 2016 CSRF in Action Attacker puts link to (say) a bank on his web page Unsuspecting user clicks on the link His authentication cookie goes with the HTTP request –Since it’s for the proper domain Bank authenticates him and transfers his funds to the attacker

Lecture 15 Page 52 CS 136, Spring 2016 Issues for CSRF Attacks Not always possible or easy Attacks sites that don’t check referrer header –Indicating that request came from another web page Attacked site must allow use of web page to allow something useful (e.g., bank withdrawal) Must not require secrets from user Victim must click link on attacker’s web site And attacker doesn’t see responses

Lecture 15 Page 53 CS 136, Spring 2016 CSRF In the Wild CSRF possibility in Verizon Mobile App API eBay CSRF problem in Magneto e- commerce system A CSRF-based pharming toolkit that attacked wireless routers discovered CSRF problem in Arris cable modems

Lecture 15 Page 54 CS 136, Spring 2016 Exploiting Statelessness HTTP is designed to be stateless But many useful web interactions are stateful Various tricks used to achieve statefulness –Usually requiring programmers to provide the state –Often trying to minimize work for the server

Lecture 15 Page 55 CS 136, Spring 2016 A Simple Example Web sites are set up as graphs of links You start at some predefined point –A top level page, e.g. And you traverse links to get to other pages But HTTP doesn’t “keep track” of where you’ve been –Each request is simply the name of a link

Lecture 15 Page 56 CS 136, Spring 2016 Why Is That a Problem? What if there are unlinked pages on the server? Should a user be able to reach those merely by naming them? Is that what the site designers intended?

Lecture 15 Page 57 CS 136, Spring 2016 A Concrete Example The ApplyYourself system Used by colleges to handle student applications For example, by Harvard Business School in 2005 Once all admissions decisions made, results available to students

Lecture 15 Page 58 CS 136, Spring 2016 What Went Wrong? Pages representing results were created as decisions were made Stored on the web server –But not linked to anything, since results not yet released Some appliers figured out how to craft URLs to access their pages –Finding out early if they were admitted

Lecture 15 Page 59 CS 136, Spring 2016 The Core Problem No protocol memory of what came before So no protocol way to determine that response matches request Could be built into the application that handles requests But frequently isn’t –Or is wrong

Lecture 15 Page 60 CS 136, Spring 2016 Solution Approaches Get better programmers –Or better programming tools Back end system that maintains and compares state Front end program that observes requests and responses –Producing state as a result Cookie-based –Store state in cookies (preferably encrypted)

Lecture 15 Page 61 CS 136, Spring 2016 Data Transport Issues The web is inherently a network application Thus, all issues of network security are relevant And all typical network security solutions are applicable Where do we see problems?

Lecture 15 Page 62 CS 136, Spring 2016 (Non-) Use of Data Encryption Much web traffic is not encrypted –Or signed As a result, it can be sniffed Allowing eavesdropping, MITM attacks, alteration of data in transit, etc. Why isn’t it encrypted?

Lecture 15 Page 63 CS 136, Spring 2016 Why Web Sites Don’t Use Encryption Primarily for cost reasons Crypto costs cycles For high-volume sites, not encrypting messages lets them buy fewer servers They are making a cost/benefit analysis decision And maybe it’s right?

Lecture 15 Page 64 CS 136, Spring 2016 Problems With Not Using Encryption Sensitive data can pass in the clear –Passwords, credit card numbers, SSNs, etc. Attackers can get information from messages to allow injection attacks Attackers can readily profile traffic –Especially on non-secured wireless networks

Lecture 15 Page 65 CS 136, Spring 2016 Firesheep Many wireless networks aren’t encrypted Many web services don’t use end-to-end encryption for entire sessions Firesheep was a demo of the dangers of those in combination Simple Firefox plug-in to scan unprotected wireless nets for unencrypted cookies –Allowing session hijacking attacks When run in that environment, tended to be highly successful

Lecture 15 Page 66 CS 136, Spring 2016 Why Does Session Hijacking Work? Web sites try to avoid computation costs of encryption So they only encrypt login Subsequent HTTP messages “authenticated” with a cookie Anyone who has the cookie can authenticate The cookie is sent in the clear... So attacker can “become” legit user

Lecture 15 Page 67 CS 136, Spring 2016 Using Encryption on the Web Some web sites support use of HTTPS –Which permits encryption of data –Based on TLS/SSL Performs authentication and two-way encryption of traffic –Authentication is certificate-based HSTS (HTTP Strict Transport Security) requires browsers to use HTTPS

Lecture 15 Page 68 CS 136, Spring 2016 Increased Use of Web Encryption These and other problems have led more major web sites to encrypt traffic E.g., Google announced in 2014 it would encrypt all search requests Facebook, Twitter adopted HSTS in 2014 –Overall, only 5% of web sites have adopted it as of 2016, though Arguably, all web interactions should be encrypted

Lecture 15 Page 69 CS 136, Spring 2016 Sometimes Encryption Isn’t Enough Especially powerful “attackers” can subvert this process –Man-in-the-middle attacks by ISPs –NSA compromised key management –NSA also spied on supposedly private links Usually impossible for typical criminal Hard or impossible for a user to know if this is going on

Lecture 15 Page 70 CS 136, Spring 2016 Conclusion Web security problems not inherently different than general software security But generality, power, ubiquity of the web make them especially important Like many other security problems, constrained by legacy issues