Wednesday, 27 November 2019

Twice and thrice over, as they say, good is it to repeat and review what is good.

Three years ago I wrote about using the AFL fuzzer to find bugs in several NetSurf libraries. I have repeated this exercise a couple of times since then and thought I would summarise what I found with my latest run.

I started by downloading the latest version of AFL (2.52b) and compiling it. This went as smoothly as one could hope for and I experienced no issues although having done this several times before probably helps.

libnsbmp

I started with libnsbmp which is used to render windows bmp and ico files which remains a very popular format for website Favicons. The library was built with AFL instrumentation enabled, some output directories were created for results and a main and four subordinate fuzzer instances started.

vince@workshop:libnsbmp$ LD=afl-gcc CC=afl-gcc AFL_HARDEN=1 make VARIANT=debug test
afl-cc 2.52b by <lcamtuf@google.com>
afl-cc 2.52b by <lcamtuf@google.com>
afl-cc 2.52b by <lcamtuf@google.com>
 COMPILE: src/libnsbmp.c
afl-cc 2.52b by <lcamtuf@google.com>
afl-as 2.52b by <lcamtuf@google.com>
[+] Instrumented 633 locations (64-bit, hardened mode, ratio 100%).
      AR: build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/libnsbmp.a
 COMPILE: test/decode_bmp.c
afl-cc 2.52b by <lcamtuf@google.com>
afl-as 2.52b by <lcamtuf@google.com>
[+] Instrumented 57 locations (64-bit, hardened mode, ratio 100%).
    LINK: build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp
afl-cc 2.52b by <lcamtuf@google.com>
 COMPILE: test/decode_ico.c
afl-cc 2.52b by <lcamtuf@google.com>
afl-as 2.52b by <lcamtuf@google.com>
[+] Instrumented 71 locations (64-bit, hardened mode, ratio 100%).
    LINK: build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_ico
afl-cc 2.52b by <lcamtuf@google.com>
Test bitmap decode
Tests:1053 Pass:1053 Error:0
Test icon decode
Tests:609 Pass:609 Error:0
    TEST: Testing complete
vince@workshop:libnsbmp$ mkdir findings_dir graph_output_dir
vince@workshop:libnsbmp$ afl-fuzz -i test/ns-afl-bmp/ -o findings_dir/ -S f02 ./build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp @@ /dev/null > findings_dir/f02.log >&1 &
vince@workshop:libnsbmp$ afl-fuzz -i test/ns-afl-bmp/ -o findings_dir/ -S f03 ./build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp @@ /dev/null > findings_dir/f03.log >&1 &
vince@workshop:libnsbmp$ afl-fuzz -i test/ns-afl-bmp/ -o findings_dir/ -S f04 ./build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp @@ /dev/null > findings_dir/f04.log >&1 &
vince@workshop:libnsbmp$ afl-fuzz -i test/ns-afl-bmp/ -o findings_dir/ -S f05 ./build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp @@ /dev/null > findings_dir/f05.log >&1 &
vince@workshop:libnsbmp$ afl-fuzz -i test/ns-afl-bmp/ -o findings_dir/ -M f01 ./build-x86_64-linux-gnu-x86_64-linux-gnu-debug-lib-static/test_decode_bmp @@ /dev/null

The number of subordinate fuzzer instances was selected to allow the system in question (AMD 2600X) to keep all the cores in use with a clock of 4GHz which gave the highest number of
AFL master instance after six days
executions per second. This might be improved with better cooling but I have not investigated this.

After five days and six hours the "cycle count" field on the master instance had changed to green which the AFL documentation suggests means the fuzzer is unlikely to discover anything new so the run was stopped.

Just before stopping the afl-whatsup tool was used to examine the state of all the running instances.

vince@workshop:libnsbmp$ afl-whatsup -s ./findings_dir/
status check tool for afl-fuzz by <lcamtuf@google.com>

Summary stats
=============

       Fuzzers alive : 5
      Total run time : 26 days, 5 hours
         Total execs : 2873 million
    Cumulative speed : 6335 execs/sec
       Pending paths : 0 faves, 0 total
  Pending per fuzzer : 0 faves, 0 total (on average)
       Crashes found : 0 locally unique

Just for completeness there is also the graph of how the fuzzer performed over the run.

AFL fuzzer performance over libnsbmp run

There were no crashes at all (and none have been detected through fuzzing since the original run) and the 78 reported hangs were checked and all actually decode in a reasonable time. It seems the fuzzer "hang" detection default is simply a little aggressive for larger images.

libnsgif

