Docsity

Software Bug Finding: Techniques for Identifying Memory-safety Vulnerabilities and Fuzzing, Slides of Software Engineering

Partial preview of the text

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.
  • Details see: http://securityevaluators.com/content/case-studies/iphone/

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

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 by Safari, 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, 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

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 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

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, 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, those which depend on challenge response, etc.

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 http://www.immunitysec.com/resourcesfreesoftware.sh tml
  • Anomalies are added to each possible spot in the inputs
  • Knowledge of protocol should give better results than 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 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.