August 1, 2006. The Software Security Problem August 1, 2006.

Slides:



Advertisements
Similar presentations
Module XIV SQL Injection
Advertisements

Webgoat.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
Principles of Computer Security: CompTIA Security + ® and Beyond, Third Edition © 2012 Principles of Computer Security: CompTIA Security+ ® and Beyond,
Understand Database Security Concepts
Web Application Security Vulnerabilities Yen-Cheng Chen Department of Information Management National Chi Nan University Puli, 545 Nantou, Taiwan
August 1, 2006 XP Security. August 1, 2006 Comparing XP and Security Goals XP GOALS User stories No BDUF Refactoring Continuous integration Simplicity.
August 1, 2006 Software Security. August 1, 2006 Essential Facts Software Security != Security Features –Cryptography will not make you secure. –Application.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Information Networking Security and Assurance Lab National Chung Cheng University 1 Top Vulnerabilities in Web Applications (I) Unvalidated Input:  Information.
Dec 13 th CS555 presentation1 Yiwen Wang --“Securing the DB may be the single biggest action an organization can take to protect its assets” David C. Knox.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
The 10 Most Critical Web Application Security Vulnerabilities
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Web Application Security
OWASP Zed Attack Proxy Project Lead
Security.NET Chapter 1. How Do Attacks Occur? Stages of attack Examples of attacker actions 1. FootprintRuns a port scan on the firewall 2. PenetrationExploits.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
The OWASP Way Understanding the OWASP Vision and the Top Ten.
Hamdi Yesilyurt, MA Student in MSDF & PhD-Public Affaris SQL Riji Jacob MS Student in Computer Science.
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.
March 4, 2008 ISACA Web Application Security James Walden Northern Kentucky University
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
May 2, 2007St. Cloud State University Software Security.
Software Security Testing Vinay Srinivasan cell:
OSI and TCP/IP Models And Some Vulnerabilities AfNOG th May 2011 – 10 th June 2011 Tanzania By Marcus K. G. Adomey.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
WWW 安全 國立暨南國際大學 資訊管理學系 陳彥錚. WWW 安全 Web security is important for E-Commerce. Previous studies: –SSL –SET –Web server security Application-level security.
1 Cover Your Applications: Top 5 Things You Can Do Nov 8, 2006 Ambarish Malpani CTO/VP Eng Cenzic, Inc.
APPLICATION PENETRATION TESTING Author: Herbert H. Thompson Presentation by: Nancy Cohen.
Injection CSC 482/582: Computer SecuritySlide #1.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
SQL Injection Jason Dunn. SQL Overview Structured Query Language For use with Databases Purpose is to retrieve information Main Statements Select Insert.
nd Joint Workshop between Security Research Labs in JAPAN and KOREA Marking Scheme for Semantic- aware Web Application Security HPC.
Web Applications Testing By Jamie Rougvie Supported by.
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.
DAT356 Hackers Paradise SQL Injection Attacks Doug Seven, Microsoft MVP Cofounder of SqlJunkies.com
June 14, 2007 Web Application Security Workshop James Walden.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 9 1COMP9321, 15s2, Week.
CS526Topic 12: Web Security (2)1 Information Security CS 526 Topic 9 Web Security Part 2.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
OWASP Building Secure Web Applications And the OWASP top 10 vulnerabilities.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Defending Applications Against Command Insertion Attacks Penn State Web Conference 2003 Arthur C. Jones June 18, 2003.
SQL Injection Attacks An overview by Sameer Siddiqui.
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.
Cosc 5/4765 Database security. Database Databases have moved from internal use only to externally accessible. –Organizations store vast quantities of.
Building Secure ColdFusion Applications
Web Application Vulnerabilities
CSC 482/582: Computer Security
Brad Glisson and Ray Welland Department of Computing Science
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
TOPIC: Web Security (Part-4)
SQL Injection.
Secure Software Confidentiality Integrity Data Security Authentication
Marking Scheme for Semantic-aware Web Application Security
James Walden Northern Kentucky University
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
Presentation transcript:

August 1, 2006

