An in-depth look into software bug finding, focusing on memory-safety vulnerabilities such as buffer overflow and integer overflow. It also covers runtime detection methods, practical tools like purify, and fuzzing techniques for finding 0-day vulnerabilities. Real-world examples, such as the iphone security flaw, and discusses the importance of code coverage and the strengths and weaknesses of different fuzzing approaches.
Download Software Bug Finding: Techniques for Identifying Memory-safety Vulnerabilities and Fuzzing and more Slides Software Engineering in PDF only on Docsity!
Find Software Bugs
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
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, 2007. The slides from this talk are also available.
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
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)
The iPhone Story
Step #1: WebKit opensource
“WebKit is an open source web browser engine. WebKit is also the nameof the Mac OS X system framework version of the engine that's used bySafari, Dashboard, Mail, and many other OS X applications.”
http://webkit.org/
Step #2: identify potential focus points
From development site: The JavaScriptCore Tests “ If you are making changes to JavaScriptCore, thereis an additional test suite you must run before landingchanges. 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
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
Trivial Example
• Standard HTTP GET request
GET /index.html HTTP/1.
• Anomalous requests
AAAAAA...AAAA /index.html HTTP/1.
GET ///////index.html HTTP/1.
GET %n%n%n%n%n%n.html HTTP/1.
GET /AAAAAAAAAAAAA.html HTTP/1.
GET /index.html HTTTTTTTTTTTTTP/1.
GET /index.html HTTP/1.1.1.1.1.1.1.
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 inputsare likely to be malformed
Inputs that would trigger a crash is a very smallfraction, probability of getting lucky may be verylow
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 isassumed
Anomalies are added to existing valid inputs
Anomalies may be completely random or follow someheuristics - e.g. remove NUL, shift character forward
Examples:
ZZUF, very successful at finding bugs in many real-world programs,http://sam.zoy.org/zzuf/
Taof, GPF, ProxyFuzz, FileFuzz, Filep, etc.
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, thosewhich depend on challenge response, etc.
Enhancement II: Generation-Based Fuzzing
Test cases are generated from some description ofthe format: RFC, documentation, etc. - Using specified protocols/file format info - E.g., SPIKE by Immunityhttp://www.immunitysec.com/resourcesfreesoftware.shtml
Anomalies are added to each possible spot in theinputs
Knowledge of protocol should give better resultsthan random fuzzing
Fuzzing Tools
• Hackers’ job made easy
• Input generation
• Input injection
• Bug detection
• Workflow automation
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 fuzzset - SPIKE, Peach, Sulley
Dumb Fuzzing automated: you provide the files or packettraces, they provide the fuzz sets - Filep, Taof, GPF, ProxyFuzz, PeachShark
Many special purpose fuzzers already exist as well