You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -57,7 +57,7 @@ The AFL++ fuzzer has many dependencies, such as LLVM, Python, and Rust. We recom
57
57
</li>
58
58
</ul>
59
59
</td>
60
-
<td>As of writing for version 4.09c of the image Clang 14 & GCC 11</td>
60
+
<td>As of writing for version 4.35c of the image Clang 19 & GCC 11</td>
61
61
</tr>
62
62
<tr>
63
63
<td>Docker (from source)</td>
@@ -88,7 +88,7 @@ The AFL++ fuzzer has many dependencies, such as LLVM, Python, and Rust. We recom
88
88
</td>
89
89
<td>
90
90
Adjustable by setting the environment variable
91
-
<code>LLVM_CONFIG</code> for example to <code>llvm-config-14</code>.
91
+
<code>LLVM_CONFIG</code> for example to <code>llvm-config-18</code>.
92
92
</td>
93
93
</tr>
94
94
</table>
@@ -100,12 +100,14 @@ The AFL++ fuzzer has many dependencies, such as LLVM, Python, and Rust. We recom
100
100
If you run a recent Debian or Ubuntu version, the packaged version in the official Ubuntu repositories is an easy choice. At the time of writing, Ubuntu 23.10 packages AFL++ 4.08c and Debian 12 version 4.04c. Note that this will limit you to the Clang version supported by the packaged AFL++ version.
101
101
102
102
103
+
Note: Check which Clang version AFL++ uses on your distribution before installing `lld`. Run `afl-cc --version` to verify, then install the matching `lld` version (e.g., `lld-17`).
104
+
103
105
```shell
104
-
apt install afl++ lld-14
106
+
apt install afl++ lld-17
105
107
```
106
108
107
109
108
-
Installing the `lld` package is required for the optional LTO mode that we will describe later. Depending on the Clang version AFL++ uses on your Linux distributions, you may want to install a specific version of `lld` like `lld-16`. Verify the output of `afl-cc --version`.
110
+
Installing the `lld` package is required for the optional LTO mode that we will describe later. Depending on the Clang version AFL++ uses on your Linux distributions, you may want to install a specific version of `lld` like `lld-17`. Verify the output of `afl-cc --version`.
After the reboot check whether the changes performed by `afl-persistent-config` were correctly applied by executing `cat``/proc/cmdline`. The output should include `mitigations=off`. If not, then the grub bootloader was configured incorrectly: Verify the configuration in the file `/etc/default/grub` and the directory `/etc/default/grub.d/`. If any of the configuration files incorrectly overwrites `GRUB_CMDLINE_LINUX_DEFAULT` then mitigations are potentially not applied. This is for example true for cloud environments that use [cloudinit](https://cloud-init.io/).
203
+
After the reboot check whether the changes performed by `afl-persistent-config` were correctly applied by executing `cat``/proc/cmdline`. The output should include `mitigations=off`. If not, then the grub bootloader was configured incorrectly: Verify the configuration in the file `/etc/default/grub` and the directory `/etc/default/grub.d/`. If any of the configuration files incorrectly overwrites `GRUB_CMDLINE_LINUX_DEFAULT` then mitigations are potentially not applied. This is for example true for cloud environments that use [cloud-init](https://cloudinit.readthedocs.io/).
202
204
203
205
204
206
{{< hint danger >}}
@@ -209,50 +211,48 @@ After the reboot check whether the changes performed by `afl-persistent-config`
209
211
210
212
Creating a binary that fuzzes the SUT is straightforward. The resulting binary will use the harness and the AFL++ runtime.
211
213
212
-
The AFL++ fuzzer offers multiple compilation modes, including [LTO](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.lto.md), [LLVM](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.llvm.md), [GCC](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.gcc_plugin.md), and a legacy Clang mode. Refer to the linked documentation for more information about each. In order to decide for one, refer to the following figure:
214
+
The AFL++ fuzzer offers multiple compilation modes, including [LTO](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.lto.md), [LLVM](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.llvm.md), and [GCC](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.gcc_plugin.md). Refer to the linked documentation for more information about each. In order to decide for one, refer to the following figure:
Depending on the mode you choose, use a different compilation command: `afl-clang-lto`, `afl-clang-fast`, `afl-gcc`, or `afl-clang`, respectively. The C++ versions are also available by appending `++`, which gives, e.g., `afl-clang-lto++`. The LTO mode is recommended because it features a better and faster instrumentation of the SUT. However, this depends on your project whether LTO mode works. Give it a try and fall back to the other modes if compilation fails.
220
+
Depending on the mode you choose, use a different compilation command: `afl-clang-lto`, `afl-clang-fast`, or `afl-gcc`, respectively. The C++ versions are also available by appending `++`, which gives, e.g., `afl-clang-lto++`. The LTO mode is recommended because it features a better and faster instrumentation of the SUT. However, this depends on your project whether LTO mode works. Give it a try and fall back to the other modes if compilation fails.
219
221
220
222
If you use the Clang compiler and want to use the LLVM mode, then the following command produces a binary `fuzzer`. Essentially, we are replacing the call to `clang++` with `afl-clang-fast++`. We are reusing the `harness.cc` and `main.cc` from the [introduction]({{% relref "fuzzing#introduction-to-fuzzers" %}})
If your project depends on the GCC compiler, then consider using the [gcc_plugin](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.gcc_plugin.md):
PRO TIP: The GCC version of your system and the GCC version that was used to compile the AFL++ GCC plugin must match. If they do not match (e.g., if you upgrade GCC), then you will get an error when using the GCC support.
253
253
{{< /hint >}}
254
254
255
-
We also enable debug symbols using `-g` and set the optimization level to `-O2`, which is a reasonable optimization level for fuzzing because it is likely the level used during production.
255
+
We set the optimization level to `-O2`, which is a reasonable optimization level for fuzzing because it is likely the level used during production. Note that `-g` is not necessary, it is added by default by the AFL++ compilers.
256
256
257
257
Many things are happening behind the scenes when using AFL++:
258
258
@@ -270,7 +270,7 @@ To launch a fuzzing campaign, first create a seeds directory. This represents th
270
270
271
271
```shell
272
272
mkdir seeds
273
-
echo"a"> seeds/minimal_seed
273
+
echo"aaaa"> seeds/minimal_seed
274
274
```
275
275
276
276
Finally, we can launch the campaign.
@@ -280,10 +280,10 @@ Finally, we can launch the campaign.
280
280
```
281
281
282
282
{{< hint info >}}
283
-
PRO TIP: In order to demonstrate how to set environment variables with the afl++ script, try setting the environment variable AFL_PIZZA_MODE to 1 if you enjoy pineapple pizza:
284
-
283
+
PRO TIP: In order to demonstrate how to set environment variables with the afl++ script, try setting the environment variable AFL_FAST_CAL to 1 to speed up the initial calibration phase:
284
+
285
285
```shell
286
-
./afl++ <host/docker>AFL_PIZZA_MODE=1 afl-fuzz -i seeds -o out -- ./fuzz
286
+
./afl++ <host/docker>AFL_FAST_CAL=1 afl-fuzz -i seeds -o out -- ./fuzz
287
287
```
288
288
{{< /hint >}}
289
289
@@ -357,7 +357,7 @@ Refer to the help page for more information about libFuzzer-compatible binaries
357
357
The AFL++ fuzzer offers many options. The following options can be most useful with the `afl-fuzz` tool.
358
358
359
359
***-G 4000** The maximum length of the test input. By default, AFL++ uses 1048576 bytes. Setting this at least a few times higher than the minimal input size is advised. As a rule of thumb, we recommend finding a minimal realistic input and then doubling that. Note that larger input sizes lead to longer execution times and do not necessarily lead to a larger input space being explored.
360
-
***-t 10000** AFL++ aborts the execution of a test case after n milliseconds. It makes sense to set this to something reasonably low. The goal is also to find inputs that cause the SUT to hang for an unreasonably long amount of time. For example, parsing a reasonable-sized PNG image should not take longer than a few hundred milliseconds. So setting this to a few seconds is usually enough not to get false positives.
360
+
***-t 1000** AFL++ aborts the execution of a test case after n milliseconds (default is 1000ms). It makes sense to set this to something reasonably low. The goal is also to find inputs that cause the SUT to hang for an unreasonably long amount of time. For example, parsing a reasonable-sized PNG image should not take longer than a few hundred milliseconds. So setting this to a few seconds is usually enough not to get false positives.
361
361
***-m 1000** The memory limit for test cases in megabytes. By default, this is set to 0, which means no limit. This should be set to a reasonable value like 1000. If this is set too low then you will see false positives, because occasionally test cases may take just slightly longer than usual (e.g., because of system load).
362
362
***-x ./dict.dict** Specifies a dictionary file that guides the fuzzer and allows the fuzzer to discover interesting test cases more quickly. For more details about this, see [Fuzzing dictionary]({{% relref 02-dictionary %}}).
363
363
@@ -423,7 +423,7 @@ The example above reads now from standard input. It aborts for the input "abc".
./afl++ <host/docker> afl-fuzz -i seeds -o out -- ./fuzz_arg
663
663
```
664
664
@@ -798,6 +798,25 @@ kill $(jobs -p)
798
798
More information and advanced use cases can be found [here](https://aflplus.plus/docs/parallel_fuzzing/) and [here](https://aflplus.plus/docs/fuzzing_in_depth/#c-using-multiple-cores).
799
799
800
800
801
+
## CMPLOG {#cmplog}
802
+
803
+
CMPLOG/RedQueen is the best path constraint solving mechanism available in any fuzzer.
804
+
To enable it, the fuzz target needs to be instrumented for it.
805
+
Before building the fuzzing target set the environment variable:
806
+
807
+
```shell
808
+
./afl++ <host/docker> AFL_LLVM_CMPLOG=1 make
809
+
```
810
+
811
+
No special action is needed for compiling and linking the harness.
812
+
813
+
To run a fuzzer instance with a CMPLOG instrumented fuzzing target, add `-c0` to the command line arguments:
ASan helps detect memory errors that may otherwise go unnoticed. For instance, the following heap buffer overflow is usually not detectable without ASan.
@@ -829,7 +848,7 @@ To enable AddressSanitizer when using AFL++, set the environment variable `AFL_U
829
848
For example, to use ASan to find the bug in main_asan.cc, first compile using the corresponding flags:
When running the fuzzer, the above heap-buffer overflow will be discovered by the fuzzer. The settable memory limit via the `-m` flag is not supported with ASan because ASan allocates a huge amount of virtual memory: 20TB, which exceeds any reasonable memory limit.
0 commit comments