This directory contains fuzzing tests for the EtchDNS DNS parsers using cargo-fuzz.
You need to have cargo-fuzz installed:
cargo install cargo-fuzzThe following fuzz targets are available:
validate_dns_packet- Tests thedns_parser::validate_dns_packetfunctionqname- Tests thedns_parser::qnamefunctionquery_type_class- Tests thedns_parser::query_type_classfunctionis_dnssec_requested- Tests thedns_parser::is_dnssec_requestedfunctionextract_edns_version- Tests thedns_parser::extract_edns_versionfunctionextract_client_ip- Tests EDNS Client Subnet IP extractioncreate_dns_response- Tests synthetic DNS response constructiondns_key_from_packet- Tests theDNSKey::from_packetfunctionip_range_from_cidr- TestsIpRange::from_cidrCIDR parsingip_validator_validate- TestsIpValidator::validate_ip_strrate_limiter_is_allowed- TestsRateLimiter::is_allowed
To run a specific fuzz target:
cargo fuzz run validate_dns_packet
cargo fuzz run qname
cargo fuzz run query_type_class
cargo fuzz run is_dnssec_requested
cargo fuzz run extract_edns_version
cargo fuzz run extract_client_ip
cargo fuzz run create_dns_response
cargo fuzz run dns_key_from_packet
cargo fuzz run ip_range_from_cidr
cargo fuzz run ip_validator_validate
cargo fuzz run rate_limiter_is_allowedEach fuzz target has its own corpus directory in fuzz/corpus/<target_name>/. The corpus contains initial valid DNS packets to help the fuzzer find interesting inputs.
The corpus is automatically generated when building the fuzz targets.
You can customize the fuzzing run with additional options:
# Run with a time limit (e.g., 60 seconds)
cargo fuzz run validate_dns_packet -- -max_total_time=60
# Run with a specific number of iterations
cargo fuzz run validate_dns_packet -- -runs=1000000
# Run with more detailed output
cargo fuzz run validate_dns_packet -- -vWhen a fuzzer finds a crash, it will save the input that caused the crash in fuzz/artifacts/<target_name>/. You can reproduce the crash with:
cargo fuzz run <target_name> <path_to_artifact>To add a new fuzz target:
- Add a new entry to
fuzz/Cargo.toml - Create a new file in
fuzz/fuzz_targets/ - Update the corpus generator in
fuzz/generate_corpus.rsif needed