Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

LIS651 lecture 3 taming PHP Thomas Krichel
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.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
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.
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.
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 SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Web-based Document Management System By Group 3 Xinyi Dong Matthew Downs Joshua Ferguson Sriram Gopinath Sayan Kole.
PHP Security.
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
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.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
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
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.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Feedback #2 (under assignments) Lecture Code:
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
PHP Workshop ‹#› PHP Security. PHP Workshop ‹#› Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER 2.ESCAPE.
PHP2010/11 : [‹#›] PHP Security. PHP2010/11 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
SEC835 Runtime authentication Secure session management Secure use of cryptomaterials.
Ram Santhanam Application Level Attacks - Session Hijacking & Defences
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.
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.
SecurityPHPApril 2010 : [‹#›] PHP Security. SecurityPHPApril 2010 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less.
Web Applications Testing By Jamie Rougvie Supported by.
Web Database Programming Week 7 Session Management & Authentication.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Web Application Vulnerabilities ECE 4112 Internetwork Security, Spring 2005 Chris Kelly Chris Lewis April 28, 2005 ECE 4112 Internetwork Security, Spring.
Chapter 16 The World Wide Web. FIGURE 16.0.F01: A very, very simple Web page. Courtesy of Dr. Richard Smith.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 9 1COMP9321, 15s2, Week.
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.
CSRF Attacks Daniel Chen 11/18/15. What is CSRF?  Cross Site Request Forgery (Sea-Surf)  AKA XSRF/ One Click / Sidejacking / Session Riding  Exploits.
Session Management Tyler Moore CS7403 University of Tulsa Slides adapted in part or whole from Dan Boneh, Stanford CS155 1.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
10 Tips for Building a Secure PHP Application. Tip 1: Use Proper Error Reporting/Handling  The development process of the application can become very.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Introduction SQL Injection is a very old security attack. It first came into existence in the early 1990's ex: ”Hackers” movie hero does SQL Injection.
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
COMP9321 Web Application Engineering Semester 2, 2017
Module: Software Engineering of Web Applications
Building Secure ColdFusion Applications
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
World Wide Web policy.
SQL Injection Attacks Many web servers have backing databases
Cross-Site Forgery
Web Systems Development (CSC-215)
PHP: Security issues FdSc Module 109 Server side scripting and
Web Systems Development (CSC-215)
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
Web Programming Language
Lecture 27 Security I April 4, 2018 Open news web sites.
Cross Site Request Forgery (CSRF)
Presentation transcript:

Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1

Types of Vulnerability In web applications, there are 5 categories of vulnerabilities : 1.SQL Injection 2.Cross-site Scripting (XXS) 3.Cross-Site Request Forgeries (XSRF) 4.Session fixation 5.Session hijacking 2

SQL Injection Consider the following query: SELECT fieldlist FROM table WHERE field = '$ ' What if $ contains: anything' OR 'x' = 'x 3

Protect against SQL Injection Protect against SQL injection in two ways: 1) Use the language's quote-removal mechanism: for PHP and MySQL, use mysql_real_escape_string() 2) Use prepared statements: Replaces variables with placeholders e.g. WHERE field = ? When values get bound to placeholders, they are guaranteed to be treated as data, not as part of the query 4

Most common use of database Is to store a list of usernames, passwords, and associated user information Basic technique: get username and password from a form Consider: transmitted in clear! Hash the password using md5 or sha1 Check database for username and hashed password match If match is exactly one row, set session variable to let user in 5

Refinements to Authentication Use a “salt”. This is a string that only you know, that you add to passwords before hashing Choose a unique session ID and set your session to be valid Store error codes for failed logins in a session variable, and tell users on the login page that they failed Regenerate the session ID cookie any time a user changes status with session_regenerate_id For serious security, only authenticate over HTTPS 6

Cross-site Scripting (XXS) In simple terms: this is when a Web application allows unintended HTML, JavaScript, or CSS to run on a client's machine Simple example: a comments form that allows un-escaped HTML/JavaScript, coupled with a display page that treats comments as plain HTML Least bad thing that can happen: malicious user puts in a URL to an inappropriate image Other things: user adds JavaScript that redirects other users to a completely different site Or, user adds inline CSS that makes your page vanish 7

Cross-site Scripting Implications More subtly, suppose a malicious user has an account on the same site as you And is able to create a JavaScript injection JavaScript can use XMLHttpRequest to POST back details (to the origin server) JavaScript has access to your cookies Attacker now has your cookie, and can impersonate you on the site Cross-site scripting is like a \gateway drug" - it leads to bigger things like XSRF and session hijacking. 8

Cross-site Request Forgery (XSRF) The situation: suppose you are logged in to Site A An attacker tricks you into clicking on this link in Site B (or in your ): The image trick requires a GET, but you can do this with POST if there is a JavaScript XSS vulnerability on Site A Solution: generate a token with your forms and require the form-submitter to present it on the URL 9

XSRF Mitigation <?php $token = md5(uniqid(rand(), TRUE)); $_SESSION['token'] = $token; $_SESSION['token_time'] = time(); ?> <input type="hidden" name="token" value=" "> 10

Session Fixation Attacker uses a link or a redirect to send them from their site to a site you belong to At the end of the link, or in the header, is a PHPSESSID of their choice You log in; they know your session ID (they fixed it) Solution: regenerate the session ID after any change in privilege level for your users (session_regenerate_id()) 11

Session Hijacking Attacker goes to the trouble of getting a valid PHPSESSID (perhaps after you have regenerated it or using a packet snifer) Attacker then impersonates your valid user One solution: generate random tokens and put onto the URL using output_add_rewrite_var() require token to match as well Best solution: remain in HTTPS 12