Repository navigation
feat(fuzz): fuzz the FFI ingress boundary (input_entry_to_directive) - #1753
Merged
Merged
Conversation
The builder behind the component's entry.create/createBatch takes wire JSON from untrusted embedders and hand-validates it — dates, the account-name gate, cost-number arity, the BookedCost per-unit x units == total invariant — and none of that validation was fuzzed. New cargo-fuzz crate for rustledger-ffi-wasi with one target: arbitrary bytes driven through the REAL wire path (serde_json -> InputEntry -> input_entry_to_directive), asserting beyond no-panic that (1) any successfully converted directive carries only accounts the canonical lexer predicate accepts — a bypass would readmit the class #1739's gate blocks — and (2) conversion disposition is deterministic. Committed seeds (fuzz/seeds/, one JSON per InputEntry variant plus booked-pair and bad-account edges) document the wire format by example and are copied into the corpus before CI runs, so cold caches start with structural coverage. fuzz.yml gains a fuzz-ffi-ingress job cloned from fuzz-booking (max_len 4096 for JSON) and the dispatch target list gains fuzz_input_entry. Locally shaken: 9.65M executions over 120s, cov 6073, zero crashes, both invariants held. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
📊 Benchmark Results
vs main branch (2026-07-10)
What do these numbers mean?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds fuzz coverage for the rustledger-ffi-wasi JSON → InputEntry → input_entry_to_directive trust boundary, plus CI automation and a small seed corpus to bootstrap structural coverage. This strengthens robustness of the untrusted embedder ingress path, complementing existing fuzz targets for parser/query/booking.
Changes:
- Introduces a new
cargo-fuzzcrate andfuzz_input_entrytarget that exercises the real wire path and asserts key invariants (account-name gate + conversion disposition determinism). - Adds a committed seed corpus (
fuzz/seeds/fuzz_input_entry/) and a CI job (fuzz-ffi-ingress) that seeds the corpus on cold starts. - Extends the fuzz workflow dispatch options to include
fuzz_input_entry.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rustledger-ffi-wasi/fuzz/fuzz_targets/fuzz_input_entry.rs | New fuzz target for FFI ingress conversion + invariants. |
| crates/rustledger-ffi-wasi/fuzz/Cargo.toml | New standalone fuzz crate configuration for cargo-fuzz. |
| crates/rustledger-ffi-wasi/fuzz/Cargo.lock | Locked dependency graph for the fuzz crate. |
| crates/rustledger-ffi-wasi/fuzz/.gitignore | Ignores fuzz build outputs/corpus/artifacts. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/open.json | Seed JSON for InputEntry::Open. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/close.json | Seed JSON for InputEntry::Close. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/balance.json | Seed JSON for InputEntry::Balance. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/pad.json | Seed JSON for InputEntry::Pad. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/note.json | Seed JSON for InputEntry::Note. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/txn_per_unit.json | Seed JSON for a transaction with per-unit cost. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/txn_compound.json | Seed JSON for a transaction with compound cost. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/txn_booked_pair.json | Seed JSON for a transaction with booked per-unit-from-total cost. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/inconsistent_pair.json | Seed JSON for an intentionally inconsistent booked cost pair. |
| crates/rustledger-ffi-wasi/fuzz/seeds/fuzz_input_entry/bad_account.json | Seed JSON for an invalid account-name edge. |
| .github/workflows/fuzz.yml | Adds fuzz_input_entry dispatch option and a new CI job to run the new fuzzer and manage corpus/artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
- explicit 64 KiB input guard in the harness so resource usage is bounded regardless of runner flags; - fuzz.yml pull_request paths gain crates/rustledger-ffi-wasi/** (the new job now runs where the boundary changes) and the workflow file itself; - seeds for the six missing InputEntry variants (commodity, price, event, document, query, custom) so the "one per variant" comment is true — 16 seeds total, re-shaken 60s locally with zero findings. Co-Authored-By: Claude Fable 5 <[email protected]>
Merged
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.
What
New cargo-fuzz crate + CI job for the FFI ingress boundary — the last hand-written validation surface with no fuzz coverage.
Why
input_entry_to_directive(behind the component'sentry.create/createBatch) takes wire JSON from untrusted embedders and hand-validates it: date parsing, the account-name gate (#1739), cost-number arity, and theBookedCostper_unit × units == totalinvariant (try_new). The parser, query, and booking layers all have fuzz targets; this trust boundary had none.How
serde_json→InputEntry→input_entry_to_directive, so serde's corners (deny_unknown_fields, defaults, tagged enums) are exercised exactly as embedders hit them.Okdirective carries only accounts the canonical lexer predicate accepts — a bypass would readmit the un-round-trippable-account class the fix: one canonical account-name rule; validate FFI ingress; warn on bad name_* roots #1739 gate blocks; (2) conversion disposition is deterministic.fuzz/seeds/, one JSON perInputEntryvariant plus the booked-pair and bad-account edges) double as by-example wire-format documentation; the CI job copies them into the corpus so cold caches start with structural coverage.corpus/stays gitignored like the sibling fuzz crates.fuzz-ffi-ingressjob cloned fromfuzz-booking(JSON needsmax_len=4096), same crash-artifact policy;fuzz_input_entryadded to the dispatch target choices.Local shake
120 seconds under nightly libFuzzer: 9.65M executions, cov 6073, zero crashes, both invariants held.
🤖 Generated with Claude Code