CSCI 6962: Server-side Design and Programming Secure Web Programming.

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.
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.
Introduction The concept of “SQL Injection”
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
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.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
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.
Injection Attacks by Example SQL Injection and XSS Adam Forsythe Thomas Hollingsworth.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Preventing SQL Injection ~example of SQL injection $user = $_POST[‘user’]; $pass = $_POST[‘pass’]; $query = DELETE FROM Users WHERE user = ‘$user’ AND.
Secure Software Engineering: Input Vulnerabilities
Workshop 3 Web Application Security Li Weichao March
PHP Security.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
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.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
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
© 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.
Sofia, Bulgaria | 9-10 October Writing Secure Code for ASP.NET Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen Forte CTO,
Feedback #2 (under assignments) Lecture Code:
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.
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.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
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.
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.
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.
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University
WEB SECURITY WEEK 2 Computer Security Group University of Texas at Dallas.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
EECS 354: Network Security Group Members: Patrick Wong Eric Chan Shira Schneidman Web Attacks Project: Detecting XSS and SQL Injection Vulnerabilities.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Error-based SQL Injection
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,
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.
CSE509 System Security Attacks against the server-side of web applications Nick Nikiforakis
Module: Software Engineering of Web Applications
Building Secure ColdFusion Applications
Introduction to Dynamic Web Programming
SQL Injection.
SQL Injection Attacks Many web servers have backing databases
Computer Security Fundamentals
CSE 154 Lecture 26: web security.
PHP: Security issues FdSc Module 109 Server side scripting and
CSC 495/583 Topics of Software Security Intro to Web Security
Lecture 2 - SQL Injection
Lecture 27 Security I April 4, 2018 Open news web sites.
Presentation transcript:

CSCI 6962: Server-side Design and Programming Secure Web Programming

Web server most vulnerable resource in organization – Must be accessible to anyone – Users can enter anything into text elements – Users can modify query string to send any value – Users can bypass any client-side security Goal: prevent malicious users from sending “dangerous” values – Attacks on your data – Attacks on other users who visit your site

SQL Injection Form inputs contain values used in database query Hacker enters values that modify SQL used in query – Access unauthorized privileges – Modify database in destructive ways – Access operating system…

SQL Injection Methods Comments: Anything after -- is ignored Quotes: Can confuse SQL parser about where strings start and end Example: – Normal login query of form SELECT * FROM users WHERE id=‘homer’ AND password=‘donut’ Fields passed from form elements on web page

SQL Injection Methods Attack: Comment out password check Enter admin’-- for username Query now of form SELECT * FROM users WHERE id=‘admin’--' AND password=‘’ Query succeeds if database contains user named admin – If admin has administrative privileges, now control database! Commented out!

SQL Injection Methods Disjunction with inherently true statement – … OR 1=1 always true – Can use to get all records Example: – Don’t know administrator account called admin – Do know administrator account often first in database

SQL Injection Methods Query now resolves to SELECT * FROM users WHERE id=‘’ OR 1=1--' AND password=‘’ Query matches all users in database Database probably uses first record matched – Probably administrator Commented out! Always true!

SQL Injection Methods Can use ; to end query and insert commands Some database servers even allow direct access to operating system – xp_cmdshell, xp_regwrite, …

Preventing SQL Injection Hard/unreliable way: Filter out all “dangerous” string values before use in SQL query Problem: Many such characters often part of legitimate input and should be accepted – O’Reilly – Smith-Jones… Difficult to create more complex rules for filtering without missing cases – Hackers always looking for new ways to exploit

Preventing SQL Injection Best/simpler way: Use prepared statements Prepared Statement p = connection.prepareStatement( “SELECT * FROM users WHERE id=? AND password=?”) p.setString(1, request.getParamter(“id”)); Form of query set in advance based on this Value of this treated as string rather than command

Session Hijacking Sessions commonly used for access control so user only has to log in once during session Usual structure: – User successfully logs in  value in bean set to true hasLoggedIn = true; – Any subsequent page request checks this value Redirects to login page if not true if (!hasLoggedIn) return “login.xhtml”

Session Hijacking Problem: Assumes SessionID can be uniquely associated with person who actually logged in! Attack: Server Bob’s SessionID: abc123 Bob’s browser Bob’s SessionID: abc123 Attacker Page request with SessionID = abc123 Server has no way of knowing request does not come from Bob!

Preventing Session Hijacking Server side: Make session identifiers difficult to guess – Random numbers – Very long Limit time attackers have to find session ID – Session timeout – Logout button destroys session Mostly built into modern web containers

Preventing Session Hijacking Client side: Same origin policy in browsers Cookies only accessible by same site that set them – Domain of web site is property of each cookie in browser Otherwise malicious web site could steal session ID set by other sites Bob’s browser ValueDomain jsessionid=2093hffpqe32Widgets.com jsessionid=oirtg04hnwre4gtrAmazon.com jsessionid=ifnvp9rnpa234rf4ysu.edu

Cross-site Scripting (XSS) Inserting malicious JavaScript onto trusted web site – User visits trusted site and goes to page containing malicious JavaScript – Malicious JavaScript downloaded to and run on user browser Server Bob’s browser Trusted.html Evil.js

Cross-site Scripting Can happen on any page where user can post text – User comments – Product reviews – Discussion pages (MySpace was first major victim) –…–…

Cross-site scripting Attacker can insert reference to JavaScript file on another site – Symbols such as, :, “, etc. escaped – Any browser that loads this comment downloads and executes JavaScript from that site

XSS and Session Hijacking Key idea: JavaScript downloaded from trusted site Has access to any cookies set by trusted site under same origin policy – JavaScript has commands for manipulating cookies Can be used for session hijacking

Attacker site XSS and Session Hijacking Bob’s browser Cookies: Evil.js Trusted site ValueDomain jsessionid=2093hffpqe32Trusted.com Evil.js

Preventing Cross-site Scripting Use html encoding to convert potentially executable symbols into non-executable symbols – All characters have numbers in html – Can force browser to render character instead of executing it by using &#number instead of actual character – Example: To display < in html must use &#60

Preventing Cross-site Scripting Safest to encode all characters posted by user – Not just those obviously dangerous (, etc.) Most web languages have tools for doing this – Server.HTMLEncode in ASP.NET – <h:outputLabel automatically converts all characters output (unless escape=false attribute added)