Repository navigation
Fuzzing and Testing
Run the full suite:
cargo test --lockedTests live inline in src/ modules and cover: header parsing, section/segment decoding, string escaping, mitigation analysis (PIE/NX/RELRO/canary), dynamic-table decoding — including a stripped ELF fixture with no section headers (dynamic table recovered from PT_DYNAMIC), and rejection of malformed inputs (out-of-bounds tables, oversized strings, truncated files).
The ELF parser is fuzzed with cargo-fuzz:
cargo install cargo-fuzz --locked
cargo fuzz run parse_elf -- -max_total_time=300The target (fuzz/fuzz_targets/parse_elf.rs) feeds arbitrary bytes straight to binary_inspector::elf::parse and asserts nothing except that the parser never panics:
fuzz_target!(|data: &[u8]| {
let _ = binary_inspector::elf::parse(data, data.len() as u64);
});.github/workflows/fuzz.yml runs weekly (Sundays 02:00 UTC) and on demand:
- Installs cargo-fuzz (install failure fails the job — no swallowing)
- Runs 60 seconds of fuzzing; any crash fails the job (no
|| true) - Pins nightly toolchain and all actions to commit SHAs
Because parsing is panic-free by design, a crash found by fuzzing is treated as a high-severity parser bug: fix it, then add a malformed-input regression test reproducing it (see Contributing).
For every parser bug:
- Reduce the crashing input to the smallest byte pattern.
- Add a
#[test]in the relevant module that feeds it toparse(or the specific helper) and asserts the error/expected result. - Confirm the test fails against the unfixed code, then passes after the fix.
Installation