Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
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.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Common Exploits Aaron Cure Cypress Data Defense. SQL Injection.
-Ajay Babu.D y5cs022.. Contents Who is hacker? History of hacking Types of hacking Do You Know? What do hackers do? - Some Examples on Web application.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
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
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
OWASP Zed Attack Proxy Project Lead
* ASP.NET Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking ASP.NET MVC Telerik Software Academy
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Software Quality Assurance QA Engineering, Testing, Bug Tracking, Test Automation Software University Technical Trainers SoftUni Team.
Prevent Cross-Site Scripting (XSS) attack
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
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.
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
AngularJS Services Built-in and Custom Services SoftUni Team Technical Trainers Software University
JavaScript, Fourth Edition
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
PHP Basics Course Introduction SoftUni Team Technical Trainers Software University
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.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
School of Computing and Information Systems CS 371 Web Application Programming Security Avoiding and Preventing Attacks.
Svetlin Nakov Technical Trainer Software University
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.
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
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.
Building Secure Web Applications With ASP.Net MVC.
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.
Trainers Team Ivan Yonkov Rated in the top 7% at Stack Overflow
Asynchronous Web Services Writing Asynchronous Web Services SoftUni Team Technical Trainers Software University
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking ASP.NET MVC SoftUni Team Technical Trainers Software University.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 9 1COMP9321, 15s2, Week.
Forms Overview, Query string, Submitting arrays, PHP & HTML, Input types, Redirecting the user Mario Peshev Technical Trainer Software.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Working with Forms in PHP HTTP GET / POST, Validation, Escaping, Input Types, Submitting Arrays, URL Redirecting, PHP Superglobals Svetlin Nakov Technical.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
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.
PHP Basics Course Introduction Svetlin Nakov Technical Trainer Software University
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,
Software Technologies Course Overview SoftUni Team Technical Trainers Software University
Doctrine The PHP ORM SoftUni Team Technical Trainers Software University
Web Storage and Cookies Cookies, Local and Session Storage SoftUni Team Technical Trainers Software University
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
Building Secure ColdFusion Applications
An Introduction to Web Application Security
Introduction to MVC SoftUni Team Introduction to MVC
State Management Cookies, Sessions SoftUni Team State Management
World Wide Web policy.
CS 371 Web Application Programming
JavaScript: ExpressJS Overview
PHP: Security issues FdSc Module 109 Server side scripting and
Riding Someone Else’s Wave with CSRF
CSC 495/583 Topics of Software Security Intro to Web Security
Lecture 2 - SQL Injection
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
Presentation transcript:

Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University

Table of Contents 1.Web Security Main Concepts 2.SQL Injection 3.Cross-Site Scripting (XSS) 4.Cross-Site Request Forgery (CSRF/XSRF) 5.Parameter Tempering 6.Session Hijacking 7.DoS/DDoS Attacks 2

Web Security Main Concepts

4  Is Software Security a Feature?  Most people consider software security as a necessary feature of a product  Is Security Vulnerability a Bug?  If the software "failed" and allowed a hacker to see personal info, most users would consider that a software bug Feature or Bug

Reasons for Failures  Software failures usually happen spontaneously  Without intentional mischief  Failures can be result of malicious attacks  For the Challenge/Prestige  Curiosity driven  Aiming to use resources  Vandalizing  Stealing 5

6  Maximum Simplicity  More complicated – greater chance for mistakes  Secure the Weakest Link  Hackers attack where the weakest link is  Limit the Publicly Available Resources  Incorrect Until Proven Correct  Consider each user input as incorrect  The Principle of the "Weakest Privilege"  Security in Errors (Remain stable)  Provide Constant Defense (also use backups) Golden Rules!

SQL Injection What is SQL Injection and How to Prevent It?

8  Try the following queries:  '  crashes  ' or ''='  Login with any user  '; INSERT INTO Messages(MessageText, MessageDate) VALUES ('Hacked!!!', ' ')--  injects a message What is SQL Injection? $loginQuery = "SELECT * FROM users WHERE username='{$_POST['user']}' AND WHERE username='{$_POST['user']}' AND password='{$_POST['pass']}'"; password='{$_POST['pass']}'"; $result = mysql_query($loginQuery);

9  The following SQL commands are executed:  Usual search (no SQL injection):  SQL-injected search (matches all records):  SQL-injected INSERT command: How Does SQL Injection Work? SELECT * FROM Messages WHERE MessageText LIKE '%nakov%'" SELECT * FROM Messages WHERE MessageText LIKE '%%'" SELECT * FROM Messages WHERE MessageText LIKE '%'; INSERT INTO Messages(MessageText, MessageDate) VALUES ('Hacked!!!', ' ') --%'" SELECT * FROM Messages WHERE MessageText LIKE '%' or 1=1 --%'"

