Basic Web Application Security. User Input Kick Your Arse.

Slides:



Advertisements
Similar presentations
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Advertisements

Web Security Never, ever, trust user inputs Supankar.
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.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
PHP syntax basics. Personal Home Page This is a Hypertext processor It works on the server side It demands a Web-server to be installed.
COMP 321 Week 12. Overview Web Application Security  Authentication  Authorization  Confidentiality Cross-Site Scripting Lab 12-1 Introduction.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
IDAsec copyright - all rights reserved1 Web Vulnerabilities in the real world.
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.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Security & VanillaCMS An XSS Introduction and Attack Demonstration.
Lecture 16 Page 1 CS 236 Online Cross-Site Scripting XSS Many sites allow users to upload information –Blogs, photo sharing, Facebook, etc. –Which gets.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
 A cookie is a piece of text that a Web server can store on a user's hard disk.  Cookie data is simply name-value pairs stored on your hard disk by.
Computer Concepts 2014 Chapter 7 The Web and .
Secure Software Engineering: Input Vulnerabilities
PHP Security.
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Prevent Cross-Site Scripting (XSS) attack
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Server-side Scripting Powering the webs favourite services.
Introduction to InfoSec – Recitation 7 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
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.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
©2008 Gotham Digital Science Secure Parameter Filter (SPF) (AKA Protecting Vulnerable Applications with IIS7) Justin Clarke, Andrew Carey Nairn.
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.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Feedback #2 (under assignments) Lecture Code:
Host and Application Security Lesson 19: How the Web Works.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
Cross-Site Attacks James Walden Northern Kentucky University.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
Foundations of Network and Computer Security J J ohn Black CSCI 6268/TLEN 5550, Spring 2013.
PHP2010/11 : [‹#›] PHP Security. PHP2010/11 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
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.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
Cloud = Web, Web = Hacked! Fabio Viggiani. Why Web Apps? Every organization exposes web apps Most common entry point Image source:
Web Application Vulnerabilities ECE 4112 Internetwork Security, Spring 2005 Chris Kelly Chris Lewis April 28, 2005 ECE 4112 Internetwork Security, Spring.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Trevor Jim Nikhil Swamy Michael Hicks Defeating Script Injection Attacks with Browser-Enforced Embedded Policies Jason FroehlichSeptember 24, 2008.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
National College of Science & Information Technology.
UKUUG Linux 2008 Introduction to Web Application Security Flaws Jake Edge LWN.net URL for slides:
Javascript worms By Benjamin Mossé SecPro
Introduction to Information Security
Web Systems & Technologies
Building Secure ColdFusion Applications
SQL Injection Attacks Many web servers have backing databases
Cross-Site Forgery
CISC103 Web Development Basics: Web site:
Chapter 27 WWW and HTTP.
CSC 495/583 Topics of Software Security Intro to Web Security
Presentation transcript:

Basic Web Application Security

User Input

Kick Your Arse

Three Ways (All Awesome)

Validation

Passive (No touchy-touchy)

This is a Number. 2

This is not a Number. a

This is really not a Number. alert(‘loldongs’)

Filtering

Destructive (One-Way Street)

Only letting the good stuff in.

or

Keeping out the bad stuff.

What’s the diff? (Bro.)

Both can be error- prone...

White-Listing  Usability Problems What happens when you screw it up? Black-Listing  Security Problems (Always a trade-off.)

Escaping

Transport Point A  Point B

Data will be the same on both sides.

Different Media, Different Escaping

HTML Huh. <b>Huh.</b> Huh

SQL Sam O’Brien INSERT INTO mah_peeps (name) VALUES (‘Sam O\’Brien‘); 1, Sam O’Brien, :30:00

XSS (Cross-Site Scripting)

(XTREME Site Scripting) SS

Sticking Scripts Where They Don’t Belong. You there, down the back. Stop sniggering.

alert(‘HACKED BY LOLDONGS’) Amateurs!

alert(document.cookie) Hmm.

document.write(‘ ’); Oh shit.

Why is this uncool? (Yeah! Why?)

document.write(‘ ’); Ooooh shit.

document.write(‘ ’); Oooooooooooh shit.

document.write(‘ ’); Oooooooooooooooooh shit.

Why is this really uncool? (Because shut up.)

HTTP Hyper-Text Thingy I-forgot-again

Stateless

No Idea Who You Are.

It can guess. (Badly.) IP Address Browser User-Agent

Sends a cookie with each request. (A basket of goodies that the browser sends faithfully every request.)

The Server puts a unique ID in the basket. PHPSESSID=123your456mum78 9 __utma= is_a_furry=1

Browser sends the ID every request. PHPSESSID=123your456mum78 9

document.write(‘ ’); Look again.

THEY HAVE YOUR COOKIE. Ooooooooooooooooooooooo-

Preventing Shenanigans

HTML Validation  Really Hard.

HTML Filtering  Still Really Hard. Use a library, eg. HTML Purifier.

HTML Escaping  Dead Easy. Most languages have stuff to handle this, eg. htmlentities(), cgi.escape(), CGI.escape()

How hard is filtering? (It’s just, right?)

THIS HARD. alert('a') ”> <IMG SRC=javascr ipt:aler t('XSS')> <IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72 &#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72 &#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29> (Well, then.) alert('a') alert("a");// RIPT>alert('a'); RIPT> <img src=”javascript:alert('a')”

THIS HARD. <iframe src= < BODY{-moz- binding:url(" (Well, then.) žscriptualert(EXSSE)ž/scriptu (US-ASCII encoding evasion) <META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64, PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">

THIS HARD. <DIV STYLE="background- image:\0075\0072\006C\0028'\006a \0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061 \006c\0065\0072\0074\ \ \0053\0027\0029' exp/* alert('a'); (Well, then.).x{background- image:url("javascript:alert('a')");} <EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzd....j wvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"> ]]>

One more thing about XSS. (Groan.)

Remember alert() ? (Yes, I do. Shut up.)

alert() can be ANY JAVASCRIPT. (Yes, and...?)

Do you have any forms on your page? (Yes.)

Do you have any javascript functions your site uses to do anything useful? (... Yes.)

Do your site make any AJAX calls to do anything useful? (... Oh.)

That injected code can trigger forms, run javascript functions, or make AJAX calls. (... Oooooh.)

Send someone to a link that looks like: doStuff(); (... Oooooooooh.)

Or store something that will output this on someone’s profile page: doStuff(); (... Oooooooooooooooh.)

... And you’re hosed. (Shit.)

The Human Element Touchy-Feely Commie Bullshit.

We are very fallible.

We will forget things.

When time gets short, we take the easy path.

Design systems so that they naturally encourage security.

SQL Insert(“INSERT INTO posts VALUES (‘”.sql_safe($title).”’, ‘“.sql_safe($content).”’, ‘”.sql_safe($author).”’)”);

SQL or

SQL insert(“INSERT INTO posts VALUES (:title, :content, :author)”, $title, $content, $author);

HTML - Written by

HTML or

HTML - Written by

Questions?

Now get out.