Course contentsShow
← Security
Lesson 1389 of 3,05228. Application Security - TestingFree lesson

AFL and LibFuzzer

Introduction to American Fuzzy Lop and LibFuzzer, industry-standard coverage-guided fuzzing tools and their usage.

AFL and LibFuzzer

What you'll learn: How industry-standard coverage-guided fuzzers AFL and LibFuzzer automate vulnerability discovery through intelligent test case generation.

The Dominant Tools in Coverage-Guided Fuzzing

Now that you understand coverage-guided fuzzing, let's meet the two tools that revolutionized the field: American Fuzzy Lop (AFL) and LibFuzzer. Both implement coverage-guided fuzzing but with different approaches and use cases.

American Fuzzy Lop (AFL)

AFL, created by Michał Zalewski, operates as a binary instrumentation tool that wraps around your program. It compiles your code with special instrumentation (using afl-gcc or afl-clang) that tracks which code paths execute during fuzzing.

AFL runs your program as a separate process for each test case, monitoring crashes and hangs. It's like having a quality assurance tester who learns which input mutations explore new code branches, then focuses energy on those promising variations.

Key characteristics:

  • Process-based (forks for each test)
  • Slower but more isolated
  • Excellent for finding memory corruption
  • Works with command-line programs that read from files or stdin

LibFuzzer

LibFuzzer is a library-based fuzzer that links directly into your code as a library. Instead of launching separate processes, it calls a special LLVMFuzzerTestOneInput() function you provide, making it significantly faster than AFL.

Think of LibFuzzer as an internal testing engine embedded in your application, while AFL is an external tester running your application repeatedly.

Key characteristics:

  • In-process execution (much faster)
  • Requires writing a harness function
  • Better for library APIs and complex state
  • Integrated with LLVM/Clang sanitizers

Both tools maintain a corpus of interesting inputs and use genetic algorithms to evolve test cases that maximize code coverage, exactly as coverage-guided fuzzing prescribes.

Key Takeaway: AFL and LibFuzzer are the industry-standard coverage-guided fuzzers—AFL excels at fuzzing command-line programs through process isolation, while LibFuzzer offers faster in-process fuzzing for library APIs and complex applications.