Srikar Nadipally. Outline Finding and Exploiting XSS Vulnerabilities Standard Reflected XSS Stored XSS DOM based XSS Prevention of XSS attack Reflect.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Nick Feamster CS 6262 Spring 2009
Cross Site Scripting (XSS)
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.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
The Web Warrior Guide to Web Design Technologies
Common Exploits Aaron Cure Cypress Data Defense. SQL Injection.
1 Project 2: Web App Security Collin Jackson CS 155 Spring 2007.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
EECS 354 Network Security Cross Site Scripting (XSS)
Automating Bespoke Attack Ruei-Jiun Chapter 13. Outline Uses of bespoke automation ◦ Enumerating identifiers ◦ Harvesting data ◦ Web application fuzzing.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Workshop 3 Web Application Security Li Weichao March
4.1 JavaScript Introduction
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Prevent Cross-Site Scripting (XSS) attack
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
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.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
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.
JSP Java Server Pages Softsmith Infotech.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Cross Site Scripting (XSS) Chaitanya Lakshmi
Chapter 8 Cookies And Security JavaScript, Third Edition.
Chapter 2. Core Defense Mechanisms. Fundamental security problem All user input is untrusted.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Cross-Site Attacks James Walden Northern Kentucky University.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
What Is XSS ? ! Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to.
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.
S ECURE P ROGRAMMING NOTES 08 XSS 1. Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the trusted.
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.
Google’s Gruyere1 : An XSS Example Presented by: Terry Gregory
CSCE 548 Student Presentation Ryan Labrador
An Introduction to Web Application Security
Unit 4 Representing Web Data: XML
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Auditing Etsy The Security of Etsy
CSC 495/583 Topics of Software Security Intro to Web Security
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Exploring DOM-Based Cross Site Attacks
Cross-Site Scripting Attack (XSS)
Cross Site Request Forgery (CSRF)
Presentation transcript:

Srikar Nadipally

Outline Finding and Exploiting XSS Vulnerabilities Standard Reflected XSS Stored XSS DOM based XSS Prevention of XSS attack Reflect Stored DOM

Standard Use standard proof of concept “> alert(document.cookie)

Detecting Reflected XSS Systematic approach of finding reflected attack Find all the entry points of the user input Submit a benign alphabetical string in each entry point Identify all the locations where the string is reflected in the applications response For each reflection identify the syntactic context in which string appears Submit modified data tailored to the reflection syntactic context, attempting to introduce the arbitrary script in to response. If reflected data is blocked, try to understand and circumvent the application defensive filter

Example 1 Tag attribute value Return page contains the code Ways to craft XSS exploit “> alert(1) “ onfoucus=“alert(1)

Example 2 Java Script String If return page code is var a=‘myxsstest’; var b =123; Ways to craft XSS exploit ‘; alert(1); var foo=‘

Example 3 Atrribute Containing URL Returned page code Click here… Ways to craft XSS exploit o javascript:alert(1) o #”onclick=“javascript:alert(1)

Stored XSS Stored XSS vulnerability identification is quite similar to that of reflected XSS – submitting a unique string in every entry point within the application. Once you identify every instance in which user controllable data is stored by the application and later displayed back to the browser, same process is followed as that of reflected XSS – determining what input to be submitted to embed valid JavaScript within the surrounding HTML and then besiege the filters that intervene with your attack payload process.

Techniques to test for stored XSS Testing for XSS in Web Mail applications Send all kinds of unusual HTML content within s to test for bypasses in input filters. Restricting to standard client will not give you enough control over the raw message content or the client may itself sanitize or clean up your malformed syntax. Using UNIX sendmail command a raw can be created in a text editor and send it. Sendmail –t <

Example Raw file MIME-Version: 1.0 From: Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: XSS test

Techniques to Detect stored XSS Testing for XSS in Uploaded Files Hybrid File attacks – “hybrid files” - two different formats Example: GIFAR (GIF + JAR) Uploaded file attack using GIFAR The attack using GIFAR files can be prevented in current versions of Java browser plug-in by validating whether JAR files being loaded actually content hybrid content.

Detecting DOM - based XSS Manually walk through the application with your browser and modify each URL parameter to contain a standard test string. “ alert(1) “;alert(1)// ‘-alert(1)-’ Displaying each returned page in the browser causes all client side scripts to execute referencing the modified URL parameter. If you see a dialog box containing cookies, you will have found a vulnerability.

