Wireless Network Protocol Fuzzing

Introduction

In this blog post I would like to introduce fuzzing to you, talk about the difficulties one might face when creating an intelligent fuzzer as well as provide you with some examples of existing fuzzing frameworks.

Fuzzing

Fuzzing is one of the most widely used vulnerability discovery techniques. The main idea of fuzzing is to test a computer program in an automated way, by providing to it as an input invalid, unexpected, or random data. After feeding the data, the state of the program is monitored for exceptions such as crashes, failing built-in code assertions, memory leaks, unexpected program behaviors, etc. This process of feeding data and monitoring program’s reaction is repeated over and over again with different inputs in an automated way.

Fuzzing is widely used in the software development, but in general, we can fuzz anything that runs code and works with some kind of input data. From now on, we will refer to the device or program that is being fuzzed as SUT (System under test).

The summary of all above-said can be seen on the Figure 1, where a typical fuzzing loop is shown.

Figure 1: Fuzzing loop

Now let us talk about the classification of fuzzers. They can be classified depending on the input generation strategy as well as the prior knowledge of the SUT.

Classification of fuzzers based on input data generation

Mutation-based fuzzers

The idea of mutation-based fuzzing is to generate new input from the previous test case by introducing small changes (mutations) in it. This mutations are typically very simple operations, like bit or byte flips, setting particular byte to zero or to the maximum value, etc. That increases the likelihood of the input still being valid, yet can potentially introduce new behavior of SUT. In order to generate the first test case, user has to provide a seed to the fuzzer. As we can see, for the mutation-based fuzzer, it is not necessary to know the specifications of input data or protocol use, as mutations alter the original seed without checking whether it complies with a specific syntax. Some of the most well-known mutation-based fuzzers are AFL, Angora and VUzzer.

Generation-based fuzzers

Generation-based methods use a set of specifications on the SUT inputs to generate new fuzz test data. In order to use generation-based fuzzing, it is necessary to know the syntax of the SUT inputs, including their format and underlying protocol (if any). Generation-based fuzzers are used when it is vital to provide a valid input for a successful test (i.e. when an input format is very constrained and it is likely that random mutation will make the test case rejected by the SUT). One of the main challenges using the generation-based fuzzer is the process of modeling complex or unknown protocols, that will be used by the fuzzer. Sulley and Peach are two of the most well-known generation-based fuzzers.

Classification of fuzzers based on the prior knowledge of SUT

Black-box fuzzers

Black-box fuzzing means that we know nothing about the SUT, we have no access to the source code and to the internal logic of the SUT. In this case, it typically comes down to fuzzing using random mutations. Obviously, such testing has a low likelihood of being successful in terms of finding bugs. However, black-box fuzzers can be applied against virtually any target, so we can consider them as a universal attacking tool. One well-known black-box fuzzer is zzuf.

White-box fuzzers

White-box fuzzing on contrary makes use of all of the information about the internal logic (i.e. the source code). Guided coverage and dynamic symbolic analysis are the most widely used methods in white-box analysis. White-box fuzzing immensely increases the code-coverage. However, frequently the code-access is not available (for example in case of auditing the third-party software). SAGE is one example of white-box fuzzers.

Grey-box fuzzers

Grey-box fuzzing, as the name suggests, is a combination of black-box and white-box fuzzing. Grey-box fuzzers have partial access to the internal logic of the SUT. That can be knowledge of protocol used, algorithms used, access to a part of the code, etc. Grey-box fuzzing is the most wide-spread nowadays. The main representative of grey-box fuzzing is AFL.

Wireless Network Protocol Fuzzing

In COSIC we are currently looking at Wireless Network Protocol Fuzzing. We are interested in fuzzing the devices that support some kind of wireless network protocols (i.e. WiFi, Long Term Evolution (LTE), Bluetooth, etc). The good thing is that almost all the devices nowadays have that support, from a smart light-bulb to a car! Our task is to find vulnerabilities in the implementations of wireless protocols in these devices using fuzzing techniques. Yes, that is right, we are not trying to find security flaws in the protocol itself (although we don’t mind if that happens). Instead, the source of bugs is typically the human’s implementation of those protocols and this is exactly the target point for security researchers.

There are two main challenges we are facing that are imposed by wireless fuzzing:

  • Intelligent input generation
  • Getting feedback from the SUT

Intelligent input generation

Because most of the time we do have the knowledge of which protocol the SUT executes, but do not have the source code, our fuzzer can be classified as a grey-box fuzzer. In addition, all wireless protocols have strict syntax, therefore generation-based method should be preferred to mutation-based one when fuzzing protocols. As it was stated before, one of the main challenges using the generation-based fuzzing is the process of modeling complex protocols that will be used by the fuzzer. Of course, we can try to read the specification and then program it manually. For smaller protocols this approach might very well work, but for the bigger ones that could be an unfeasible task. Let us take LTE as an example. LTE has a specification written in tens of thousands of pages. Basically, the specification describes the finite-state machine (FSM) for LTE. A small snippet of the specification can be seen in the Figure 2 ([1, Chapter 5.3.2.3]).

Figure 2: Description of FSM in LTE specification

Programming such a state machine would require immense amount of time and resources. So, instead of programming a state machine manually, we can try to use the techniques to retrieve it from the SUT itself (or any other device that implements the same protocol). One way of doing that is Automata Learning. The principles of Automata Learning is perhaps the topic of another blog post, but in simple words it allows us to extract FSM from the device using only (request, response) pairs to/from the SUT and does not demand any knowledge of the SUT’s source code. Automata Learning is still being actively explored. The most well-known framework for Automata Learning is LeanLib.

Knowing the FSM of the protocol used by the SUT, we are ready to use the generation-based fuzzing mechanisms for testing.