I went through a similar setup with libnsgif which is used to render the GIF image format. The run was performed on a similar system running for five days and eighteen hours. The outcome was similar to libnsbmp with no hangs or crashes.


vince@workshop:libnsgif$ afl-whatsup -s ./findings_dir/
status check tool for afl-fuzz by <lcamtuf@google.com>

Summary stats
=============

       Fuzzers alive : 5
      Total run time : 28 days, 20 hours
         Total execs : 7710 million
    Cumulative speed : 15474 execs/sec
       Pending paths : 0 faves, 0 total
  Pending per fuzzer : 0 faves, 0 total (on average)
       Crashes found : 0 locally unique

libsvgtiny

AFL fuzzer results for libsvgtiny
I then ran the fuzzer on the SVG render library using a dictionary to help the fuzzer cope with a sparse textural input format. The run was allowed to continue for almost fourteen days with no crashes or hangs detected.

In an ideal situation this run would have been allowed to continue but the system running it required a restart for maintenance.

Conclusion

The aphorism "absence of proof is not proof of absence" seems to apply to these results. While the new fuzzing runs revealed no additional failures it does not mean there are no defects in the code to find. All I can really say is that the AFL tool was unable to find any failures within the time available.

Additionally the AFL test corpus produced did not significantly change the code coverage metrics so the existing set was retained.

Will I spend the time again in future to re-run these tests? perhaps, but I think more would be gained from enabling the fuzzing of the other NetSurf libraries and picking the low hanging fruit from there than expending thousands of hours preforming these runs again.

22 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thanks for sharing it i had to take my online class right now and your code helped me alot in my assignement

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. A social media marketing agency near you, like ReviseBook, is a professional service provider specializing in helping businesses and individuals effectively leverage social media platforms to achieve their marketing goals. With a focus on local proximity, ReviseBook offers its expertise and services to clients in your area.

    ReplyDelete
  5. No doubt about your hard work. Thanks for sharing. But are you interested in to start your business in Dubai?

    ReplyDelete
  6. If you got bored of using original green WhatsApp, then download blue kb WhatsApp to get amazing features.

    ReplyDelete
  7. Ver ESPN 3 México ofrece a los aficionados acceso a una amplia gama de eventos deportivos en vivo, análisis experto y cobertura exclusiva, brindando una experiencia inmersiva para los amantes del deporte en México. Con transmisión de alta calidad y contenido variado, ESPN 3 México se ha convertido en un destino favorito para seguir de cerca las emociones del deporte. Y ver gratis ver espn 3 mexico

    ReplyDelete


  8. ISO 9001 clause 6.3 focuses on ensuring the effectiveness of processes, emphasizing the importance of planning and implementing actions to address risks and opportunities. By systematically identifying and mitigating potential issues while capitalizing on opportunities for improvement, organizations can enhance their ability to consistently deliver quality products and services, aligning with the core principles of ISO 9001.

    ReplyDelete
  9. IT TCS Peshawar is a branch of TCS (Tranzum Courier Service) in Peshawar, Pakistan, providing logistics, courier, and supply chain solutions. It offers a range of services including express delivery, freight forwarding, and e-commerce logistics to support businesses and individuals in the region.

    ReplyDelete
  10. The TCS Lahore office serves as a key hub for the company's courier and logistics operations, offering a wide range of services including parcel delivery, freight forwarding, and e-commerce solutions. Known for its efficient service and customer support, the Lahore office ensures timely and reliable deliveries across the region.

    ReplyDelete
  11. SNGPL duplicate bill print allows customers of Sui Northern Gas Pipelines Limited (SNGPL) to easily access and print a copy of their gas bill online. This service helps users conveniently track their billing information, check payment status, and avoid delays in receiving physical copies.

    ReplyDelete
  12. Does cookout use peanut oil. Cook Out primarily uses beef tallow for frying rather than peanut oil. However, it's best to check with your local Cook Out location to confirm, especially if you have allergies.

    ReplyDelete
  13. Ethiopia located in the Horn of Africa, is one of the continent's oldest nations, with a rich history dating back thousands of years. Known for its diverse culture, languages, and landscapes, it is the only African country never colonized, preserving a unique heritage. Ethiopia is also home to stunning landscapes like the Simien Mountains and historical sites, including the rock-hewn churches of Lalibela.

    ReplyDelete
  14. The https://sngplbills.pk/sngpl-consumer-bill/ bill is a monthly statement issued by Sui Northern Gas Pipelines Limited (SNGPL) for gas consumption in Pakistan. It provides details on usage, charges, and payment due dates, allowing customers to monitor and manage their energy expenses. SNGPL also offers options for online viewing and payment to make bill management more convenient.

    ReplyDelete