This document describes the architecture of FUTAG (Fuzz target Automated Generator), a tool from ISP RAS for automated generation of fuzzing wrappers (fuzz targets) for C/C++ software libraries. Futag analyzes library source code via custom Clang/LLVM static analysis checkers and generates fuzz targets in LibFuzzer or AFLplusplus format.
+---------------------------------------------------------------+
| Layer 1: Build Infrastructure |
| build-llvm/prepare.sh --> build/build.sh |
| (download LLVM sources, patch Futag checkers, compile) |
+---------------------------------------------------------------+
|
futag-llvm/ toolchain
|
+---------------------------------------------------------------+
| Layer 2: C++ Clang Checkers |
| analyzers/checkers/ analyzers/clang-patches/ |
| (StaticAnalyzer plugins: extract function signatures, |
| types, and usage patterns from library source code) |
+---------------------------------------------------------------+
|
JSON analysis data
|
+---------------------------------------------------------------+
| Layer 3: Python Orchestration |
| futag-package/src/futag/ |
| |
| preprocessor.py --> generator.py --> fuzzer.py |
| (build & analyze) (gen targets) (run fuzzing) |
+---------------------------------------------------------------+
Located in build-llvm/ and build/, shell scripts that:
- Download LLVM sources (
build-llvm/prepare.sh) - Patch in Futag's checkers and Clang modifications
- Build the complete toolchain via CMake (
build/build.sh) - Optionally build AFLplusplus support (
futag-llvm/buildAFLplusplus.sh)
Note: This layer is only needed for the full pipeline workflow. The Python package can also work with pre-built analysis JSON and system-installed clang, or in generation-only mode. See Usage Modes below.
Library Futag LLVM Python Package
Source Code Toolchain (futag)
| | |
v v |
+----------+ +-------------+ |
| .c / .h |--->| scan-build | |
| files | | (checkers) | |
+----------+ +------+------+ |
| |
JSON analysis |
data files |
| v
| +-------------------+
+----------->| preprocessor.py |
| Builder.analyze() |
+--------+----------+
|
futag-analysis-result.json
|
v
+-------------------+
| generator.py |
| gen_targets() |
+--------+----------+
|
.c / .cpp fuzz targets
|
v
+-------------------+
| generator.py |
| compile_targets() |
+--------+----------+
|
instrumented binaries
|
v
+-------------------+
| fuzzer.py |
| Fuzzer.fuzz() |
+--------+----------+
|
v
crashes / coverage
Located in analyzers/checkers/ and analyzers/clang-patches/, these are static analysis plugins that
run inside Clang's StaticAnalyzer framework. They extract function signatures, type
information, and usage patterns from the target library's source code and serialize
the results as JSON.
For detailed documentation, see docs/checkers.md.
Located in futag-package/src/futag/, this layer provides the user-facing
Python API that drives the full pipeline:
- preprocessor.py --
Builderbuilds and analyzes target libraries;ConsumerBuilderhandles library+consumer pairs - generator.py --
Generatorproduces fuzz targets from analysis JSON;ContextGeneratoruses consumer usage contexts - fuzzer.py --
BaseFuzzer,Fuzzer, andNatchFuzzerexecute generated targets with configurable timeouts, memory limits, and sanitizers - sysmsg.py -- Constants and error messages (LIBFUZZER, AFLPLUSPLUS engine identifiers, paths)
For detailed documentation, see docs/generators.md and docs/python-api.md.
The Python package supports three usage modes via ToolchainConfig:
| Mode | Requires | Use case |
|---|---|---|
| Full pipeline | futag-llvm toolchain | First-time setup, complete workflow |
| Pre-built JSON + system clang | Any clang + analysis JSON | CodeQL or other backend, CI/CD |
| Generation only | Just the analysis JSON file | Produce source files, compile elsewhere |
from futag.toolchain import ToolchainConfig
# Mode 1: Full pipeline
tc = ToolchainConfig.from_futag_llvm(FUTAG_PATH)
generator = Generator(library_root, toolchain=tc)
# Mode 2: Pre-built JSON + system clang
tc = ToolchainConfig.from_system()
generator = Generator(library_root=lib_root, json_file="analysis.json", toolchain=tc)
# Mode 3: Generation only (no compiler needed)
generator = Generator(library_root=lib_root, json_file="analysis.json")
generator.gen_targets() # produces .c/.cpp source filesThe JSON interface between analysis backends and generators is formally specified in analysis-schema.json. For instructions on producing compatible JSON from alternative tools, see analysis-backend.md.
| Component | Location | Documentation |
|---|---|---|
| Clang Checkers | analyzers/checkers/, analyzers/clang-patches/ |
docs/checkers.md |
| Generator Classes | futag-package/src/futag/ |
docs/generators.md |
| Python API | futag-package/ |
docs/python-api.md |
| Build Scripts | build-llvm/, build/ |
README.en.md |
| JSON Schema | docs/analysis-schema.json |
docs/analysis-backend.md |
Futag/
analyzers/ # C++ analysis layer
checkers/ # Clang StaticAnalyzer checker sources
clang-patches/ # Clang modifications for Futag
build-llvm/ # Scripts to download and patch LLVM sources
docs/ # Detailed documentation
checkers.md # Clang checker documentation
generators.md # Generator class documentation
python-api.md # Python API reference
examples/ # Example scripts and configurations
futag-package/ # Python package (pip-installable)
src/futag/ # Core Python modules
tests/ # Unit tests
integration-tests/ # Dockerized tests
build-test/ # Build validation (Ubuntu 20.04/22.04/24.04, Alt 11/12)
libraries-test/ # End-to-end tests against real libraries
package-test/ # Python package tests
scripts/ # Standalone utility scripts
vendors/
json/ # nlohmann/json (C++ JSON library for checkers)
workshop/ # Library-specific tutorials
Futag supports multiple LLVM versions: 14, 18, and 19.
The project maintains version-specific copies of source files using a naming convention with version suffixes:
| Base File | LLVM 14 | LLVM 18 |
|---|---|---|
FutagAnalyzer.cpp |
FutagAnalyzer14.cpp |
FutagAnalyzer18.cpp |
ASTMatchFinder.cpp |
ASTMatchFinder14.cpp |
ASTMatchFinder18.cpp |
CMakeLists.txt |
CMakeLists14.txt |
CMakeLists18.txt |
Checkers.td |
Checkers14.td |
Checkers18.td |
The build script (build/build.sh) detects or accepts the target LLVM version and
selects the correct version-specific files during compilation.
When adding support for a new LLVM version (e.g., 19):
- Create version-specific source files (e.g.,
FutagAnalyzer19.cpp) - Create a version-specific
CMakeLists19.txt - Update
Checkers.tdwith a version-specific copy - Update
build/build.shversion detection logic
The base (unsuffixed) file should always match the latest supported LLVM version.
For build instructions and setup, see README.en.md.
For a complete workflow example, see scripts/template-script.py and the
workshop/ directory for library-specific tutorials.