CAP6135: Malware and Software Vulnerability Analysis Find Software Bugs Cliff Zou Spring 2011.

Slides:



Advertisements
Similar presentations
Finding bugs: Analysis Techniques & Tools Symbolic Execution & Constraint Solving CS161 Computer Security Cho, Chia Yuan.
Advertisements

TaintScope: A Checksum-Aware Directed Fuzzing Tool for Automatic Software Vulnerability Detection Tielei Wang 1, Tao Wei 1, Guofei Gu 2, Wei Zou 1 1 Peking.
By Skyler Onken.  Who am I?  What is Fuzzing?  Usual Targets  Techniques  Results  Limitations  Why Fuzz?  “Fuzzing the Web”?  Desired Solution.
Abhinn Kothari, 2009CS10172 Parth Jaiswal 2009CS10205 Group: 3 Supervisor : Huzur Saran.
1 Topic 1 – Lesson 3 Network Attacks Summary. 2 Questions ► Compare passive attacks and active attacks ► How do packet sniffers work? How to mitigate?
Introduction to InfoSec – Recitation 6 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
System Security Scanning and Discovery Chapter 14.
Fuzzing Dan Fleck CS 469: Security Engineering Sources:
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 and Penetration Testing
(semi)Automatic Methods for Security Bug Detection Tal Garfinkel Stanford/VMware.
Methods For The Prevention, Detection And Removal Of Software Security Vulnerabilities Jay-Evan J. Tevis Department of Computer Science and Software Engineering.
Leveraging User Interactions for In-Depth Testing of Web Application Sean McAllister Secure System Lab, Technical University Vienna, Austria Engin Kirda.
Buffer Overflow Attacks. Memory plays a key part in many computer system functions. It’s a critical component to many internal operations. From mother.
The Internet & The World Wide Web Notes
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
INTRODUCTION TO WEB DATABASE PROGRAMMING
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
CS5103 Software Engineering Lecture 18 Security Issues in Software Engineering & Final Exam.
Malicious Code Brian E. Brzezicki. Malicious Code (from Chapter 13 and 11)
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
DIRAC Web User Interface A.Casajus (Universitat de Barcelona) M.Sapunov (CPPM Marseille) On behalf of the LHCb DIRAC Team.
Revolutionizing the Field of Grey-box Attack Surface Testing with Evolutionary Fuzzing Department of Computer Science & Engineering College of Engineering.
Software Testing Damian Gordon.
Exploitation: Buffer Overflow, SQL injection, Adobe files Source:
Computer Security and Penetration Testing
BLENDED ATTACKS EXPLOITS, VULNERABILITIES AND BUFFER-OVERFLOW TECHNIQUES IN COMPUTER VIRUSES By: Eric Chien and Peter Szor Presented by: Jesus Morales.
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.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 Internet Browsing Vulnerabilities and Security ECE4112 Final Lab Ye Yan Frank Park Scott Kim Neil Joshi.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
Automated Whitebox Fuzz Testing (NDSS 2008) Presented by: Edmund Warner University of Central Florida April 7, 2011 David Molnar UC Berkeley
CSCE 201 Web Browser Security Fall CSCE Farkas2 Web Evolution Web Evolution Past: Human usage – HTTP – Static Web pages (HTML) Current: Human.
COMPUTER SECURITY MIDTERM REVIEW CS161 University of California BerkeleyApril 4, 2012.
16 October Reminder Types of Testing: Purpose  Functional testing  Usability testing  Conformance testing  Performance testing  Acceptance.
TaintScope Presented by: Hector M Lugo-Cordero, MS CAP 6135 April 12, 2011.
Understanding Computer Viruses: What They Can Do, Why People Write Them and How to Defend Against Them Computer Hardware and Software Maintenance.
Overflow Examples 01/13/2012. ACKNOWLEDGEMENTS These slides where compiled from the Malware and Software Vulnerabilities class taught by Dr Cliff Zou.
EXE: Automatically Generating Inputs of Death Cristian Cadar, Vijay Ganesh, Peter M. Pawlowski, David L. Dill, Dawson R. Engler 13th ACM conference on.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 4: Planning and Configuring Routing and Switching.
Sairajiv Burugapalli. This chapter covers three main categories of classic software vulnerability: Buffer overflows Integer vulnerabilities Format string.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
Web Security Firewalls, Buffer overflows and proxy servers.
CAP6135: Malware and Software Vulnerability Analysis Find Software Bugs Cliff Zou Spring 2015.
Lecture 15 Page 1 CS 236 Online Evaluating Running Systems Evaluating system security requires knowing what’s going on Many steps are necessary for a full.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
Fuzzing And Oracles By: Thomas Sidoti. Overview Introduction Motivation Fuzzable Exploits Oracles Implementation Fuzzing Results.
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
CAP6135: Malware and Software Vulnerability Analysis Find Software Bugs Cliff Zou Spring 2016.
Fuzz Testing (Fuzzing) Eng. Hector M Lugo-Cordero, MS CIS 4361 Jan 27, 2012.
Fuzzing Machine By Nikolaj Tolkačiov.
TOPIC: Web Application Firewall & Fuzzers
Input testing SQL Injections
Introduction to Operating Systems
Configuration Fuzzing for Software Vulnerability Detection
Types for Programs and Proofs
*Acknowledgements: Dawn Song, Kostya Serebryany,
Secure Software Development: Theory and Practice
Introduction to Information Security
*Acknowledgements: Suman Jana, Dawn Song, Kostya Serebryany,
Introduction to Operating Systems
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, Thanassis.
Malware and Software Vulnerability Analysis Find Software Bugs Cliff Zou University of Central Florida.
CSC-682 Advanced Computer Security
CS5123 Software Validation and Quality Assurance
Acknowledgement This lecture is modified based on the lecture notes from: Dr. Dawn Song: CS161: computer security.
Presentation transcript:

