Repository navigation
Add fuzzing for the signed-file parsers - #69
Open
jqnatividad wants to merge 4 commits into
Open
jqnatividad wants to merge 4 commits into
jqnatividad wants to merge 4 commits into
Conversation
Three libFuzzer targets for the code that reads untrusted signed files: * `zip`: verify_zip and copy_and_unsign_zip * `tar`: verify_tar and copy_and_unsign_tar * `signatures`: read_signatures (the signature block header) Seeds in fuzz/seeds/ are real signed and unsigned files, signed with the fixed key in fuzz_targets/common.rs, so the fuzzer starts from valid structure and reaches the signature-matching code. The crate has its own [workspace] and stays out of normal builds and CI. 10 minutes per target (~300M signatures / 9M tar / 4M zip runs) found no crashes, panics, OOMs or timeouts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One matrix job per target on nightly, starting from the committed seeds. Crash inputs are uploaded as artifacts when a job fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fuzzing is random, so a 60-second run can hit a pre-existing bug and turn an unrelated PR red. Run it from a separate workflow only when api/, fuzz/, the workspace Cargo.toml (dependency bumps change parser behavior) or the workflow itself change, plus weekly and on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prebuilt cargo-fuzz from taiki-e/install-action is a musl binary
and defaults to x86_64-unknown-linux-musl, which has no
AddressSanitizer support ("sanitizer is incompatible with statically
linked libc"). Pass the host triple from `rustc -vV` explicitly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds cargo-fuzz targets for the code that reads untrusted signed files, plus a short CI job that runs them.
Targets (
fuzz/fuzz_targets/):zip:verify_zipandcopy_and_unsign_ziptar:verify_tarandcopy_and_unsign_tar, including the gzip-tail and base64 signature blocksignatures:read_signatures, the signature block headerSeeds (
fuzz/seeds/): small real signed and unsigned.zip/.tar.gzfiles. They're signed with the fixed key infuzz_targets/common.rs, so the fuzzer starts from valid files and reaches the signature-matching code, not just the early rejections.Isolation:
fuzz/has its own[workspace], so normal builds,cargo fmt --all,clippy --workspaceandcargo sort --workspaceare unaffected and don't need nightly or libFuzzer. Run instructions are a comment at the top offuzz/Cargo.toml.corpus/andartifacts/are gitignored.CI: a separate
Fuzzworkflow (.github/workflows/fuzz.yml), with one matrix job per target on nightly. Each runs for 60 seconds from the seeds, and crash inputs are uploaded as artifacts if a job fails.Fuzzing is random, so any run can hit a bug that has been in the code all along. To keep that from turning unrelated PRs red, the workflow runs only when something that affects the parsers changes:
mainthat touchapi/**,fuzz/**, the workspaceCargo.toml(dependency bumps like zip or ed25519-dalek change parser behavior) or the workflow itself,workflow_dispatch).ci.ymlis unchanged. If you'd prefer it to run only on the schedule, drop thepush/pull_requesttriggers. I'd also suggest not making it a required check.Results
10 minutes per target locally, no crashes, panics, OOMs or timeouts:
Coverage had levelled off. That matches the code: parser allocations are capped at
BUF_LIMIT(64 KiB) before allocating, and offset math uses checked arithmetic.Testing
corpus/) works with the job'smkdir -p.cargo +nightly fmt --check,cargo +nightly clippyandtyposare clean forfuzz/.actionlintis clean for both workflows.zipsign-apiandzipsign.🤖 Generated with Claude Code