RAM Disks and Saving Your SSD From AFL Fuzzing
09 December, 2014
The American Fuzzy Lop fuzzer has become a critical tool for finding security vulnerabilities in all sorts of software. It has the ability to send fuzzing data through programs on the order of hundreds of millions of executions per day on a capable system, and can certainly put strain on your hardware and OS. If you are fuzzing a target program with the AFL mode where a file is written and the target binary reads from this file, then AFL is going to conduct a huge number of writes to the local disk. For a solid-state drive this can reduce its life expectancy because of write amplification.My main workstation is a Mac running OS X Yosemite, and I run a lot of Linux, FreeBSD, and OpenBSD virtual machines under Parallels for development purposes. The drive on this system is an SSD which keeps everything quite fast, but I don't want to prematurely shorten its life through huge AFL fuzzing runs. Normally, I'm using AFL to fuzz fwknop from an Ubuntu-14.10 VM, and what is needed is a way to keep disk writes down. The solution is to use a RAM disk from within the VM.
First, from the Ubuntu VM, let's get set up for AFL fuzzing and show what the disk writes look like without using a RAM disk from the perspective of the host OS X system. This assumes AFL 0.89 has been installed already and is in the current path:
$ git clone https://github.com/mrash/fwknop.git fwknop.git $ cd fwknop.git $ ./autogen.sh $ cd test/afl/ $ ./compile/afl-compile.shWe're not running AFL yet. Now, from the Mac, launch the Activity Monitor (under Applications > Utilities) and look at current disk utilization:

$ ./fuzzing-wrappers/server-digest-cache.sh [+] All right - fork server is up. [+] All test cases processed. [+] Here are some useful stats: Test case count : 1 favored, 0 variable, 1 total Bitmap range : 727 to 727 bits (average: 727.00 bits) Exec timing : 477 to 477 us (average: 477 us) [+] All set and ready to roll!And now let's take a look at disk writes again from OS X:

# mkdir /tmp/afl-ramdisk && chmod 777 /tmp/afl-ramdisk # mount -t tmpfs -o size=512M tmpfs /tmp/afl-ramdisk $ mv fwknop.git /tmp/afl-ramdisk $ cd /tmp/afl-ramdisk/fwknop.git/test/afl/ $ ./fuzzing-wrappers/server-digest-cache.shHere is disk utilization once again from the Mac:
