Skip to content

Commit 8044d2c

Browse files
committed
Updated bash script and documentation for mutation-based fuzzing option
1 parent ad2af59 commit 8044d2c

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

docs/fuzzing.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ vulnerabilities are not observable, and even the crash behaviour varies from cas
1313
to case. Furthermore, the goal to find a general approach for any authenticator
1414
rules out common solutions such as hardware emulation or binary instrumentation.
1515

16-
## Corpus testing
16+
## How does it work
1717

1818
Our idea is fuzzing by proxy. We take [OpenSK](https://github.com/google/OpenSK)
1919
(an open source implementation of a FIDO2 security key) as our fuzz target and
2020
generate interesting input data guided by OpenSK's code coverage. At the moment,
21-
the fuzzing tool consists of running this input corpus on the device under test.
21+
we support two fuzzing modes:
22+
1. Run this input corpus directly on the device under test.
23+
2. Fuzz the device under test using this input corpus as initial corpus.
2224
The corpus is hosted at a [git repository](https://github.com/google/CTAP2-test-tool-corpus)
2325
and integrated as a submodule, which will be downloaded upon cloning the test
2426
tool repository. When downloading the test tool manually, you can copy the corpus
@@ -42,10 +44,12 @@ you can simply run:
4244
```shell
4345
./run_fuzzing.sh
4446
```
45-
By default, our predefined data set is run with a blackbox monitor.
47+
By default, our predefined data set is run on the device with a blackbox monitor.
4648

4749
For more control, the following arguments are available:
4850

51+
- `--run_mode`: `corpus_test` runs the given corpus and `fuzzing` starts mutation-
52+
based fuzzing.
4953
- `--corpus_path`: The path to the corpus containing the test files.
5054
- `--monitor`: The monitor type to be used. All supported options are:
5155
- `blackbox`: General blackbox monitor.
@@ -55,6 +59,18 @@ For more control, the following arguments are available:
5559
- `--port`: If a GDB monitor is selected, the port to listen on for GDB remote
5660
connection.
5761

62+
In the fuzzing mode, more options are supported:
63+
64+
- `--fuzzing_mode`: The type of inputs to be fuzzed. All supported options are:
65+
- `cbor_make_credential`
66+
- `cbor_get_assertion`
67+
- `cbor_client_pin`
68+
- `ctaphid_raw`
69+
- `--num_runs`: Number of inputs to be run. By default, the fuzzer will run indefinitely.
70+
- `--max_length`: Maximum length of an input. By default, there is no limit.
71+
- `--max_mutation_degree`: Maximum number of successive mutation operations to be
72+
applied. By default, the degree is 10.
73+
5874
## How to reproduce
5975

6076
The files causing a reported crash are saved to `corpus_tests/artifacts/` by

run_fuzzing.sh

+34-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ path=_
2525
corpus=corpus_tests/test_corpus/
2626
monitor=blackbox
2727
port=2331
28+
run_mode=corpus_test
29+
fuzzing_mode=ctaphid_raw
30+
num_runs=0
31+
max_length=0
32+
max_mutation_degree=10
2833

2934
# parse parameters
3035
for arg in "$@"
@@ -46,6 +51,26 @@ case $arg in
4651
port="${arg#*=}"
4752
shift
4853
;;
54+
--run_mode=*)
55+
run_mode="${arg#*=}"
56+
shift
57+
;;
58+
--fuzzing_mode=*)
59+
fuzzing_mode="${arg#*=}"
60+
shift
61+
;;
62+
--num_runs=*)
63+
num_runs="${arg#*=}"
64+
shift
65+
;;
66+
--max_length=*)
67+
max_length="${arg#*=}"
68+
shift
69+
;;
70+
--max_mutation_degree=*)
71+
max_mutation_degree="${arg#*=}"
72+
shift
73+
;;
4974
esac
5075
done
5176

@@ -54,5 +79,12 @@ then
5479
git submodule init
5580
git submodule update
5681
fi
57-
58-
bazel run //:corpus_test -- --token_path="$path" --corpus_path="$corpus" --monitor="$monitor" --port="$port"
82+
if [ "$run_mode" = "corpus_test" ]
83+
then
84+
bazel run //:corpus_test -- --token_path="$path" --corpus_path="$corpus" --monitor="$monitor" --port="$port"
85+
elif [ "$run_mode" = "fuzzing" ]
86+
then
87+
bazel run //:fuzzing -- --token_path="$path" --corpus_path="$corpus" --monitor="$monitor" --port="$port" --fuzzing_mode="$fuzzing_mode" --num_runs="$num_runs" --max_length="$max_length" --max_mutation_degree="$max_mutation_degree"
88+
else
89+
echo "Unsupported run mode."
90+
fi

0 commit comments

Comments
 (0)