CAP6135: Malware and Software Vulnerability Analysis Find Software Bugs Cliff Zou Spring 2011

2 Acknowledgement  This lecture is modified based on the lecture notes from:  Dr. Dawn Song: CS161: computer securityCS161: computer security

3 Review  Memory-safety vulnerabilities  Buffer overflow  Format string  Integer overflow  Runtime detection  Runtime bounds check  Purify, Jones & kelly (string bound check)  Expensive  Runtime detection of overwrite  Stackguard, etc.  Practical, but only cover certain types of attacks  Runtime mitigation to make attacks hard  Randomization  Practical, but not fool proof

4 This Class: Software Bug Finding  The iPhone story  Blackbox bug finding  Whitebox bug finding

5 IPhone Security Flaw  Jul 2007: “researchers at Independent Security Evaluators, said that they could take control of iPhones through a WiFi connection or by tricking users into going to a Web site that contains malicious code. The hack, the first reported, allowed them to tap the wealth of personal information the phones contain.”  Found by Charles Miller  Dr. Charlie Miller presented the details of the exploit at BlackHat in Las Vegas on August 2, The slides from this talk are also available.BlackHatavailable  Details see:

6 iPhone attack  iPhone Safari downloads malicious web page  Arbitrary code is run with administrative privileges  Can read SMS log, address book, call history, other data  Can perform physical actions on the phone  system sound and vibrate the phone for a second  could dial phone numbers, send text messages, or record audio (as a bugging device)  Can transmit any collected data over network to attacker

7 0days Are a Hacker Obsession  An 0day is a vulnerability that’s not publicly known  Modern 0days often combine multiple attack vectors & vulnerabilities into one exploit  Many of these are used only once on high value targets  0day statistics  Often open for months, sometimes years

8 How to Find a 0day?  Step #1: obtain information  Hardware, software information  Sometimes the hardest step  Step #2: bug finding  Manual audit  (semi)automated techniques/tools  Fuzz testing (focus of this lecture)

9 The iPhone Story  Step #1: WebKit opensource  “WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that's used by Safari, Dashboard, Mail, and many other OS X applications.”   Step #2: identify potential focus points  From development site: The JavaScriptCore Tests “If you are making changes to JavaScriptCore, there is an additional test suite you must run before landing changes. This is the Mozilla JavaScript test suite.”  So we know what they use for code testing  Use code coverage to see which portions of code is not well tested  Tools gcov, icov, etc., measure test coverage

10 Results  59.3% of lines in JavaScriptCore were covered  79.3% of main engine covered  54.7% of Perl Compatible Regular Expression (PCRE) covered  Next step: focus on PCRE  Wrote a PCRE fuzzer (20 lines of perl)  Ran it on standalone PCRE parser (pcredemo from PCRE library)  Started getting errors: PCRE compilation failed at offset 6: internal error: code overflow  Evil regular expressions crash mobileSafari

