Name Date Size #Lines LOC

..--

CMakeLists.txtH A D19-Sep-20232.8 KiB8370

DockerfileH A D04-May-2024634 1715

MakefileH A D04-May-20242.9 KiB9167

READMEH A D19-Sep-20231.9 KiB4437

build-coverageH A D19-Sep-20231.1 KiB3520

clock.cH A D19-Sep-20231.8 KiB8151

dummy.hH A D19-Sep-20237.5 KiB183165

export.gnuH A D04-May-20246.9 KiB284283

functions.txtH A D04-May-202479.6 KiB950907

fuzz_assert.cH A D04-May-202412.9 KiB533412

fuzz_bio.cH A D19-Sep-202310.1 KiB443333

fuzz_cred.cH A D19-Sep-202312.9 KiB483394

fuzz_credman.cH A D19-Sep-20239.3 KiB408313

fuzz_hid.cH A D19-Sep-20235.9 KiB240188

fuzz_largeblob.cH A D19-Sep-20235.7 KiB273201

fuzz_mgmt.cH A D19-Sep-202312.2 KiB529433

fuzz_netlink.cH A D19-Sep-20233.3 KiB165122

fuzz_pcsc.cH A D19-Sep-20236.2 KiB270206

libfuzzer.cH A D19-Sep-20234.6 KiB231179

mutator_aux.cH A D19-Sep-20235.5 KiB333256

mutator_aux.hH A D19-Sep-20232.9 KiB11272

pcsc.cH A D19-Sep-20233.9 KiB154118

preload-fuzz.cH A D19-Sep-20231.9 KiB10677

preload-snoop.cH A D19-Sep-20234.1 KiB219167

prng.cH A D07-Oct-20213.9 KiB11451

report.tgzHD04-May-2024353.5 KiB

summary.txtH A D04-May-20249.5 KiB6563

udev.cH A D19-Sep-20236.6 KiB271220

uniform_random.cH A D07-Oct-20211.8 KiB5818

wiredata_fido2.hH A D19-Sep-202333.8 KiB709681

wiredata_u2f.hH A D19-Sep-20237.2 KiB154142

wrap.cH A D19-Sep-20239.1 KiB701595

wrapped.symH A D19-Sep-20231.7 KiB103102

README

1libfido2 can be fuzzed using AFL or libFuzzer, with or without
2ASAN/MSAN/UBSAN.
3
4AFL is more convenient when fuzzing the path from the authenticator to
5libfido2 in an existing application. To do so, use preload-snoop.c with a real
6authenticator to obtain an initial corpus, rebuild libfido2 with -DFUZZ=ON, and
7use preload-fuzz.c to read device data from stdin.
8
9libFuzzer is better suited for bespoke fuzzers; see fuzz_cred.c, fuzz_credman.c,
10fuzz_assert.c, fuzz_hid.c, and fuzz_mgmt.c for examples. To build these
11harnesses, use -DCMAKE_C_FLAGS=-fsanitize=fuzzer-no-link
12-DFUZZ_LDFLAGS=-fsanitize=fuzzer -DFUZZ=ON.
13
14If -DFUZZ=ON is enabled, symbols listed in wrapped.sym are wrapped in the
15resulting shared object. The wrapper functions simulate failure according to a
16deterministic RNG and probabilities defined in wrap.c. Harnesses wishing to
17use this functionality should call prng_init() with a seed obtained from the
18corpus. To mutate only the seed part of a libFuzzer harness's corpora,
19use '-reduce_inputs=0 --fido-mutate=seed'.
20
21To run under ASAN/MSAN/UBSAN, libfido2 needs to be linked against flavours of
22libcbor and OpenSSL built with the respective sanitiser. In order to keep
23memory utilisation at a manageable level, you can either enforce limits at
24the OS level (e.g. cgroups on Linux), or patch libcbor with the diff below.
25N.B., the patch below is relative to libcbor 0.10.1.
26
27diff --git src/cbor/internal/memory_utils.c src/cbor/internal/memory_utils.c
28index bbea63c..3f7c9af 100644
29--- src/cbor/internal/memory_utils.c
30+++ src/cbor/internal/memory_utils.c
31@@ -41,7 +41,11 @@ size_t _cbor_safe_signaling_add(size_t a, size_t b) {
32
33 void* _cbor_alloc_multiple(size_t item_size, size_t item_count) {
34   if (_cbor_safe_to_multiply(item_size, item_count)) {
35-    return _cbor_malloc(item_size * item_count);
36+    if (item_count > 1000) {
37+      return NULL;
38+    } else {
39+      return _cbor_malloc(item_size * item_count);
40+    }
41   } else {
42     return NULL;
43   }
44