• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Fuzzer for libstagefright_amrwbdec decoder
2
3## Plugin Design Considerations
4The fuzzer plugin for AMR-WB is designed based on the understanding of the
5codec and tries to achieve the following:
6
7##### Maximize code coverage
8The configuration parameters are not hardcoded, but instead selected based on
9incoming data. This ensures more code paths are reached by the fuzzer.
10
11AMR-WB supports the following parameters:
121. Quality (parameter name: `quality`)
132. Mode (parameter name: `mode`)
14
15| Parameter| Valid Values| Configured Value|
16|------------- |-------------| ----- |
17| `quality` | 0. `Bad Quality` 1. `Good quality` | Bit 0 (LSB) of 1st byte of data. |
18| `mode`   | 0. `MODE_7k` 1. `MODE_9k` 2. `MODE_12k` 3. `MODE_14k`  4. `MODE_16k ` 5. `MODE_18k` 6. `MODE_20k` 7. `MODE_23k` 8. `MODE_24k` 9. `MRDTX`  | Bits 3, 4, 5 and 6 of 1st byte of data. |
19
20This also ensures that the plugin is always deterministic for any given input.
21
22##### Maximize utilization of input data
23The plugin feeds the entire input data to the codec using a loop.
24If the decode operation was successful, the input is advanced by the frame size
25which is based on `mode` and `quality` selected.
26If the decode operation was un-successful, the input is still advanced by frame size so
27that the fuzzer can proceed to feed the next frame.
28
29This ensures that the plugin tolerates any kind of input (empty, huge,
30malformed, etc) and doesnt `exit()` on any input and thereby increasing the
31chance of identifying vulnerabilities.
32
33## Build
34
35This describes steps to build amrwb_dec_fuzzer binary.
36
37### Android
38
39#### Steps to build
40Build the fuzzer
41```
42  $ mm -j$(nproc) amrwb_dec_fuzzer
43```
44
45#### Steps to run
46Create a directory CORPUS_DIR and copy some amrwb files to that folder
47Push this directory to device.
48
49To run on device
50```
51  $ adb sync data
52  $ adb shell /data/fuzz/arm64/amrwb_dec_fuzzer/amrwb_dec_fuzzer CORPUS_DIR
53```
54To run on host
55```
56  $ $ANDROID_HOST_OUT/fuzz/x86_64/amrwb_dec_fuzzer/amrwb_dec_fuzzer CORPUS_DIR
57```
58
59## References:
60 * http://llvm.org/docs/LibFuzzer.html
61 * https://github.com/google/oss-fuzz
62