Software Security CS461/ECE422 Spring 2012. Reading Material Chapter 12 of the text.

Slides:



Advertisements
Similar presentations
Webgoat.
Advertisements

Closing the Gap: Analyzing the Limitations of Web Application Vulnerability Scanners David Shelly Randy Marchany Joseph Tront Virginia Polytechnic Institute.
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 11 – Buffer Overflow.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
Principles of Computer Security: CompTIA Security + ® and Beyond, Third Edition © 2012 Principles of Computer Security: CompTIA Security+ ® and Beyond,
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.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
Building Secure Software Chapter 9 Race Conditions.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 11: Software Security.
Guide To UNIX Using Linux Third Edition
Computer Security and Penetration Testing
Lecture 17 Software Security
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
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
CS252: Systems Programming Ninghui Li Final Exam Review.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
INTRODUCTION TO WEB DATABASE PROGRAMMING
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Security.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
+ 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.
Ladd Van Tol Senior Software Engineer Security on the Web Part One - Vulnerabilities.
A Security Review Process for Existing Software Applications
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 12 – Software Security.
Computer Security and Penetration Testing
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
OSI and TCP/IP Models And Some Vulnerabilities AfNOG th May 2011 – 10 th June 2011 Tanzania By Marcus K. G. Adomey.
Attacking Applications: SQL Injection & Buffer Overflows.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
School of Computing and Information Systems CS 371 Web Application Programming Security Avoiding and Preventing Attacks.
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.
Chapter 11 Software Security Many vulnerabilities result from poor programming practices Consequence from insufficient checking and validation of data.
Eng. Hector M Lugo-Cordero, MS February 2012 Software Security CIS 4361.
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.
CIS 450 – Network Security Chapter 14 – Specific Exploits for UNIX.
PwC New Technologies New Risks. PricewaterhouseCoopers Technology and Security Evolution Mainframe Technology –Single host –Limited Trusted users Security.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
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.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
ASP.NET 2.0 Security Alex Mackman CM Group Ltd
Chapter 11 Software Security. Many vulnerabilities result from poor programming practices Consequence from insufficient checking and validation of data.
Chapter 11 Software Security 1. Many vulnerabilities result from poor programming practices Consequence from insufficient checking and validation of data.
Secure Programming Dr. X
Web Application Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Chapter 7: Identifying Advanced Attacks
Secure Programming Dr. X
CS 371 Web Application Programming
A Security Review Process for Existing Software Applications
Secure Software Development: Theory and Practice
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
PHP: Security issues FdSc Module 109 Server side scripting and
Software Security Lesson Introduction
CS5123 Software Validation and Quality Assurance
Software Security Slide Set #10 Textbook Chapter 11 Clicker Questions
Presentation transcript:

Software Security CS461/ECE422 Spring 2012

Reading Material Chapter 12 of the text

Outline Review common vulnerabilities in programs Input Checking Program Logic Errors Errors Interacting with the OS Output handling

Software Vulnerabilities Generally a result of poor programming practices. OWASP top 10 Web Application Security risks – SP_Top_Ten_Project SP_Top_Ten_Project – A good number are developer bugs

Security in Design and Architecture Security concerns must be considered up front Security impacts system architecture – Perhaps re-architect to ameliorate security concerns – Security architecture can be used to drive testing – True even for projects with no “security features” Leaving security to the test phase (or later) is not a good idea to say the least

Defensive Programming or Secure Coding Mostly good software engineering – Except when considering security must consider a malicious actor – Traditional software engineering concentrates dealing with errors due to accidents Goal – Continued functioning of software in spite of unforeseeable usage of said software. Conflicts with time to market

Make No Assumptions! Don’t assume the user won’t enter more than 512 characters on the command line Don’t that there will always be enough disk space OR codify and enforce your assumptions

Handling User Input This is where the user (malicious or innocent) can directly impact the program – Always verify the user input – White list expected results Input can come from a number of places – Text entry – Configuration files – Environment variables – Network

Injection Attacks Error in input handling that results in unexpected execution flow Often occurs in scripting languages – Script writer expects user input to be data – But user inputs text that will be interpreted as code

Unsafe Perl Script

Running Script With user = lpb Finger user Login Name lpbLawrie Brown With user=‘xxx; echo attack success; ls finger*’ Finger User attack success finger.cgifinger.html Command injection. Running arbitrary commands at the privilege of the web user id.

Safer Script counter attack by validating input – compare to pattern that rejects invalid input – see example additions to script:

