This repository contains a coverage-guided fuzzing framework for Deep Neural Network image classifiers. It identifies corner case inputs from existing limited test inputs by mutating seed images, keeps the most useful inputs in a queue, and measures how well the resulting data explores a model's internal behavior using various coverage criteria.
In practice, the codebase helps you:
- Build an initial seed set for a model and dataset.
- Construct a model profile that the fuzzer uses to guide mutations.
- Run coverage-guided fuzzing to discover new corner cases.
- Evaluate the generated data with latent-space and coverage-based metrics.
The repository currently supports MNIST, SVHN, GTSRB, and CIFAR-100 datasets but can be easily extended to other datasets.
- main.py runs the fuzzing loop.
- evaluation.py evaluates DNN performance on generated or stored datasets.
- config/ contains dataset/model configuration files.
- fuzzer/ contains the seed construction, profile construction, coverage tracking, mutation loop, and queue logic.
- metrics_utils/ and coverage_calculation/ contain the quality and coverage metric helpers.
The workflow is:
- Load a trained classifier and its matching configuration file.
- Build or load a model profile that describes coverage-relevant internal activations.
- Build or load an initial seed corpus.
- Run the fuzzer, which mutates seeds and keeps inputs that improve coverage or other selected criteria.
- Save the discovered inputs and crash/corner-case artifacts in the output directory.
The main script supports wide-range of structural and non-structural fuzzing criteria for evaluating DNNs. This includes various forms of Neuron Coverage - nc, kmnc, bknc, tknc, nbc, snac, and Non-stuctural latent-space based coverage criteria - lsc, dsc, mdsc, and lscd.
For a typical fuzzing run, start with a dataset-specific config file and a directory of seed images:
python main.py -i /path/to/seed_dir -o /path/to/output_dir -config_file config/cifar100.tomlIf you want the project to generate inputs for you, rebuild the seed corpus first:
python main.py -i /path/to/seed_dir -o /path/to/output_dir -config_file config/cifar100.toml -construct_seeds 1If the model profile is missing or outdated, rebuild it before fuzzing:
python main.py -i /path/to/seed_dir -o /path/to/output_dir -config_file config/cifar100.toml -construct_profile 1Create and activate a virtual environment, then install dependencies:
python -m venv .env
source .env/bin/activate
pip install -r requirements.txtIf you are on macOS, use requirements_mac.txt and follow the extra system-package notes in that file.
python main.py --helpPick one of the configuration files in config/ and point the fuzzer at an input seed directory and output directory:
python main.py \
-i /path/to/seed_dir \
-o /path/to/output_dir \
-config_file config/cifar100.tomlTo rebuild the seed corpus or the model profile, use the matching flags:
python main.py -i /path/to/seed_dir -o /path/to/output_dir -config_file config/cifar100.toml -construct_seeds 1
python main.py -i /path/to/seed_dir -o /path/to/output_dir -config_file config/cifar100.toml -construct_profile 1Use evaluation.py to score generated data or stored crash/corner-case inputs.
- Each run needs a trained model checkpoint, a matching config file, a model profile, and an initial seed set.
- Model checkpoints are expected in the location referenced by the selected config file.
- New architectures need implementations for
intermediate_outputsand seed-selection logic compatible with the fuzzer. - The project uses Git LFS for large binary artifacts such as
.pkl,.pth, and.ptfiles.
dataset/: dataset wrappers and preprocessing helpers.fuzzer/: the core fuzzing engine and queue management.coverage_calculation/: scripts for computing coverage and related metrics.metrics_utils/: metric utilities used during evaluation.models/: model definitions for supported architectures.mutation/: input mutation operators.plot_scripts/: analysis and plotting helpers.
If you change Python files, run isort and black before sending updates.
pip install isort black
isort path/to/file.py
black path/to/file.pyDue to the large size of our corner cases datasets used in our empirical study, we are sharing them via a cloud download link. Please download the necessary files using the following link: https://www.dropbox.com/scl/fi/a2dws2hjpf8qslqc2riqx/fuzzing_data_eq_samples.zip?rlkey=fy22mwm4c1j73rczq0ag4mgbp&st=thm1w4wy&dl=0