CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

Similar documents
CNIT 129S: Securing Web Applications. Ch 10: Attacking Back-End Components

Content Security Policy

Portcullis Computer Security.

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

NET 311 INFORMATION SECURITY

Application vulnerabilities and defences

Project 3 Web Security Part 1. Outline

Web basics: HTTP cookies

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

Web basics: HTTP cookies

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

Common Websites Security Issues. Ziv Perry

Abusing Windows Opener to Bypass CSRF Protection (Never Relay On Client Side)

Web Security, Part 2

Web Security: XSS; Sessions

CIS 4360 Secure Computer Systems XSS

Acknowledgments... xix

CSCE 813 Internet Security Case Study II: XSS

High -Tech Bridge s Web Server Security Service API Developer Documentation Version v1.3 February 13 th 2018

BOOSTING THE SECURITY OF YOUR ANGULAR 2 APPLICATION

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

Some Facts Web 2.0/Ajax Security

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

Web Application Security

Web Security IV: Cross-Site Attacks

Avoiding Web Application Flaws In Embedded Devices. Jake Edge LWN.net URL for slides:

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

5/19/2015. Objectives. JavaScript, Sixth Edition. Saving State Information with Query Strings. Understanding State Information

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

CSC 405 Computer Security. Web Security

Client Side Injection on Web Applications

Finding Vulnerabilities in Web Applications

Manipulating Web Application Interfaces a New Approach to Input Validation Testing. AppSec DC Nov 13, The OWASP Foundation

Web Security: Vulnerabilities & Attacks

Web Security: Vulnerabilities & Attacks

WEB APPLICATION PENETRATION TESTING EXTREME VERSION 1

CS 161 Computer Security

Title: Multiple Remote Command Execution vulnerabilities on Avaya Intuity Audix LX (plus some client-side bugs)

CS 161 Computer Security

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

BEGINNER PHP Table of Contents

Web Security. Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

Unusual Web Bugs. A Web App Hacker s Bag O Tricks. Alex kuza55 K.

Beijing , China. Keywords: Web system, XSS vulnerability, Filtering mechanisms, Vulnerability scanning.

Advanced Web Technology 10) XSS, CSRF and SQL Injection

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

WHY CSRF WORKS. Implicit authentication by Web browsers

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

CS 142 Winter Session Management. Dan Boneh

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

Preparing for the Cross Site Request Forgery Defense

HTTP Security Headers Explained

Webapps Vulnerability Report

Pemrograman Jaringan Web Client Access PTIIK

CS 155 Project 2. Overview & Part A

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

Ruby on Rails Secure Coding Recommendations

A Balanced Introduction to Computer Science, 3/E

CNIT 129S: Securing Web Applications. Ch 8: Attacking Access Controls

How to Use Adhoc Parameters in Actuate Reports

Lecture Overview. IN5290 Ethical Hacking

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

Secure Programming. Input Validation. Learning objectives Code Injection: Outline. 4 Code Injection

This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in

Code-Injection Attacks in Browsers Supporting Policies. Elias Athanasopoulos, Vasilis Pappas, and Evangelos P. Markatos FORTH-ICS

ATTACKING SYSTEM & WEB Desmond Alexander CISSP / GIAC/ GPEN CEO FORESEC

CS 161 Computer Security

Don't Trust The Locals: Exploiting Persistent Client-Side Cross-Site Scripting in the Wild

Web Security, Summer Term 2012

Web Security, Summer Term 2012

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

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

DEFENSIVE PROGRAMMING. Lecture for EDA 263 Magnus Almgren Department of Computer Science and Engineering Chalmers University of Technology

WEB SECURITY: XSS & CSRF

Master Syndication Gateway V2. User's Manual. Copyright Bontrager Connection LLC

Types of XSS attacks. Persistent XSS. Non-persistent XSS

CNIT 127: Exploit Development. Ch 18: Source Code Auditing. Updated

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

GOING WHERE NO WAFS HAVE GONE BEFORE


CGS 3066: Spring 2015 JavaScript Reference

C1: Define Security Requirements

Assignment 6: Web Security

Automated SQL Ownage Techniques. OWASP October 30 th, The OWASP Foundation

The security of Mozilla Firefox s Extensions. Kristjan Krips

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

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

A SURVEY OF ATTACKS ON PHP AND WEB VULNERABILITIES

CSP ODDITIES. Michele Spagnuolo Lukas Weichselbaum

Security in a Mainframe Emulator. Chaining Security Vulnerabilities Until Disaster Strikes (twice) Author Tim Thurlings & Meiyer Goren

JOE WIPING OUT CSRF

Attack Pattern: Target Programs That Write to Privileged OS Resources

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

MWR InfoSecurity Advisory. 26 th April Elastic Path Administrative. Quit. Session Hijacking through Embedded XSS

CSE 127 Computer Security

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

Client Side Security And Testing Tools

I n p u t. This time. Security. Software. sanitization ); drop table slides. Continuing with. Getting insane with. New attacks and countermeasures:

CSCD 303 Essential Computer Security Fall 2018

Transcription:

CNIT 129S: Securing Web Applications Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

Finding and Exploiting XSS Vunerabilities