SQL Injection Or why is this XKCD comic funny –

SQL Injection another widely exploited injection attack when input used in SQL query to database – similar to command injection – SQL meta-characters are the concern – must check and validate input for these

Code Injection further variant input includes code that is then executed – see PHP remote code injection vulnerability variable + global field variables + remote include – this type of attack is widely exploited

04/10/0716 Cross Site Scripting (XSS) Goal – Inject malicious code into web pages viewed by others.  Sites that allow HTML formatted user input to be stored, e.g. Blog comments, wiki entries.  Enter the following into a form that then shows the original query in the response. confirm("Do you hate purple dinosaurs?");

XSS Example cf. guestbooks, wikis, blogs etc where comment includes script code – e.g. to collect cookie details of viewing users need to validate data supplied – including handling various possible encodings attacks both input and output handling

Alternate Encodings

Input Checks Example of evading input checks – Samy’s explanation of his Myspace worm – Canonicalize input before performing checks – Map the multiple versions of ‘A’ to a particular value Issue for numeric values too – Is the number 16 bits or 32? – Signed or unsigned? Negative number or large positive

Input Fuzzing Generate “random” inputs to test programs – Environment variables – Input strings – Network values Could be completely randomized or somewhat structured – Minifuzz – ShareFuzz – Spike – MuDynamics Standard component of Microsoft’s Software Development Lifecycle

More Fuzz - SPIKE An input language for creating variant network packets From WireShark output, make it easy to express new packets – a_binary(“ ”) Data: – a_block_size_big-endian_word(“Blockname”); Data: – a_block_start(“Blockname”) a_binary(“ ”) Data: – a_block_end(“Blockname”); Data:

Writing Correct/Safe Code Is your algorithm correct? – Incorrect use of random number generators Bad seeds E.g. Code Red and Netscape TCP session hijacking – How random is the sequence number? Leaving in test code – Used by Morris Worm

Is there a bug in the compiler? Ken Thompson Trojan compiler example Required for higher levels of Common Criteria – Correspondence of design, source, and object code.

Correct Use of Memory Memory Leak – Run process out of memory. DoS Free/Allocation errors – Heap overflow, can enable arbitrary execution Could be solved by – Heap randomization – Tools to track heap utilization Valgrind Duma

Race Conditions and Shared Memory Multiple threads of control accessing a common memory location – Subtle (and not so subtle) errors in synchronization are possible – Multiple writers – Writing while another thread is reading – Deadlocks Errors vary from invocation to invocation Attacker could attempt to trigger a latent threading error

Environment Variables Another way for the program to get input – And should be treated as such Generally set up for the user – Sysadmin creates a profile for the user that initializes the environment Environment variables read by compiled programs and scripted program

Example Vulnerable Scripts using PATH or IFS environment variables cause script to execute attackers program with privileges granted to script – SetUID root scripts would be attractive almost impossible to prevent in some form – Though the use of IFS has been restricted in most modern shells

Path Attack On Libraries Dynamic libraries are loaded at invocation time Loader must search the system to find the libraries needed by the executable – LD_LIBRARY_PATH – Flexibility vs attack avenue

Least Privilege Ideally run a program with as many privileges and access rights as it needs but no more – What’s the hard in too much access? Root in Unix Web servers and file access – What files does the web server process need to read? Need to write? How long does a program need special privilege? – E.g., a low port network service program Divide program into sets of processes – Move the privilege required elements into smaller, simpler processes

System Calls and Standard Library Functions programs use system calls and standard library functions for common operations – and make assumptions about their operation – if incorrect behavior is not what is expected may be a result of system optimizing access to shared resources by buffering, re-sequencing, modifying requests – can conflict with program goals

Secure File Shredder

Race Conditions Files can be used to synchronize access to OS resources between processes If [ ! –e $file ] then touch $file else echo “You don’t have the lock” fi Time of check to time of use (TOCTOU)

Temporary Files Many programs create temporary intermediate files – Can create unique names based on process id – How could an attacker leverage this? do { filename = tempnam(NULL, “foo”); fd = open(filename, ….) free(filename); } while (fd == -1);

Output Checking Example 1 – Active display VT100 command characters Or X-terminal display hijack Example 2 – Cross Site Scripting Generate display from stored data Data is interpreted as command

Summary Useful to look at common software vulnerabilities – Know common issues to avoid going forward Even more important to consider security in the design architecture – More likely to catch/avoid problems if you think from the security perspective up front – Someone will be thinking from the security perspective eventually