fix(types): return false instead of panic in verify_multi_proof#177
Merged
poszu merged 1 commit intopodnetwork:mainfrom Mar 3, 2026
Merged
fix(types): return false instead of panic in verify_multi_proof#177poszu merged 1 commit intopodnetwork:mainfrom
poszu merged 1 commit intopodnetwork:mainfrom
Conversation
The final match arm in `MerkleTree::verify_multi_proof` called `panic!()` when the stack/path lengths were in an unexpected state after processing all flags. Proof data comes from external sources (RPC responses, deserialized network messages), so a malformed proof would crash the process rather than return a verification failure. Two earlier guard checks in the same function already return `false` for invalid proofs. Align this last branch with the same pattern: log a debug message and return `false`.
poszu
approved these changes
Mar 3, 2026
Contributor
poszu
left a comment
There was a problem hiding this comment.
I suppose the intent of the author was to show that this path is not possible to be executed (even on invalid input) but it's difficult to prove this is true.
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
MerkleTree::verify_multi_proofpanicked instead of returningfalsewhen the stack and path lengths were in an unexpected state after processing all proof flags.Proof verification functions handle untrusted external data — proofs come from RPC responses and deserialized network messages. A malformed or adversarially crafted proof would crash the process rather than be rejected as invalid.
The same function already returns
falsein two earlier guard checks for invalid proofs:The final match arm was inconsistent with these:
Test plan
MerkleMultiProof(e.g. mismatchedflags/pathlengths that bypass the early guards) returnsfalseinstead of panicking