Detecting DOM-based XSS Effective approach: Review all client-side JavaScript for any use of DOM properties that may lead to a vulnerability. DOM-tracer is a tool that helps you to automate this process

Preventing XSS attacks Due to the different root causes different defense mechanisms needs to be applied for reflected and stored XSS on one hand and DOM-based on the other. Reflected and Stored XSS Identify every instance within the application where user-controllable data is being copied into responses including data that is copied from immediate request and also any stored data that is originated from any user at any prior time, including via out-of-band channels. After identification, follow a threefold approach to prevent any actual vulnerabilities from arising.

…Continued Threefold approach- Validate input Validate output (Encode the output) Eliminate dangerous insertion points Validate input: The application should perform context- dependent validation of data when application receives user-supplied data that may copy into one of its responses at any future point. Potential features to validate – data is not too long, contains only a certain permitted character set, matches a particular regular expression. Different Validation rules should also be applied – names, id’s, account numbers etc.

…Continued Validate Output Data should be HTML-encoded to sanitize potentially malicious characters. HTML encoding involves replacing literal characters with their corresponding HTML entities. HTML encodings of the primary problematic characters are as follows – “ — " ‘ — &apos; & — & < — < > — >

…Continued Eliminate dangerous insertion points Inserting user-controllable data directly into existing script code should be avoided wherever possible. This applies to the code within tags, and also code within event handlers. Allowing limited HTML

…Continued Preventing DOM-based XSS Application should avoid using client-side scripts to process DOM data and insert it into the page. DOM-based XSS flaws can be prevented through two types of defenses- Validate input Validate output Validate input: Attack can be prevented by validating the data about to be inserted into the document containing only alphanumeric characters and white space.

…Continued Example: var a = document.URL; a = a.substring(a.indexOf(“message=”) + 8, a.length); a = unescape(a); var regex=/^([A-Za-z0-9+\s])*$/; if (regex.test(a)) document.write(a);

…Continued Server-side validation can also be employed to detect requests that may contain malicious exploits by verifying the following: The query string contains a single parameter. The parameter’s name is message (case-sensitive check). The parameter’s value contains only alphanumeric content

…Continued Validate output: Applications can perform HTML encoding of user- controllable DOM data before it is inserted into the document. HTML encoding can be implemented in client-side Javascript with a function like the following: function sanitize(str) { var d = document.createElement(‘div’); d.appendChild(document.createTextNode(str)); return d.innerHTML; }

Request forgery Also known as “Session riding” is related to session hijacking attacks, in which an attacker captures a user’s session token and thereby uses that application as that user. Request Forgery vulnerabilities comes in two flavors: On-site Request Forgery (OSRF) Cross-Site Request Forgery (CSRF)

OSRF Attack for exploiting stored XSS vulnerabilities. OSRF vulnerabilities can exist even in situations where XSS is not possible. Consider a message board application that lets users submit items that are viewed by other users. Messages are submitted using a request like the following: POST /submit.php Host: wahh-app.com Content-Length: 34 type=question&name=daf&message=foo

…Continued This request results in the following being added to the messages page: daf foo

CSRF Attacker creates the innocuous-looking website causes the user’s browser to submit a request directly to the vulnerable application to perform some unintended action that is beneficial to the attacker. CSRF attacks are “one-way” only. Consider an application in which administrators can create new user accounts using requests like the following: POST /auth/390/NewUserStep2.ashx HTTP/1.1 Host: mdsec.net Cookie: SessionId=8299BE6B260193DA076383A2385B07B9 Content-Type: application/x-www-form-urlencoded Content-Length: 83 realname=daf&username=daf&userrole=admin&password=letmein1& confirmpassword=letmein1

…Continued This request has three key features that make it vulnerable to CSRF attacks: The request performs a privileged action. In the example shown, the request creates a new user with administrative privileges. The application relies solely on HTTP cookies for tracking sessions. No session-related tokens are transmitted elsewhere within the request. The attacker can determine all the parameters required to perform the action. Aside from the session token in the cookie, no unpredictable values need to be included in the request

…Continued Attacker can construct a web page that makes a cross-domain request to the vulnerable application containing everything needed to perform the privileged action. Example of such attack: <form action=” method=”POST”> document.forms[0].submit();

Questions