Fuzzing

The project includes AFL++ fuzz harnesses for all input parsing surfaces.

Targets

TargetAttack SurfaceInput
fuzz_v4l2_querycapVIDIOC_QUERYCAP response (104 bytes)Kernel ioctl struct
fuzz_v4l2_controlsVIDIOC_QUERYCTRL response (68 bytes)Kernel ioctl struct
fuzz_ipc_commandDaemonCommand JSONUnix socket input
fuzz_profile_parseProfile TOMLUser-writable files
fuzz_format_fourccPixel format + video modeUSB descriptor data
fuzz_firmware_bcdProduct ID + BCD versionUSB descriptor data

Running

# Install AFL++ and cargo-afl
sudo apt-get install afl++
cargo install cargo-afl

# Build instrumented targets
cd fuzz/targets
cargo afl build --release

# Generate seed corpus
cd ../..
python3 fuzz/gen_corpus.py

# Run a single fuzzer
cargo afl fuzz -i fuzz/corpus/ipc_parse -o fuzz/findings/ipc_command \
    -- fuzz/targets/target/release/fuzz_ipc_command

# Run all fuzzers in parallel
for target in v4l2_querycap ipc_command profile_parse format_fourcc firmware_bcd; do
    corpus="fuzz/corpus/v4l2_parse"
    [ "$target" = "ipc_command" ] && corpus="fuzz/corpus/ipc_parse"
    [ "$target" = "profile_parse" ] && corpus="fuzz/corpus/profile_parse"
    [ "$target" = "format_fourcc" ] && corpus="fuzz/corpus/usb_descriptor"
    [ "$target" = "firmware_bcd" ] && corpus="fuzz/corpus/usb_descriptor"
    timeout 120 cargo afl fuzz -i "$corpus" -o "fuzz/findings/$target" \
        -- "fuzz/targets/target/release/fuzz_$target" &
done
wait

Results

Initial fuzzing run (633,000+ executions across all targets):

TargetExecutionsExec/secCrashesStability
v4l2_querycap87,018725/s0100%
ipc_command309,5522,581/s0100%
profile_parse63,621530/s097.4%
format_fourcc86,538721/s0100%
firmware_bcd86,529721/s0100%

Zero crashes across all targets. Rust's type safety and bounds checking prevent the buffer overflow and integer overflow classes that AFL++ typically finds in C parsers.