The Software Security Problem

August 1, 2006

Traditional Security is Reactive Perimeter defense (firewalls) Intrusion detection Over-reliance on cryptography Penetrate and patch Penetration testing

August 1, 2006 The Problem is Software “75 percent of hacks happen at the application.” Theresa Lanowitz, Gartner Inc.

August 1, 2006 Hackers “Malicious hackers don’t create security holes; they simply exploit them. Security holes and vulnerabilities – the real root cause of the problem – are the result of bad software design and implementation.” John Viega & Gary McGraw

August 1, 2006 Developers Aren’t Ready “64% of developers are not confident in their ability to write secure applications” Bill Gates, RSA 2005

August 1, 2006 A Growing Problem

August 1, 2006 Penetrate and Patch Discover flaws after deployment. Often by attackers. Users may not deploy patches. Patches may have security flaws (15%?) Patches are maps to vulnerabilities. Attackers reverse engineer to create attacks.

August 1, 2006 Vulnerabilities and Threats Vulnerability: A bug or flaw in a system that makes an attack possible. Threat: A party with the capability and intention to exploit a vulnerability.

August 1, 2006 OWASP Top 10 Vulnerabilities 1. Unvalidated InputUnvalidated Input –Information from web requests is not validated before being used by a web application. Attackers can use these flaws to attack backend components through a web application. 2. Broken Access ControlBroken Access Control –Restrictions on what authenticated users are allowed to do are not properly enforced. Attackers can exploit these flaws to access other users' accounts, view sensitive files, or use unauthorized functions.

August 1, 2006 OWASP Top 10 Vulnerabilities 3. Broken Authentication and Session ManagementBroken Authentication and Session Management –Account credentials and session tokens are not properly protected. Attackers that can compromise passwords, keys, session cookies, or other tokens can defeat authentication restrictions and assume other users' identities. 4. Cross Site ScriptingCross Site Scripting –The web application can be used as a mechanism to transport an attack to an end user's browser. A successful attack can disclose the end user’s session token, attack the local machine, or spoof content to fool the user.

August 1, 2006 OWASP Top 10 Vulnerabilities 5. Buffer OverflowBuffer Overflow –Web application components in some languages that do not properly validate input can be crashed and, in some cases, used to take control of a process. These components can include CGI, libraries, drivers, and web application server components. 6. Injection FlawsInjection Flaws –Web applications pass parameters when they access external systems or the local operating system. If an attacker can embed malicious commands in these parameters, the external system may execute those commands on behalf of the web application.

August 1, 2006 OWASP Top 10 Vulnerabilities 7. Improper Error HandlingImproper Error Handling –Error conditions that occur during normal operation are not handled properly. If an attacker can cause errors to occur that the web application does not handle, they can gain detailed system information, deny service, cause security mechanisms to fail, or crash the server. 8. Insecure StorageInsecure Storage –Web applications frequently use cryptographic functions to protect information and credentials. These functions and the code to integrate them have proven difficult to code properly, frequently resulting in weak protection.

August 1, 2006 OWASP Top 10 Vulnerabilities 9. Application Denial of ServiceApplication Denial of Service –Attackers can consume web application resources to a point where other legitimate users can no longer access or use the application. Attackers can also lock users out of their accounts or even cause the entire application to fail. 10. Insecure Configuration ManagementInsecure Configuration Management –Having a strong server configuration standard is critical to a secure web application. These servers have many configuration options that affect security and are not secure out of the box.

August 1, 2006

SQL Injection use DBI; $dbh = DBI->connect($conn, $dbusername, $dbpassword) or die “Database connection failed.\n”; $sql = “SELECT count(*) from users where username = ‘$username’ and password = ‘$password’”; $sth = $dbh->prepare($sql) or die “Prepare failed.\n”; $sth->execute() or die “Execute failed.\n”; What if user gives SQL code as name or password?

August 1, 2006 SQL Metacharacters ‘ quotes parameters ; separates commands -- comments %, _ glob in LIKE clause %, _, *, +, |, [], () used for regular expressions in SIMILAR TO clause

