Skip to content

Add FFI roundtrip fuzz target - #2059

Open
caarloshenriq wants to merge 1 commit into
payjoin:masterfrom
caarloshenriq:fuzz/ffi-roundtrip
Open

caarloshenriq wants to merge 1 commit into
payjoin:masterfrom
caarloshenriq:fuzz/ffi-roundtrip

Conversation

@caarloshenriq

Copy link
Copy Markdown
Contributor

Adds ffi-roundtrip-v2, a full v2 payjoin end to end through the payjoin-ffi bindings. A real sender and receiver, both driven only through the FFI types, talk over an in-process mock OHTTP directory (the same crypto plumbing as roundtrip/v2.rs).

Both parties stay honest, so every message passes both crypto layers on its own and the fuzzer never touches ciphertext. What it controls is the wallet choices, the receiver's answers, directory statuses, polling order, and whether either party resumes from its event log. The input is [len:2][psbt][scenario]; an empty scenario is the happy path.

What it covers

This reaches surface the per-state FFI targets and the core roundtrip cannot:

  • The sender validating a real proposal in process_response. This is the sender's defense against a malicious receiver, and it is only reachable through a full roundtrip, since it needs the receiver's genuine OHTTP/HPKE context.
  • The JSON event persisters and callback adapters across both state machines, plus replay_receiver_event_log / replay_sender_event_log mid-flow (sender restart, receiver resume).
  • The error path: when the receiver rejects a check, the target replays to HasReplyableError and posts the error back to the sender.

Testing

Unit tests cover the happy path completing, sender restart, early polls, a receiver rejection reaching the sender, and a directory fault stopping the post.

Fuzzed locally with 8 parallel workers: ~72k executions, no crash, no slow units, peak RSS ~505 MB, and the corpus kept growing throughout (942 new units), so coverage had not saturated.

Reviewer: @benalleng

Disclosure: co-authored by Claude

Pull Request Checklist

Please confirm the following before requesting review:

Drive a full v2 payjoin end to end through the payjoin-ffi bindings: a
real sender and receiver, both exercised only through the FFI types,
talk over an in-process mock OHTTP directory. The fuzzer controls the
wallet choices, the receiver's answers, directory statuses, polling
order and whether either party resumes from its event log, while both
parties stay honest so the crypto layers are never fed fuzzer bytes.
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 43947383697

Coverage remained the same at 87.657%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18262
Covered Lines: 16008
Line Coverage: 87.66%
Coverage Strength: 104.47 hits per line

💛 - Coveralls

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants