OLD | NEW |
1 ================== | 1 ================== |
2 american fuzzy lop | 2 american fuzzy lop |
3 ================== | 3 ================== |
4 | 4 |
5 Written and maintained by Michal Zalewski <lcamtuf@google.com> | 5 Written and maintained by Michal Zalewski <lcamtuf@google.com> |
6 | 6 |
7 Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved. | 7 Copyright 2013, 2014, 2015, 2016 Google Inc. All rights reserved. |
8 Released under terms and conditions of Apache License, Version 2.0. | 8 Released under terms and conditions of Apache License, Version 2.0. |
9 | 9 |
10 For new versions and additional information, check out: | 10 For new versions and additional information, check out: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 data from stdin or from a file and passes it to the tested library. In such a | 108 data from stdin or from a file and passes it to the tested library. In such a |
109 case, it is essential to link this executable against a static version of the | 109 case, it is essential to link this executable against a static version of the |
110 instrumented library, or to make sure that the correct .so file is loaded at | 110 instrumented library, or to make sure that the correct .so file is loaded at |
111 runtime (usually by setting LD_LIBRARY_PATH). The simplest option is a static | 111 runtime (usually by setting LD_LIBRARY_PATH). The simplest option is a static |
112 build, usually possible via: | 112 build, usually possible via: |
113 | 113 |
114 $ CC=/path/to/afl/afl-gcc ./configure --disable-shared | 114 $ CC=/path/to/afl/afl-gcc ./configure --disable-shared |
115 | 115 |
116 Setting AFL_HARDEN=1 when calling 'make' will cause the CC wrapper to | 116 Setting AFL_HARDEN=1 when calling 'make' will cause the CC wrapper to |
117 automatically enable code hardening options that make it easier to detect | 117 automatically enable code hardening options that make it easier to detect |
118 simple memory bugs. | 118 simple memory bugs. Libdislocator, a helper library included with AFL (see |
| 119 libdislocator/README.dislocator) can help uncover heap corruption issues, too. |
119 | 120 |
120 PS. ASAN users are advised to review notes_for_asan.txt file for important | 121 PS. ASAN users are advised to review notes_for_asan.txt file for important |
121 caveats. | 122 caveats. |
122 | 123 |
123 4) Instrumenting binary-only apps | 124 4) Instrumenting binary-only apps |
124 --------------------------------- | 125 --------------------------------- |
125 | 126 |
126 When source code is *NOT* available, the fuzzer offers experimental support for | 127 When source code is *NOT* available, the fuzzer offers experimental support for |
127 fast, on-the-fly instrumentation of black-box binaries. This is accomplished | 128 fast, on-the-fly instrumentation of black-box binaries. This is accomplished |
128 with a version of QEMU running in the lesser-known "user space emulation" mode. | 129 with a version of QEMU running in the lesser-known "user space emulation" mode. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 redundant verbiage - notably including HTML, SQL, or JavaScript. | 270 redundant verbiage - notably including HTML, SQL, or JavaScript. |
270 | 271 |
271 To avoid the hassle of building syntax-aware tools, afl-fuzz provides a way to | 272 To avoid the hassle of building syntax-aware tools, afl-fuzz provides a way to |
272 seed the fuzzing process with an optional dictionary of language keywords, | 273 seed the fuzzing process with an optional dictionary of language keywords, |
273 magic headers, or other special tokens associated with the targeted data type | 274 magic headers, or other special tokens associated with the targeted data type |
274 - and use that to reconstruct the underlying grammar on the go: | 275 - and use that to reconstruct the underlying grammar on the go: |
275 | 276 |
276 http://lcamtuf.blogspot.com/2015/01/afl-fuzz-making-up-grammar-with.html | 277 http://lcamtuf.blogspot.com/2015/01/afl-fuzz-making-up-grammar-with.html |
277 | 278 |
278 To use this feature, you first need to create a dictionary in one of the two | 279 To use this feature, you first need to create a dictionary in one of the two |
279 formats discussed in testcases/README.testcases; and then point the fuzzer to | 280 formats discussed in dictionaries/README.dictionaries; and then point the fuzzer |
280 it via the -x option in the command line. | 281 to it via the -x option in the command line. |
| 282 |
| 283 (Several common dictionaries are already provided in that subdirectory, too.) |
281 | 284 |
282 There is no way to provide more structured descriptions of the underlying | 285 There is no way to provide more structured descriptions of the underlying |
283 syntax, but the fuzzer will likely figure out some of this based on the | 286 syntax, but the fuzzer will likely figure out some of this based on the |
284 instrumentation feedback alone. This actually works in practice, say: | 287 instrumentation feedback alone. This actually works in practice, say: |
285 | 288 |
286 http://lcamtuf.blogspot.com/2015/04/finding-bugs-in-sqlite-easy-way.html | 289 http://lcamtuf.blogspot.com/2015/04/finding-bugs-in-sqlite-easy-way.html |
287 | 290 |
288 PS. Even when no explicit dictionary is given, afl-fuzz will try to extract | 291 PS. Even when no explicit dictionary is given, afl-fuzz will try to extract |
289 existing syntax tokens in the input corpus by watching the instrumentation | 292 existing syntax tokens in the input corpus by watching the instrumentation |
290 very closely during deterministic byte flips. This works for some types of | 293 very closely during deterministic byte flips. This works for some types of |
291 parsers and grammars, but isn't nearly as good as the -x mode. | 294 parsers and grammars, but isn't nearly as good as the -x mode. |
292 | 295 |
| 296 If a dictionary is really hard to come by, another option is to let AFL run |
| 297 for a while, and then use the token capture library that comes as a companion |
| 298 utility with AFL. For that, see libtokencap/README.tokencap. |
| 299 |
293 10) Crash triage | 300 10) Crash triage |
294 ---------------- | 301 ---------------- |
295 | 302 |
296 The coverage-based grouping of crashes usually produces a small data set that | 303 The coverage-based grouping of crashes usually produces a small data set that |
297 can be quickly triaged manually or with a very simple GDB or Valgrind script. | 304 can be quickly triaged manually or with a very simple GDB or Valgrind script. |
298 Every crash is also traceable to its parent non-crashing test case in the | 305 Every crash is also traceable to its parent non-crashing test case in the |
299 queue, making it easier to diagnose faults. | 306 queue, making it easier to diagnose faults. |
300 | 307 |
301 Having said that, it's important to acknowledge that some fuzzing crashes can be | 308 Having said that, it's important to acknowledge that some fuzzing crashes can be |
302 difficult quickly evaluate for exploitability without a lot of debugging and | 309 difficult quickly evaluate for exploitability without a lot of debugging and |
(...skipping 26 matching lines...) Expand all Loading... |
329 The minimizer accepts the -m, -t, -f and @@ syntax in a manner compatible with | 336 The minimizer accepts the -m, -t, -f and @@ syntax in a manner compatible with |
330 afl-fuzz. | 337 afl-fuzz. |
331 | 338 |
332 Another recent addition to AFL is the afl-analyze tool. It takes an input | 339 Another recent addition to AFL is the afl-analyze tool. It takes an input |
333 file, attempts to sequentially flip bytes, and observes the behavior of the | 340 file, attempts to sequentially flip bytes, and observes the behavior of the |
334 tested program. It then color-codes the input based on which sections appear to | 341 tested program. It then color-codes the input based on which sections appear to |
335 be critical, and which are not; while not bulletproof, it can often offer quick | 342 be critical, and which are not; while not bulletproof, it can often offer quick |
336 insights into complex file formats. More info about its operation can be found | 343 insights into complex file formats. More info about its operation can be found |
337 near the end of technical_details.txt. | 344 near the end of technical_details.txt. |
338 | 345 |
339 11) Common-sense risks | 346 11) Going beyond crashes |
| 347 ------------------------ |
| 348 |
| 349 Fuzzing is a wonderful and underutilized technique for discovering non-crashing |
| 350 design and implementation errors, too. Quite a few interesting bugs have been |
| 351 found by modifying the target programs to call abort() when, say: |
| 352 |
| 353 - Two bignum libraries produce different outputs when given the same |
| 354 fuzzer-generated input, |
| 355 |
| 356 - An image library produces different outputs when asked to decode the same |
| 357 input image several times in a row, |
| 358 |
| 359 - A serialization / deserialization library fails to produce stable outputs |
| 360 when iteratively serializing and deserializing fuzzer-supplied data, |
| 361 |
| 362 - A compression library produces an output inconsistent with the input file |
| 363 when asked to compress and then decompress a particular blob. |
| 364 |
| 365 Implementing these or similar sanity checks usually takes very little time; |
| 366 if you are the maintainer of a particular package, you can make this code |
| 367 conditional with #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION (a flag also |
| 368 shared with libfuzzer) or #ifdef __AFL_COMPILER (this one is just for AFL). |
| 369 |
| 370 12) Common-sense risks |
340 ---------------------- | 371 ---------------------- |
341 | 372 |
342 Please keep in mind that, similarly to many other computationally-intensive | 373 Please keep in mind that, similarly to many other computationally-intensive |
343 tasks, fuzzing may put strain on your hardware and on the OS. In particular: | 374 tasks, fuzzing may put strain on your hardware and on the OS. In particular: |
344 | 375 |
345 - Your CPU will run hot and will need adequate cooling. In most cases, if | 376 - Your CPU will run hot and will need adequate cooling. In most cases, if |
346 cooling is insufficient or stops working properly, CPU speeds will be | 377 cooling is insufficient or stops working properly, CPU speeds will be |
347 automatically throttled. That said, especially when fuzzing on less | 378 automatically throttled. That said, especially when fuzzing on less |
348 suitable hardware (laptops, smartphones, etc), it's not entirely impossible | 379 suitable hardware (laptops, smartphones, etc), it's not entirely impossible |
349 for something to blow up. | 380 for something to blow up. |
350 | 381 |
351 - Targeted programs may end up erratically grabbing gigabytes of memory or | 382 - Targeted programs may end up erratically grabbing gigabytes of memory or |
352 filling up disk space with junk files. AFL tries to enforce basic memory | 383 filling up disk space with junk files. AFL tries to enforce basic memory |
353 limits, but can't prevent each and every possible mishap. The bottom line | 384 limits, but can't prevent each and every possible mishap. The bottom line |
354 is that you shouldn't be fuzzing on systems where the prospect of data loss | 385 is that you shouldn't be fuzzing on systems where the prospect of data loss |
355 is not an acceptable risk. | 386 is not an acceptable risk. |
356 | 387 |
357 - Fuzzing involves billions of reads and writes to the filesystem. On modern | 388 - Fuzzing involves billions of reads and writes to the filesystem. On modern |
358 systems, this will be usually heavily cached, resulting in fairly modest | 389 systems, this will be usually heavily cached, resulting in fairly modest |
359 "physical" I/O - but there are many factors that may alter this equation. | 390 "physical" I/O - but there are many factors that may alter this equation. |
360 It is your responsibility to monitor for potential trouble; with very heavy | 391 It is your responsibility to monitor for potential trouble; with very heavy |
361 I/O, the lifespan of many HDDs and SSDs may be reduced. | 392 I/O, the lifespan of many HDDs and SSDs may be reduced. |
362 | 393 |
363 A good way to monitor disk I/O on Linux is the 'iostat' command: | 394 A good way to monitor disk I/O on Linux is the 'iostat' command: |
364 | 395 |
365 $ iostat -d 3 -x -k [...optional disk ID...] | 396 $ iostat -d 3 -x -k [...optional disk ID...] |
366 | 397 |
367 12) Known limitations & areas for improvement | 398 13) Known limitations & areas for improvement |
368 --------------------------------------------- | 399 --------------------------------------------- |
369 | 400 |
370 Here are some of the most important caveats for AFL: | 401 Here are some of the most important caveats for AFL: |
371 | 402 |
372 - AFL detects faults by checking for the first spawned process dying due to | 403 - AFL detects faults by checking for the first spawned process dying due to |
373 a signal (SIGSEGV, SIGABRT, etc). Programs that install custom handlers for | 404 a signal (SIGSEGV, SIGABRT, etc). Programs that install custom handlers for |
374 these signals may need to have the relevant code commented out. In the same | 405 these signals may need to have the relevant code commented out. In the same |
375 vein, faults in child processed spawned by the fuzzed target may evade | 406 vein, faults in child processed spawned by the fuzzed target may evade |
376 detection unless you manually add some code to catch that. | 407 detection unless you manually add some code to catch that. |
377 | 408 |
(...skipping 15 matching lines...) Expand all Loading... |
393 need to make simple code changes to make them behave in a more traditional | 424 need to make simple code changes to make them behave in a more traditional |
394 way. Preeny may offer a relatively simple option, too - see: | 425 way. Preeny may offer a relatively simple option, too - see: |
395 https://github.com/zardus/preeny | 426 https://github.com/zardus/preeny |
396 | 427 |
397 Some useful tips for modifying network-based services can be also found at: | 428 Some useful tips for modifying network-based services can be also found at: |
398 https://www.fastly.com/blog/how-to-fuzz-server-american-fuzzy-lop | 429 https://www.fastly.com/blog/how-to-fuzz-server-american-fuzzy-lop |
399 | 430 |
400 - AFL doesn't output human-readable coverage data. If you want to monitor | 431 - AFL doesn't output human-readable coverage data. If you want to monitor |
401 coverage, use afl-cov from Michael Rash: https://github.com/mrash/afl-cov | 432 coverage, use afl-cov from Michael Rash: https://github.com/mrash/afl-cov |
402 | 433 |
| 434 - Occasionally, sentient machines rise against their creators. If this |
| 435 happens to you, please consult http://lcamtuf.coredump.cx/prep/. |
| 436 |
403 Beyond this, see INSTALL for platform-specific tips. | 437 Beyond this, see INSTALL for platform-specific tips. |
404 | 438 |
405 13) Special thanks | 439 14) Special thanks |
406 ------------------ | 440 ------------------ |
407 | 441 |
408 Many of the improvements to afl-fuzz wouldn't be possible without feedback, | 442 Many of the improvements to afl-fuzz wouldn't be possible without feedback, |
409 bug reports, or patches from: | 443 bug reports, or patches from: |
410 | 444 |
411 Jann Horn Hanno Boeck | 445 Jann Horn Hanno Boeck |
412 Felix Groebert Jakub Wilk | 446 Felix Groebert Jakub Wilk |
413 Richard W. M. Jones Alexander Cherepanov | 447 Richard W. M. Jones Alexander Cherepanov |
414 Tom Ritter Hovik Manucharyan | 448 Tom Ritter Hovik Manucharyan |
415 Sebastian Roschke Eberhard Mattes | 449 Sebastian Roschke Eberhard Mattes |
(...skipping 16 matching lines...) Expand all Loading... |
432 Alex Moneger Dmitry Vyukov | 466 Alex Moneger Dmitry Vyukov |
433 Keegan McAllister Kostya Serebryany | 467 Keegan McAllister Kostya Serebryany |
434 Richo Healey Martijn Bogaard | 468 Richo Healey Martijn Bogaard |
435 rc0r Jonathan Foote | 469 rc0r Jonathan Foote |
436 Christian Holler Dominique Pelle | 470 Christian Holler Dominique Pelle |
437 Jacek Wielemborek Leo Barnes | 471 Jacek Wielemborek Leo Barnes |
438 Jeremy Barnes Jeff Trull | 472 Jeremy Barnes Jeff Trull |
439 Guillaume Endignoux ilovezfs | 473 Guillaume Endignoux ilovezfs |
440 Daniel Godas-Lopez Franjo Ivancic | 474 Daniel Godas-Lopez Franjo Ivancic |
441 Austin Seipp Daniel Komaromy | 475 Austin Seipp Daniel Komaromy |
442 Daniel Binderman | 476 Daniel Binderman Jonathan Metzman |
| 477 Vegard Nossum Jan Kneschke |
| 478 Kurt Roeckx |
443 | 479 |
444 Thank you! | 480 Thank you! |
445 | 481 |
446 14) Contact | 482 15) Contact |
447 ----------- | 483 ----------- |
448 | 484 |
449 Questions? Concerns? Bug reports? The author can be usually reached at | 485 Questions? Concerns? Bug reports? The author can be usually reached at |
450 <lcamtuf@google.com>. | 486 <lcamtuf@google.com>. |
451 | 487 |
452 There is also a mailing list for the project; to join, send a mail to | 488 There is also a mailing list for the project; to join, send a mail to |
453 <afl-users+subscribe@googlegroups.com>. Or, if you prefer to browse | 489 <afl-users+subscribe@googlegroups.com>. Or, if you prefer to browse |
454 archives first, try: | 490 archives first, try: |
455 | 491 |
456 https://groups.google.com/group/afl-users | 492 https://groups.google.com/group/afl-users |
457 | 493 |
458 PS. If you wish to submit raw code to be incorporated into the project, please | 494 PS. If you wish to submit raw code to be incorporated into the project, please |
459 be aware that the copyright on most of AFL is claimed by Google. While you do | 495 be aware that the copyright on most of AFL is claimed by Google. While you do |
460 retain copyright on your contributions, they do ask people to agree to a simple | 496 retain copyright on your contributions, they do ask people to agree to a simple |
461 CLA first: | 497 CLA first: |
462 | 498 |
463 https://cla.developers.google.com/clas | 499 https://cla.developers.google.com/clas |
464 | 500 |
465 Sorry about the hassle. Of course, no CLA is required for feature requests or | 501 Sorry about the hassle. Of course, no CLA is required for feature requests or |
466 bug reports. | 502 bug reports. |
OLD | NEW |