# Introduction to VirtualBox security research

DevFeed: [Introduction to VirtualBox security research](<https://devfeed.tech/articles/introduction-to-virtualbox-security-research-92012.md>)

Original publisher: [Read original article](<https://blog.doyensec.com/2022/04/26/vbox-fuzzing.html>)

Published: 2022-04-25T22:00:00Z

Content type: tutorial

Language: en

Sources: [Doyensec](<https://devfeed.tech/sources/doyensec.md>)

Topics: [Oracle-VM-VirtualBox](<https://devfeed.tech/topics/vm-box.md>), [Security research](<https://devfeed.tech/topics/security-research.md>), [builds](<https://devfeed.tech/topics/builds.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [make](<https://devfeed.tech/topics/make.md>), [Linux](<https://devfeed.tech/topics/linux.md>)

Tags: [auditing](<https://devfeed.tech/tags/auditing.md>), [automation](<https://devfeed.tech/tags/automation.md>), [build](<https://devfeed.tech/tags/build.md>), [coverage](<https://devfeed.tech/tags/coverage.md>), [device](<https://devfeed.tech/tags/device.md>), [doyensec](<https://devfeed.tech/tags/doyensec.md>), [doyensecurity](<https://devfeed.tech/tags/doyensecurity.md>), [driver](<https://devfeed.tech/tags/driver.md>), [drivers](<https://devfeed.tech/tags/drivers.md>), [exploit](<https://devfeed.tech/tags/exploit.md>), [fuzzing](<https://devfeed.tech/tags/fuzzing.md>), [hacking](<https://devfeed.tech/tags/hacking.md>), [harness](<https://devfeed.tech/tags/harness.md>), [infosec](<https://devfeed.tech/tags/infosec.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [network](<https://devfeed.tech/tags/network.md>), [offensive](<https://devfeed.tech/tags/offensive.md>), [pentest](<https://devfeed.tech/tags/pentest.md>), [pentester](<https://devfeed.tech/tags/pentester.md>), [research](<https://devfeed.tech/tags/research.md>), [reverse-engineering](<https://devfeed.tech/tags/reverse-engineering.md>), [security](<https://devfeed.tech/tags/security.md>), [security-research](<https://devfeed.tech/tags/security-research.md>), [virtualbox](<https://devfeed.tech/tags/virtualbox.md>), [vulnerability](<https://devfeed.tech/tags/vulnerability.md>)

## AI overview

The article gives a hands-on method for building a coverage-guided AFL++ harness for VirtualBox 6.1.30's PCNet emulated network driver. It uses separate debug, fuzzing, and coverage builds; the debug build supplies logging, while patched release builds add AFL instrumentation and coverage mapping. The harness retrieves the VM through VirtualBox's `IMachineDebugger` API, locates the PCNet device, and feeds inputs to its I/O and MMIO handlers. LLVM's Fuzzed Data Provider constrains generated values, and a patched `PDMDevHlp_PhysRead` supplies fuzz data to device reads. The article reports over 10,000 executions per second but describes poor stability: driver state is not fully reset and whole-VM activity adds hard-to-control behavior. Suggested mitigations include narrowing coverage to short fuzzing blocks, disabling unrelated devices, and using AFL debug mode with core dumps to inspect crashes. LTO-based remedies did not work in the described setup.

## Source excerpt

Introduction This article introduces VirtualBox research and explains how to build a coverage-based fuzzer, focusing on the emulated network device drivers. In the examples below, we explain how to create a harness for the non-default network device driver PCNet. The example can be readily adjusted for a different network driver or even different device driver components. We are aware that there are excellent resources related to this topic - see [1], [2]. However, these cover the fuzzing process from a high-level perspective or omit some important technical details. Our goal is to present all the necessary steps and code required to instrument and debug the latest stable version of VirtualBox (6.1.30 at the time of writing). As the SVN version is out-of-sync, we download the tarball instead. In our setup, we use Ubuntu 20.04.3 LTS. As the VT-x/AMD-V feature is not fully supported for VirtualBox, we use a native host. When using a MacBook, the following guide enables a Linux installation to an external SSD. VirtualBox uses the kBuild framework for building. As mentioned on their page, only a few (0.5) people on our planet understand it, but editing makefiles should be straightforward. As we will see later, after commenting out hardware-specific components, that's indeed true. kmk is a kBuild alternative for the make subsystem. It allows creating debug or release builds, depending on the supplied arguments. The debug build provides a robust logging mechanism, which we will describe next. Note that in this article, we will use three different builds. The remaining two release builds are for fuzzing and coverage reporting. Because they involve modifying the source code, we use a separate directory for every instance. Debug Build The build instructions for Linux are described here. After installing all required dependencies, it's enough to run the following commands: $ ./configure --disable-hardening --disable-docs $ source ./env.sh && kmk KBUILD_TYPE=debug If successfu