11 The Art of Fuzzing  Automatically generate test cases  Many slightly anomalous test cases are input into a target interface  Application is monitored for errors  Inputs are generally either file based (.pdf,.png,.wav,.mpg)  Or network based…  http, SNMP, SOAP

12 Trivial Example  Standard HTTP GET request  GET /index.html HTTP/1.1  Anomalous requests  AAAAAA...AAAA /index.html HTTP/1.1  GET ///////index.html HTTP/1.1  GET %n%n%n%n%n%n.html HTTP/1.1  GET /AAAAAAAAAAAAA.html HTTP/1.1  GET /index.html HTTTTTTTTTTTTTP/1.1  GET /index.html HTTP/

13 Regression vs. Fuzzing  Regression: Run program on many normal inputs, look for badness.  Goal: Prevent normal users from encountering errors  Fuzzing: Run program on many abnormal inputs, look for badness.  Goal: Prevent attackers from encountering exploitable errors

14 Approach I: Black-box Fuzz Testing  Given a program, simply feed it random inputs, see whether it crashes  Advantage: really easy  Disadvantage: inefficient  Input often requires structures, random inputs are likely to be malformed  Inputs that would trigger a crash is a very small fraction, probability of getting lucky may be very low

15 Enhancement I: Mutation-Based Fuzzing  Take a well-formed input, randomly perturb (flipping bit, etc.)  Little or no knowledge of the structure of the inputs is assumed  Anomalies are added to existing valid inputs  Anomalies may be completely random or follow some heuristics  e.g. remove NUL, shift character forward  Examples:  ZZUF, very successful at finding bugs in many real-world programs,  Taof, GPF, ProxyFuzz, FileFuzz, Filep, etc.

16 Example: fuzzing a pdf viewer  Google for.pdf (about 1 billion results)  Crawl pages to build a corpus  Use fuzzing tool (or script to)  1. Grab a file  2. Mutate that file  3. Feed it to the program  4. Record if it crashed (and input that crashed it)

17 Mutation-based Fuzzing In Short  Strengths  Super easy to setup and automate  Little to no protocol knowledge required  Weaknesses  Limited by initial corpus  May fail for protocols with checksums, those which depend on challenge response, etc.

18 Enhancement II: Generation-Based Fuzzing  Test cases are generated from some description of the format: RFC, documentation, etc.  Using specified protocols/file format info  E.g., SPIKE by Immunity are.shtml are.shtml  Anomalies are added to each possible spot in the inputs  Knowledge of protocol should give better results than random fuzzing

19 Generation-Based Fuzzing In Short  Strengths  completeness  Can deal with complex dependencies e.g. checksums  Weaknesses  Have to have spec of protocol  Often can find good tools for existing protocols e.g. http, SNMP  Writing generator can be labor intensive for complex protocols  The spec is not the code  Our goal is code testing, not spec testing

20 Fuzzing Tools  Hackers’ job made easy  Input generation  Input injection  Bug detection  Workflow automation

21 Input Generation  Existing generational fuzzers for common protocols (ftp, http, SNMP, etc.)  Mu-4000, Codenomicon, PROTOS, FTPFuzz  Fuzzing Frameworks: You provide a spec, they provide a fuzz set  SPIKE, Peach, Sulley  Dumb Fuzzing automated: you provide the files or packet traces, they provide the fuzz sets  Filep, Taof, GPF, ProxyFuzz, PeachShark  Many special purpose fuzzers already exist as well  ActiveX (AxMan), regular expressions, etc.

22 Input Injection  Simplest  Run program on fuzzed file  Replay fuzzed packet trace  Modify existing program/client  Invoke fuzzer at appropriate point  Use fuzzing framework  e.g. Peach automates generating COM interface fuzzers  E.g., PaiMei framework  A reverse engineering framework

23 Bug Detection  See if program crashed  Type of crash can tell a lot (SEGV vs. assert fail)  Run program under dynamic memory error detector (valgrind/purify)  Catch more bugs, but more expensive per run.  See if program locks up  Roll your own checker e.g. valgrind skins  Valgrind:  framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail.

