Bluetooth stack implements very complex wireless communication protocols and scenarios. It's been a hotspot for security researchers and attackers. Fuzzing has been used as a popular approach to look for security vulnerabilities in Bluetooth stack.
Due to the complex architecture of the Android Bluetooth stack, fuzzing the entire stack with pure software is very difficult and impractical. Instead, multiple fuzzers are created to target different areas of the BT stack. Fuzzers in this directory focuses on the components under system/stack
.
For security purpose, remote attack surfaces usually take higher priority since they can cause much severe damage comparing to local attacks. This makes the incoming BT message handlers our focus. The goal is to be able to pipe randomly generated data packets to those message handlers to explore the code path each component contains. This helps flushing out any memory/logic issues in the remote message handling routine.
Components requiring no authentication, or dealing with messages before authentication have a higher fuzzing priority. This includes the SDP, GATT, SMP and L2CAP components. A couple post authentication components such as BNEP, AVRC, AVCT are also covered by different fuzzers.
According to Bluetooth spec and the source code, most of the components we care here work above the L2CAP layer. In general they work with the following sequences:
The fuzzers are designed to simulate how a component is used in the real world, but with a lot of simplifications. Here is how they work in general:
For maximium fuzzing efficiency, the fuzzers are created to include the target component and minimium number of other Bluetooth components. This means any dependencies from other Bluetooth components need to be mocked. The mocks are implemented with a balance of reaching maximium target code coverage and minimium development effort. Some of the mocks are simply not implemented.
These fuzzers are still far from perfect, with the following possible improvements:
Code coverage
It's very important to review the code coverage of each fuzzer. Any big coverage gaps should be analyzed and improved. This can be done by adding additional logic in the fuzzing loop, such as calling certain APIs, providing upper layer callbacks, or changing the mock behaviors.
Performance
The fuzzers are designed to run as fast as possible. But there might still be some room to improve the performance. Profiling can be done to figure out the performance bottlenecks, which might be sleeps, tight for loops, or computational heavy operations, such as crypto functions.
Component coverage
Currently only 3 fuzzers are created. More should be added so we can cover most of the stack components. With the mocks and design patterns it shouldn't be too difficult.