edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
fuzzriff: cargo-fuzz targets for ec-riff WAV and AVI readers
Goal: DONE.md shared gate 2, at least one cargo-fuzz target per untrusted parse entry point in ec-riff (WAV/RF64 reader, AVI reader). ec-riff writer and public API unchanged. Base sha: 78ec1905 (main at worktree creation).
What changed
crates/ec-riff/fuzz/: standalone cargo-fuzz crate (ec-riff-fuzz, own[workspace], path dep on ec-riff).wav_read:WavReader::new, then the metadata accessors, then a fresh reader drained withread_all_i32orread_all_f32.avi_read:AviReader::new,audio_streams,has_index,index_len, thennext_packetuntil error.avi_seek: 10-byte control prefix (after flag, stream number, u64 LE target), then the AVI; callsindexed_point,seek_to_stream_time, drains packets, rewinds, drains again.seed.sh: WAV fixtures fromfixtures/audio/*.wavplus an RF64 variant of each (20 seeds); five synthesised AVIs foravi_readandavi_seek(5 + 10 seeds). No.avifixtures exist in the repo..gitignore:target,corpus,artifacts,coverage.
crates/ec-riff/src/avi.rs(fixes, all minimal, all in read paths):read_bodyhelper: reads a declared chunk body throughtake()instead ofvec![0; size]. Used foridx1,indx, and the odml standard index. Fixes an OOM from anidx1size field of 0xC8000060 in a 2.5 KB file (found byavi_read).seek_to_stream_time:clampreplaced bymin/max(clamp panics when min > max on a movi list shorter than 8 bytes; found byavi_seek).seek_to_stream_time:movi_start + estimateis nowsaturating_add(overflow for a huge target; found byavi_seekafter the clamp fix, 2 further artifacts).queue_packets_in: depth parameter, refused pastMAX_REC_DEPTH(16). Nestedreclists recursed once per level, so 100 000 levels overflowed the stack. Found by reading the code, not by the fuzzer.parse_odml_standardandchunk_matches:offset + 8andoffset + 8 + sizeuse saturating arithmetic. Overflow for offsets near u64::MAX. Found by reading the code.- Clippy-only:
chunks_exact(16)toas_chunks::<16>()inparse_idx1_body; theOk(... ?)wrapper around the odmlcollectremoved.
crates/ec-riff/src/read.rs:chunks_exact(4)toas_chunks::<4>()inread_all_f32(clippy only).crates/ec-riff/tests/avi_fuzz_regressions.rs(new): five regression tests, each a hand-minimised inline AVI, not the fuzzer's artifact bytes:idx1_size_past_end_of_file_is_refusedseek_in_empty_movi_does_not_panicseek_to_huge_target_does_not_overflow(debug build panics without the fix, confirmed)deeply_nested_rec_lists_are_refused_not_recursedodml_index_offset_at_u64_max_does_not_overflow
Crashes found and fixed
avi_read: OOM,malloc(3355443296)from theidx1size field. Fixed byread_body.avi_seek: panicmin > maxinclamp(movi list shorter than 8 bytes). Fixed.avi_seek: panicattempt to add with overflowatavi.rs:211(huge target). Fixed withsaturating_add. Two artifacts (crash-766d26...,crash-87ddd2...) reproduced it; both pass after the fix.- Found by reading, not fuzzing: unbounded recursion on nested
reclists; odml/chunk offset overflow. Fixed, with regression tests.
Verify commands and results
Run from the worktree ~/.cache/wt/fuzzriff, on branch lane/fuzzriff.
scripts/remote-run.sh fuzzriff -- cargo clippy -p ec-riff --all-targets -- -D warnings: exit 0 (final run; ec-riff re-checked).scripts/remote-run.sh fuzzriff -- cargo test -p ec-riff --release: exit 0. 5 regression tests passed, 11 WAV tests passed, 0 doctests.cargo test -p ec-riff --test avi_fuzz_regressions(debug, overflow checks on): 5 passed. With the seek saturating_add reverted,seek_to_huge_target_does_not_overflowfails with the overflow panic.cargo +nightly fuzz build --fuzz-dir crates/ec-riff/fuzz(remote-run, host b): exit 0, all three targets built.- Smoke runs,
cargo +nightly fuzz run <t> --fuzz-dir crates/ec-riff/fuzz -- -max_total_time=120 -rss_limit_mb=3000 -timeout=10, final code:wav_read: exit 0, 7274910 runs in 121 s. (An earlier pre-fix run on host b: 734011 runs in 121 s.)avi_read: exit 0, 17918460 runs in 121 s.avi_seek: exit 0, 15320442 runs in 121 s.
- The smoke runs were local (cargo-fuzz with a separate target dir). The vps hosts were slot-busy, so remote-run fell back to local.
- Replays of the crash artifacts on the fixed code:
avi_readOOM artifact exit 0;avi_seekartifactscrash-9299668...,crash-766d26...,crash-87ddd2...exit 0.
Left open
- The gate asks for 1 CPU-hour per target. Only 120 s smoke runs were done, so the gate is not met.
- Corpus is seeded from fixtures and synthesised AVIs only. No minimised corpus, no coverage measured.
- The
recdepth fix and the overflow fixes inchunk_matchesandparse_odml_standardwere found by reading, not fuzzing; the fuzzer did not reach them in the smoke runs. - RF64 reads still return Unsupported (not a crash). The RF64 seed is only a read-path input.
crates/ec-riff/fuzz/Cargo.lockwas generated on the host and is not committed (same as fuzzaudio1).- The regression reproducers are hand-minimised inline constructions, not the fuzzer's artifact bytes.