Skip to content

Add cargo fuzz targets#6

Merged
shahan-khatchadourian-anchorage merged 4 commits into
solana-parser-add-arbitraryfrom
add-fuzz-targets
Mar 18, 2026
Merged

Add cargo fuzz targets#6
shahan-khatchadourian-anchorage merged 4 commits into
solana-parser-add-arbitraryfrom
add-fuzz-targets

Conversation

@shahan-khatchadourian-anchorage
Copy link
Copy Markdown

Summary

Adds three libFuzzer fuzz targets via cargo fuzz:

  • fuzz_idl_json — feeds arbitrary bytes as IDL JSON into decode_idl_data; exercises the JSON deserializer and IDL struct validation
  • fuzz_instruction_data — feeds arbitrary bytes as instruction data into parse_instruction_with_idl against a fixed known-good IDL; exercises discriminator matching and borsh decoding
  • fuzz_transaction — feeds arbitrary bytes as a base64-encoded transaction into parse_transaction; exercises the full transaction deserialization and dispatch path

Sits on top of #1 (proptest arb module).

Usage

# Run a specific target (Ctrl-C to stop)
cargo +nightly fuzz run fuzz_idl_json
cargo +nightly fuzz run fuzz_instruction_data
cargo +nightly fuzz run fuzz_transaction

Test plan

  • cargo +nightly fuzz build — all three targets compile clean

…tions

Three libFuzzer targets:
- fuzz_idl_json: arbitrary bytes as IDL JSON into decode_idl_data
- fuzz_instruction_data: arbitrary bytes as instruction data into parse_instruction_with_idl
- fuzz_transaction: arbitrary bytes as encoded transaction into parse_transaction

Run with: cargo +nightly fuzz run <target>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move proptest strategies from src/arb.rs into fuzz-core/src/proptest.rs
and add arbitrary::Arbitrary implementation for IDL types in
fuzz-core/src/arbitrary.rs (ArbIdl wrapper). This separates fuzz
infrastructure from the core library into a dedicated crate that can be
depended on by both libfuzzer targets and proptest consumers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded IDL with ArbIdl-based dynamic generation, fixing the
wrong discriminator bug where the hardcoded value didn't match the
Anchor-computed SHA256("global:transfer") discriminator. The fuzz target
now generates random IDL shapes and exercises parse_instruction_with_idl
across varying instruction schemas.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move fuzz_idl_parsing.rs and its proptest regressions here where the IDL
parsing code lives. Add embedded_idls_never_panic and
embedded_idls_valid_data_always_parses_ok tests that replace the
fuzz_all_idls.sh shell script with Rust test code iterating over all 13
embedded IDLs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shahan-khatchadourian-anchorage shahan-khatchadourian-anchorage added the bug Something isn't working label Mar 18, 2026
@shahan-khatchadourian-anchorage shahan-khatchadourian-anchorage merged commit b6a5e28 into solana-parser-add-arbitrary Mar 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant