This crate tests MastForest deserialization and validation against bad inputs.
- Rust nightly toolchain
- cargo-fuzz:
cargo install cargo-fuzz
List all fuzz targets:
cargo +nightly fuzz list --fuzz-dir miden-core-fuzzRun all targets (5 minutes each):
make fuzz-allmast_forest_deserialize — Tests MastForest::read_from_bytes with arbitrary bytes.
cargo +nightly fuzz run mast_forest_deserialize --fuzz-dir miden-core-fuzzmast_forest_validate — Tests the full untrusted pipeline: deserialize then validate.
cargo +nightly fuzz run mast_forest_validate --fuzz-dir miden-core-fuzzThese fuzz internal structures through the MastForest deserialization path:
basic_block_data — Operation batches (indptr, padding, group data).
cargo +nightly fuzz run basic_block_data --fuzz-dir miden-core-fuzzdebug_info — Decorators, string table, CSR structures, error codes.
cargo +nightly fuzz run debug_info --fuzz-dir miden-core-fuzzmast_node_info — Node type discriminants and digests (40-byte fixed structure).
cargo +nightly fuzz run mast_node_info --fuzz-dir miden-core-fuzzGenerate seed files from valid serializations:
make fuzz-seedsSeeds go to miden-core-fuzz/corpus/<target-name>/.
Generate coverage report:
make fuzz-coverageThis runs cargo fuzz coverage for the main targets and outputs coverage data to miden-core-fuzz/coverage/.
Crash-inducing inputs go to miden-core-fuzz/artifacts/<target-name>/. To reproduce:
cargo +nightly fuzz run <target-name> --fuzz-dir miden-core-fuzz artifacts/<target-name>/crash-XXXExample:
cargo +nightly fuzz run mast_forest_deserialize --fuzz-dir miden-core-fuzz artifacts/mast_forest_deserialize/crash-da39a3ee5e6b4b0dWhere we expect malicious inputs to cause problems:
- Header parsing (magic, flags, version)
- Node count bounds (rejection of excessive allocations)
- Procedure roots deserialization
- Basic block data (operation batches, padding, groups)
- MastNodeInfo (type discriminants, child IDs, digests)
- DebugInfo (decorators, strings, CSR structures)
- Hash verification in validation
- No panics — Deserialization never panics on any input
- No crashes — No undefined behavior, buffer overflows, or memory corruption
- Resource limits — Excessive allocations rejected early
- Validation completeness —
UntrustedMastForest::validate()catches all invalid forests