Feedback from the SUT

When fuzzing the software that is running on your own machine it is easy to discover if any exceptions (memory leaks, hangs, crashes, etc.) have occurred during the program’s runtime. In case of fuzzing embedded devices, which don’t even always have an operating system, we face a lot of difficulties monitoring the above mentioned exceptions. The only thing that we can observe with relative ease is a crash of the device. The problem is that not every memory violation or unexpected program behavior (immediately) results in a crash. Therefore, a fuzzer that is solely based on monitoring an “aliveness” of the device won’t be very efficient. In order to make our fuzzer more intelligent, different methods of extracting information from the SUT might be used. For example, we can take advantage of the debug interfaces offered by the SUT. In addition, side-channel analysis might help us as well. Lastly, the approach of using partial or full emulation of the SUT’s firmware can be used. It has to be said though that the emulation approach brings additional difficulties. More about the challenges in fuzzing embedded devices you can find in [8].

Overview of existing WiFi Fuzzing tools

In this section, I give an overview of two of the most powerful (in my opinion) WiFi fuzzing tools. I limit myself just to WiFi to keep this blog post within reasonable length limits.

Greyhound

Greyhound is a grey-box fuzzer that targets WiFi devices. It has a built-in FSM for WiFi protocol. As FSM for WiFi is not very large, developers of Greyhound hardcoded it manually instead of using Automata Learning techniques to retrieve it. In order to fuzz the SUT, Greyhound builds malformed packets by probabilistically mutating some fields of the correct packet, and sends them to the SUT. Additionally, Greyhound can send the correct packets at the wrong time. This allows Greyhound to trigger some well-known WiFi vulnerabilities such as KRACK and Dragonslayer.
In order to monitor the state of the SUT, Greyhound solely relies on the received packets from the SUT. Misbehavior is detected when the response packet does not comply with the expected response packets in the current state of FSM.
Fuzzing process used by Greyhound is summarized in the Figure 3, taken from the original paper [6]. On top of being capable to discover known vulnerabilities, Greyhound found 4 new ones in popular WiFi clients. I encourage reading the original paper [6] for getting more details about the fuzzer.

Figure 3: Architecture of Greyhound

Owfuzz

“Owfuzz is a WiFi protocol fuzzing tool using openwifi. Openwifi is an open-source WiFi protocol stack based on software-defined radio (SDR) that is fully compatible with Linux mac80211. It supports monitoring and injection of arbitrary WiFi frames. Owfuzz is the first to use openwifi platform to implements a WiFi protocol fuzzing test framework, which supports the fuzzing test of all WiFi frames and the interactivity testing of WiFi protocols” [9].
The architecture of Owfuzz framework can be seen in Figure 4, taken from [9].

Figure 4: Architecture of Owfuzz

Owfuzz supports different packet mutation strategies, but all it comes down to is either randomly fuzzing some field of the packet or testing the boundary values for certain fields.

In order to monitor the status of the SUT, Owfuzz uses the following techniques:

  • Monitor Deauth/Dissaoc frame from the SUT
  • Monitor whether the SUT continuously sends WiFi frames
  • Detect the network connectivity of the SUT through ICMP

Owfuzz has discovered 6 new vulnerabilities, which were mostly related to DOS attacks and driver/firmware crashes.

Conclusion

This blog post can be considered as an introduction to the rich world of fuzzing. You can find more reading materials below.

References and additional reading material

[1] 3rd Generation Partnership Project; Technical Specification Group Radio Access Net-
work; Evolved Universal Terrestrial Radio Access (E-UTRA); Radio Resource Control
(RRC);
Protocol specification. 2021, p. 94.

[2] Hongjian Cao. Owfuzz: WiFi Nightmare. Youtube. url: https://www.youtube.com/
watch?v=OYG5Q9hBZyI

[3] DRAGONBLOOD: Analysing WPA3’s Dragonfly Handshake. url: https://www.krackattacks.com/

[4] Maialen Eceiza, Jose Luis Flores, and Mikel Iturbe. “Fuzzing the Internet of Things:
A Review on the Techniques and Challenges for Efficient Vulnerability Discovery in
Embedded Systems”. In: IEEE Internet of Things Journal
8.13 (2021), pp. 10390–
10411. doi: 10.1109/JIOT.2021.3056179.

[5] Fuzzing. Wikipedia. 2022. url: https://en.wikipedia.org/wiki/Fuzzing.

[6] Matheus E. Garbelini, Chundong Wang, and Sudipta Chattopadhyay. “GREYHOUND:
Directed Greybox Wi-Fi Fuzzing”. In: IEEE Transactions on Dependable and Secure
Computing
(2020), pp. 1–1. doi: 10.1109/TDSC.2020.3014624.

[7] Key Reinstallation Attacks: Breaking WPA2 by forcing nonce reuse. url: https://wpa3.mathyvanhoef.com/

[8] Marius Muench et al. “What You Corrupt Is Not What You Crash: Challenges in
Fuzzing Embedded Devices”.
In: NDSS. Feb. 2018. url: http://s3.eurecom.fr/docs/ndss18_muench.pdf

[9] Owfuzz: a WiFi protocol fuzzing tool. url: https://github.com/alipay/Owfuzz

[10] Prof. Dr. Frits Vaandrager. Finding Software Bugs Using Active Automata Learning.
Youtube.
2020. url: https://www.youtube.com/watch?v=AT10cFXXFFs

[11] Andreas Zeller et al. “Mutation-Based Fuzzing”. In: The Fuzzing Book. Retrieved 2022-
01-11 09:26:32+01:00. CISPA Helmholtz Center for Information Security, 2022. url:
https://www.fuzzingbook.org/html/MutationFuzzer.html