CMPSC 447: Software Security, Spring 2019


Experiencing Fuzzing

In this project, you will use AFL to perform fuzzing on your program written for homework 3 and fix your program if AFL finds errors in it. You must do this project on the Westgate Linux lab machines. These machines are named cse-p204instXX.cse.psu.edu, where XX is a number between 01 and about 40.

Project tasks

Part 0: Build and install American Fuzzy Lop (AFL) under your user account on the Linux Lab machines. AFL is easy to build; download the source tarball and follow the quick start guide for building it. Its installation and running do not require root access. After installation, do a quick test following our course slides to make sure AFL installs and runs correctly.

Part 1 (6 points): Fuzz testing on your homework 3 client code

The client-server application in homework 3 requires both a server and a client. For the convenience of fuzzing, we will only fuzz the client part. For that, download a new project tarball. This new version is modified so that the client can run independently without contacting a server; in particular, siis-network.c has been modified so that data is not sent to a server.

After downloading the project tarball, replace transfer.c with your own version in homework 3. Please also modify the transfer_file function in transfer.c to comment out the line "wait_message( sock, &hdr, block, EXIT )" toward the end of the function so that the client does not wait for messages from the server.

You will also need to modify the Makefile to change its AFLDIR variable to point to the directory where your AFL is installed. Invoke "make" to build the executables; the Makefile in the tarball invokes afl-gcc for compilation (instead of gcc). As mentioned earlier, in this project we will use only the executable for the client, not the server.

For fuzzing, first create a directory called testcase and put some test files there. Then invoke "make aflfuzz" to start fuzzing; it will find test files under testcase and put the result under the directory called output. You should have a look at the Makefile to see how "make aflfuzz" works; it sets up some environment variables and fuzz the client program with specified input and output directories.

You should run a fuzzing campaign that lasts between 2 and 3 hours. If it is going slower, you should look at your crashes; there may be a bug you need to fix that is preventing it from executing paths.

There is always a possibility that AFL cannot find any bugs in your program. After all, the fuzzing process is probabilistic and your program may be bug free! If you cannot find any bugs through AFL, you should manually inject some memory-corruption bugs into your program and repeat the process; for example, make a malloc allocate one less space than needed, free a buffer before a use, inject a format-string error, etc.

Part 2 (4 points): Fixing the bugs

This part is about fixing the bugs found by AFL, up to a maximum of 3 unique fixes (if you have more, you do not have to fix them all). Some of the crashes/hangs may be caused by the same bug; so one fix may cover multiple crashes/hangs. Please record a mapping between crashes/hangs and fixes in your report.

What AFL gives is a set of inputs that make the program crash or hang (under the crashes and hangs sub-directories of the output directory). So you will need to manually run such an input on your program and figure out the bug before doing the fix; this may involve inserting extra debugging code (such as printfs) into the program. Once the bug is identified (e.g., not allocating a big-enough buffer or missing some input validation), fix your code accordingly.

If you manually injected bugs in part 1, then in your report just describe how you would identify those injected bugs from the AFL-generated inputs.

What do you need to submit?

Submit your work through Canvas. It's due on Mar 15th by midnight.


Author: Gang Tan, Penn State University, 2019. All rights reserved.