Basic Approach Inject this string into every parameter on every page of the application If the attack string appears unmodified in the response, that indicates an XSS vulnerability This is the fastest way to find an XSS, but it won't find them all

When the Simple Attack Fails Applications with rudimentary blacklist-based filters Remove <script>, or < > " / Crafted attacks may still work

Response Different from Input XSS attacks that don't simply return the attack string Sometimes input string is sanitized, decoded, or otherwise modified In DOM-based XSS, the input string isn't necessarily returned in the browser's immediate response, but is retained in the DOM and accessed via client-side JavaScript

Finding and Exploiting Reflected XSS Vulnerabilities

Identifying Reflections of User Input Choose a unique string that doesn't appear anyhere in the application and includes only alphabetical characters that won't be filtered, like "myxsstestdmqlwp" Submit it as every parameter, one at a time, including GET, POST, query string, and headers such as User-Agent Monitor responses for any appearance of the string

Testing Reflections to Introduce Script Manually test each instance of reflected input to see if it's exploitable You'll have to customize the attack for each situation

1. A Tag Attribute Value Here are two ways to exploit it

Demos (Use Firefox)

2. A JavaScript String This attack works

3. An Attribute Containing a URL Use the javascript: handler to make your script into a URL Or use the onclick event handler

Probing Defensive Filters Three common types

Beating Signature-Based Filters You may see an error message like this

Remove Parts of the String Until the error goes away Find the substring that triggered the error, usually something like <script> Test bypass methods

Ways to Introduce Script Code

Script Tags If <script> is blocked, try these

Event Handlers All these run without user interaction

Event Handlers in HTML 5 Autofocus In closing tags New tags

Script Pseudo-Protocols Used where a URL is expected IE allows the vbs: protocol HTML 5 provides these new ways:

Dynamically Evaluated Styles IE 7 and earlier allowed this: Later IE versions allow this:

Bypassing Filters: HTML Ways to obfuscate this attack

Inserted NULL Butes Causes C code to terminate the string Will bypass many filters IE allows NULL bytes anywhere Web App Firewalls (WAFs) are typically coded in C for performance and this trick fools them

Invalid Tags Browser will let it run Filter may not see it due to invalid tag "x"

Base Tag Hijacking Set <base> and later relative-path URLs will be resolved relative to it

Space Following the Tag Name Replace the space with other characters Add extra characters when there's no space

NULL Byte in Attribute Name Attribute delimiters Backtick works in IE

Attribute Delimiters If filter is unaware that backticks work as attribute delimiters, it treats this as a single attribute Attack with no spaces

Attribute Values Insert NULL, or HTML-encode characters

HTML Encoding Can use decimal and hexadecimal format, add leading zeroes, omit trailing semicolon Some browsers will accept these

Tag Brackets Some applications perform URL decoding twice, so this input becomes this, which has no < or > and it's then decoded to this

Tag Brackets Some app frameworks translate unusual Unicode characters into their nearest ASCII equivalents, so double-angle quotation marks %u00ab and %u00bb work:

Tag Brackets Browsers tolerate extra brackets This strange format is accepted by Firefox, despite not having a valid <script> tag

Web Developer Add-on View Generated Source shows HTML after Firefox has tried to "fix" the code

Character Sets

Telling Browser the Character Set Set it in the HTTP Content-Type header Or an HTTP META tag Or a CHARSET parameter, if one is used

Shift-JIS Suppose two pieces of input are used in the app's response input1 blocks quotes, input2 blocks < and > This attack works, because %f0 starts a two-byte character, breaking the quotation mark

Bypassing Filters: Script Code

JavaScript Escaping Unicode Eval Superfluous escape characters

Dynamically Constructing Strings Third example works in Firefox And in other browsers too, according to link Ch 12f

Alternatives Alternatives to eval Alternatives to dots

Combining Multiple Techniques The "e" in "alert" uses Unicode escaping: \u0065 The backslash is URL-encoded: \ With more HTML-encoding

VBScript Skip this section Microsoft abandoned VBScript with Edge Link Ch 12g

Beating Sanitization Encoding certain characters < becomes < > becomes > Test to see what characters are sanitized Try to make an attack string without those characters

Examples Your injection may already be in a script, so you don't need <script> tag Sneak in <script> using layers of encoding, null bytes, nonstandard syntax, or obfuscates scrip code

Mistakes in Sanitizing Code Not removing all instances Not acting recursively

Stages of Encoding Filter first strips <script> recursively Then strips <object> recursively This attack succeeds

Injecting into an Event Handler You control foo This attack string Turns into this, and executes in some browsers

Beating Length Limits 1. Short Attacks This sends cookies to server with hostname a This tag executes a script from the server with hostname a

JavaScript Packer Link Ch 12h

Beating Length Limits 2. Span Multiple Locations Use multiple injection points Inject part of the code in each point Consider this URL

Beating Length Limits 2. Span Multiple Locations It returns three hidden fields Inject this way

Beating Length Limits 2. Span Multiple Locations Result

Beating Length Limits 3. Convert Reflected XSS to DOM Inject this JavaScript, which evaluates the fragment string from the URL The part after #

Beating Length Limits 3. Convert Reflected XSS to DOM First attack works in a straightforward manner Second one works because http: is interpreted as a code label, // as a comment, and %0A terminates the comment