August 1, 2006 SQL Injection Attack #1 Unauthorized Access Attempt: –password = ’ or 1=1 -- SQL statement becomes: –select count(*) from users where username = ‘user’ and password = ‘’ or 1=1 -- –Checks if password is empty OR 1=1, which is always true, permitting access.

August 1, 2006 SQL Injection Attack #2 Database Modification Attack: –password = foo’; delete from table users where username like ‘% Database executes two SQL statements: –select count(*) from users where username = ‘user’ and password = ‘foo’ –delete from table users where username like ‘%’

August 1, 2006 Beyond the Database ODBC allows shell injection via “|” –‘|shell(“cmd /c echo “ & chr(124) & “format c:”)|’ MS SQL Server Extended Stored Procs –Shell: exec master..xp_cmdshell ‘format c:’ –Create new DB accounts: xp_grantlogin –Read any file: bulk insert foo from “c:\d.txt”

August 1, 2006 The Problem: String Building Building a SQL command string with user input in any language is dangerous. –Variable interpolation. –String concatentation with variables. –String format functions like sprintf(). –String templating with variable replacement.

August 1, 2006 Bad Solution #1: Blacklist Attempted solution: Blacklist SQL metacharacters, especially single quotes. Problems: 1.Numeric parameters don’t use quotes. 2.Database-escaped quotes: \’ 3.URL escaped metacharacters. 4.Unicode encoded metacharacters. 5.Did you miss any metacharacters? 6.2 nd Order SQL Injection.

August 1, 2006 Numeric Parameters Solution: Escape single quotes Problem #1: What if you use stored user data? –Q: select count(*) from users where uid=$uid –User enters uid = 1 or 1=1 –Query becomes: select count(*) from users where uid=1 or 1=1 Once again, this query is always true.

August 1, nd Order SQL Injection Solution: Escape single quotes Problem #2: What if you use stored user data? –User creates account with user = root’-- –Application escapes and inserts as root’’-- –User resets password. –Your query fetches username from DB to verify account exists with correct old password. –update users set password=‘pass’ where username = ‘root’--’

August 1, 2006 Bad Solution #2: Stored Procedures SQL Stored Procedures build strings too: CREATE PROCEDURE nchar(128) AS nchar(256) = ‘SELECT cc FROM cust WHERE id=‘’’ + ‘’’’ RETURN

August 1, 2006 Solution: Prepared Queries use DBI; $dbh = DBI->connect(conn(), $db_username, $db_password) or die “Database connection failed.\n”; $sql = “SELECT count(*) from users where username = ? and password = ?”; $sth = $dbh->prepare($sql) or die “Prepare failed.\n”; $sth->bind_param(1, $username); $sth->bind_param(2, $password); $sth->execute() or die “Execute failed.\n”;

August 1, 2006 Additional Precautions 1.Don’t access the DB as a privileged user. 2.Don’t allow access to DB from Internet. 3.Don’t embed DB passwords in your code. 4.Don’t leak information in error messages.

August 1, 2006 Going Further Reading –OWASP Top 10 Project –OWASP Guide –Hacking Web Applications Exposed, 2/e Software –WebGoat (OWASP) –Hacme Bank (Foundstone) –MasterBugs

August 1, 2006 References 1.Stephen J. Friedl, “SQL Injection Attacks by Example,” Gary McGraw, Software Security, Addison-Wesley, Michael Howard, David LeBlanc, and John Viega, 19 Deadly Sins of Software Security, McGraw-Hill Osborne, Michael Howard, David LeBlanc, Writing Secure Code, 2 nd edition, Microsoft Press, Michael Howard and Steve Lipner, The Security Development Lifecycle, Microsoft Press, OWASP, The OWASP Top 10 Project, OWASP, The OWASP Guide to Building Secure Web Applications, Joel Scambray, Mike Shema, and Caleb Sima, Hacking Web Applications Exposed, 2 nd edition, Addison-Wesley, SK, “SQL Injection Walkthrough,” John Viega and Gary McGraw, Building Secure Software, Addison-Wesley, 2002.