fix(fuzz): handle all reachable EncodeError arms and remove dead MissingReceiver variant#314
Open
ManthanNimodiya wants to merge 1 commit intoopenwallet-foundation-labs:mainfrom
Conversation
…ingReceiver variant Signed-off-by: ManthanNimodiya <manthannimodiya989898@gmail.com>
3232a02 to
e9526e0
Compare
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
The
payload_encode_decodefuzz harness had twotodo!()arms in itsencode_payloadmatch block.todo!()panics at runtime — when the fuzzertriggers one of those arms, the harness itself crashes, making it look like
the encoder has a bug when it actually returned a valid error. Additionally,
EncodeError::MissingReceiverwas declared in the error enum but never raisedanywhere in the codebase, which obscured the incomplete coverage in the harness.
Root Cause
encode_payloadcan legitimately returnErr(EncodeError::ExcessiveFieldSize)when any payload field exceeds the CESR variable-data size limit
(
3 * 2^24bytes). TheArbitraryimpl infuzzing.rsgeneratesnew_vidand
datafields as unboundedVec<u8>, so this path is reachable. The outer_ => todo!()caught it and panicked, producing a false-positive crash report.The inner
todo!()(inside theMissingHopsarm) was unreachable in practicesince
MissingHopsis only raised forRoutedMessage, but it was stillincorrect —
unreachable!()or a flat assertion is the right form.Changes
fuzz/fuzz_targets/payload_encode_decode.rs— replaced bothtodo!()arms with explicit handling:
ExcessiveFieldSizeis silently ignored (it isa legitimate rejection),
MissingHopsis flattened into a singleassert!with a guard, and a catch-all
panic!now surfaces genuinely unexpected errorsas real fuzz findings
tsp_sdk/src/cesr/error.rs— removedMissingReceiverfromEncodeError;it was never raised by any function in the SDK
Testing
The fuzz target itself is the test. Changes verified by:
git grep MissingReceiverreturns no results after the removalencode_payloaderror sites inpacket.rstoconfirm every reachable variant is now explicitly handled
Checklist