24 Workflow Automation  Sulley, Peach, Mu-4000 all provide tools to aid setup, running, recording, etc.  Virtual machines can help create reproducable workload

25 How Much Fuzz Is Enough?  Mutation based fuzzers may generate an infinite number of test cases... When has the fuzzer run long enough?  Generation based fuzzers may generate a finite number of test cases. What happens when they’re all run and no bugs are found?

26 Code Coverage  Some of the answers to these questions lie in code coverage  Code coverage is a metric which can be used to determine how much code has been executed.  Data can be obtained using a variety of profiling tools. e.g. gcov

27 Types of Code Coverage  Line/block coverage  Measures how many lines of source code have been executed.  Branch coverage  Measures how many branches in code have been taken (conditional jmps)  Path coverage  Measures how many paths have been taken

28 Example  Requires  1 test case for line coverage  2 test cases for branch coverage  4 test cases for path coverage  i.e. (a,b) = {(0,0), (3,0), (0,3), (3,3)}

29 Code Coverage  Benefits:  How good is this initial file?  Am I getting stuck somewhere? if(packet[0x10] < 7) { //hot path } else { //cold path }  How good is fuzzer X vs. fuzzer Y  Am I getting benefits from running a different fuzzer?  Problems:  Code can be covered without revealing bugs  Maybe the bug logic is not revealed by any testing inputs so far.

30 Fuzzing Rules of Thumb  Protocol specific knowledge very helpful  Generational tends to beat random, better spec’s make better fuzzers  More fuzzers is better  Each implementation will vary, different fuzzers find different bugs  The longer you run, the more bugs you may find  Best results come from guiding the process  Notice where your getting stuck, use profiling!  Code coverage can be very useful for guiding the process  Can we do better?

31 Approach II: Constraint-based Automatic Test Case Generation  Look inside the box  Use the code itself to guide the fuzzing  Assert security/safety properties  Explore different program execution paths to check for security properties  Challenge:  1. For a given path, need to check whether an input can trigger the bug, i.e., violate security property  2. Find inputs that will go down different program execution paths

32 Running Example f(unsigned int len){ unsigned int s; char *buf; if (len % 2==0) s = len; else s = len + 2; buf = malloc(s); read(fd, buf, len); … }  Where’s the bug?  What’s the security/safety property?  s>=len  What inputs will cause violation of the security property?  len =  How likely will random testing find the bug?

33 Symbolic Execution  Test input len=6  No assertion failure  What about all inputs that takes the same path as len=6?

34 Symbolic Execution  What about all inputs that takes the same path as len=6?  Represent len as symbolic variable

35 Symbolic Execution  Represent inputs as symbolic variables  Perform each operation on symbolic variables symbolically  x = y + 5;  Registers and memory values dependent on inputs become symoblic expressions  Certain conditions for conditional jump become symbolic expressions as well

36 Symbolic Execution  What about all inputs that takes the same path as len=6?  Represent len as symbolic variable

37 Using a Solver  Is there a value for len s.t. len % 2 = 0 ^ s = len ^ s < len?  Give the symbolic formula to a solver  In this case, the solver returns No  The formula is not satisfiable  What does this mean?  For any len that follows the same path as len = 6, the execution will be safe  Symbolic execution can check many inputs at the same time for the same path  What to do next?  Try to explore different path

38 How to Explore Different Paths?  Previous path constraint: len % 2 = 0  Flip the branch to go down a different path:  len % 2 != 0  Using a solver for the formula  A satisfying assignment is a new input to go down the path

39 Checking Assertion in the Other Path  Is there a value for len s.t.  len % 2 != 0 ^ s = len+2 ^ s < len?  Give the symbolic formula to a solver  Solver returns satisfying assignment: len =  Found the bug!

40 Summary: Symbolic Execution for Bug Finding  Symbolically execute a path  Create the formula representing: path constraint ^ assertion failure  Give the solver the formula  If returns a satisfying assignment, a bug found  Reverse condition for a branch to go down a different path  Give the solver the new path constraint  If returns a satisfying assignment  The path is feasible  Found a new input going down a different path  Pioneer work  EXE, DART, CUTE  “DART: directed automated random testing”, Conference on Programming Language Design and Implementation,  “EXE: automatically generating inputs of death”, Conference on Computer and Communications Security, 2006.