Add fuzz target for the v1 payjoin roundtrip - #1872
Open
caarloshenriq wants to merge 1 commit into
Open
Conversation
Walk the full v1 exchange: the sender builds a request from an original PSBT, the receiver runs it through the typestate chain, and the sender parses the resulting proposal. A custom mutator keeps a known-good original PSBT intact and spends the mutation budget on the BIP 78 query parameters, where the attacker-controlled values live. Raw inputs cannot reach the receiver: the sender builder needs funded inputs, an output paying the URI address and consistent values, so seeding a valid PSBT is what puts the state machine rather than the PSBT parser under test. The receiver's checks all answer unconditionally, since a real receiver's answers depend on its own UTXO set.
caarloshenriq
requested review from
DanGould,
benalleng and
spacebear21
as code owners
September 9, 2026 20:33
Collaborator
Coverage Report for CI Build 34401726297Coverage remained the same at 86.646%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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 a libFuzzer target covering the full v1 payjoin roundtrip: sender builds a request, receiver walks the typestate chain, sender parses the proposal that comes back.
What is covered
The target exercises both sides of the exchange and the handoff between them:
Sender:
SenderBuilder::new,build_non_incentivizing,create_v1_post_request,V1Context::process_responseReceiver:
UncheckedOriginalPayload::from_request,check_inputs_not_owned,check_no_inputs_seen_before,identify_receiver_outputs,commit_outputs,commit_inputs,apply_fee_range,finalize_proposalThe receiver's ownership checks answer unconditionally: a real receiver's answers depend on its own UTXO set, which is not what this target is exercising. The goal is the state machine's robustness against attacker-controlled input, not wallet logic.
Mutator design
The input is
[len:2][psbt][query]. The custom mutator keeps the PSBT section intact and mutates the query, where the BIP 78 parameters live. 25% of mutations pass straight tofuzzer_mutate, which is also the only path that reaches the PSBT bytes and so doubles as coverage of the sender builder's rejection paths.Seeding a valid PSBT is what makes the target work. Measured over 200k runs with raw input, roughly 4% deserialize as a PSBT at all and none of those survive
build_non_incentivizing, which needs funded inputs, an output paying the URI address and consistent values. Without the seed the target only exercises the rust-bitcoin PSBT parser. The seed is theBIP 78 test vector already used by payjoin-test-utils, and the URI address is derived from its output 1 rather than hardcoded, so the two cannot drift apart.
Fuzzing results
From an empty corpus on x86_64 Linux, 6 forks, 61 seconds:
Addresses part of #1267.
Disclosure: co-authored by Claude Opus 5
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.