10  Original SQL Query:  Setting username to John & password to ' OR '1'= '1 produces  Result: If a user Admin exists – he is logged in without password Another SQL Injection Example String sqlQuery = SELECT * FROM user WHERE name = 'Admin' AND pass='' OR '1'='1' String sqlQuery = "SELECT * FROM user WHERE name = '" + username + "' AND pass='" + password + "'"

11  Ways to prevent the SQL injection:  SQL-escape all data coming from the user:  Not recommended: use as last resort only!  Preferred approach:  Use ORM  Use parameterized queries Preventing SQL Injection

SQL Injection and Prevention Live Demo

Cross Site Scripting (XSS) What is XSS and How to Prevent It? …

14  Cross-Site Scripting ( XSS ) is a common security vulnerability in Web applications  Web application is let to display a JavaScript code that is executed at the client's browser  Crackers could take control over sessions, cookies, passwords, and other private data  How to prevent from XSS?  Validate the user input (built-in in ASP.NET)  Perform HTML escaping when displaying text data in a Web control XSS Attack

XSS  Cross-site scripting attack  Cookie theft  Account hijacking  Modify content  Modify user settings  Download malware  Submit CRSF attack  Password prompt 15 Submits script on an unsafe form Execute the script on visiting the page

16  HTML escaping is the act of replacing special characters with their HTML entities  Escaped characters are interpreted as character data instead of mark up  Typical characters to escape  – start / end of HTML tag  & – start of character entity reference  ', " – text in single / double quotes  … What is HTML Escaping?

17  Each character could be presented as HTML entity escaping sequence  Numeric character references:  ' λ ' is λ, &#x03BB ; or &#X03bb ;  Named HTML entities:  ' λ ' is λ  ' < ' is <  ' > ' is >  ' & ' is &  " (double quote) is " HTML Character Escaping

18  HTML encodes a string and returns the encoded (html-safe) string Example (in PHP): HTML Output: Web browser renders the following: How to Encode HTML Entities? echo htmlentities("The image tag: "); The image tag: <img> The image tag: The image tag: echo htmlspecialchars("The image tag: ");

HTML Escaping Live Demo

Cross-Site Request Forgery What is CSRF and How to Prevent It?

21  Cross-Site Request Forgery (CSRF / XSRF) is a web security attack over the HTTP protocol  Allows executing unauthorized commands on behalf of some authenticated user  E.g. to transfer some money in a bank system  The user has valid permissions to execute the requested command  The attacker uses these permissions to send a forged HTTP request unbeknownst to the user  Through a link / site / web form that the user is allured to open What is CSRF?

22  How does CSRF work? 1. The user has a valid authentication cookie for the site victim.org (remembered in the browser) 2. The attacker asks the user to visit some evil site, e.g The evil site sends HTTP GET / POST to victim.org and does something evil  Through a JavaScript AJAX request  Using the browser's authentication cookie 4. The victim.org performs the unauthorized command on behalf of the authenticated user CSRF Explained

23  Cross-site request forgery attack CSRF Evil.com MySite.com User Login Authentication cookie Submit data on behalf of User

Cross-Site Request Forgery Live Demo

25  To prevent CSRF attacks in PHP apps use random generated tokens  Put hidden field with random generated token in the HTML forms:  Verify anti-CSRF token in each controller action that should be protected: Prevent CSRF in PHP </form> if (!isset($_POST['formToken']) || $_POST['formToken'] != $_SESSION['formToken']) { throw new Exception('Invalid request!'); throw new Exception('Invalid request!'); exit; } exit; } $_SESSION['formToken'] = uniqid(mt_rand(), true);

Anti-CSRF in MVC Apps Live Demo

Parameter Tampering What is Parameter Tampering and How to Prevent It?

What is Parameter Tampering?  What is Parameter Tampering?  Malicious user alters the HTTP request parameters in unexpected way  Altered query string (in GET requests)  Altered request body (form fields in POST requests)  Altered cookies (e.g. authentication cookie)  Skipped data validation at the client-side  Injected parameter in MVC apps 28

Parameter Tampering Live Demo

Session Hijacking

1.Capture a valid token session using a sniffer 2.Use the valid session token to gain unauthorized access to the server  Always use SSL when sending sensitive data!  You should use Man in the Middle attack to sniff the session token Session Hijacking

DoS (DDoS) Attacks What is Denial-of-Service attack? 32

33  Semantic URL attacks  URL Manipulation  Man in the Middle (MiTM)  Brute force (use CAPTCHA!)  Insufficient Access Control  Error messages can reveal information  Phishing  Security flows in other software you are using  Social Engineering Other Threats

? ? ? ? ? ? ? ? ? Web Security

License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" licenseCreative Commons Attribution- NonCommercial-ShareAlike 4.0 International 35

Free Software University  Software University Foundation – softuni.orgsoftuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg softuni.bg  Software Facebook  facebook.com/SoftwareUniversity facebook.com/SoftwareUniversity  Software YouTube  youtube.com/SoftwareUniversity youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bgforum.softuni.bg