fix(backend): harden Celestia node response handling#2
Open
loopghost wants to merge 1 commit into
Open
Conversation
Make the Celestia backend return errors on unexpected responses from the configured node instead of relying on implicit invariants: - broadcast: validate the node-returned tx hash length before copy_from_slice into [u8; 32]; return CelestiaSubmit on an unexpected length. - verify (ProofRequired): contain NMT proof verifier panics and map them to InclusionVerificationFailed so malformed proofs are handled as verification errors along the same path as an explicit rejection. - verify: use checked_add for the share range bound to avoid integer overflow on unexpected index or length values.
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
Defensive hardening of the Celestia backend's handling of responses from the configured node. A few spots assume well-formed responses; this makes them return errors on unexpected input instead of relying on implicit invariants. Changes are confined to
coro/src/backend/celestia_client.rs.Changes
broadcast: validate the length of the node-returned transaction hash before copying it into[u8; 32], returningError::CelestiaSubmiton an unexpected length instead of relying on thecopy_from_slicelength invariant.verify(ProofRequired): contain panics from the NMT proof verifier and map them toError::InclusionVerificationFailed, so a malformed proof is handled as a verification error along the same path as an explicit rejection.verify: compute the share range bound withchecked_addto avoid integer overflow on unexpected index or length values.Testing
cargo check -p coropasses.cc @Ferret-san