Add regression test and fuzz coverage for zero first offset in lists#29
Open
MegaRedHand wants to merge 1 commit into
Open
Add regression test and fuzz coverage for zero first offset in lists#29MegaRedHand wants to merge 1 commit into
MegaRedHand wants to merge 1 commit into
Conversation
leanEthereum/leanSpec#1175 reports that leanSpec's SSZ list decoder accepts first_offset == 0, deriving a zero element count while the offset/scope boundary describes one element spanning the whole input. libssz already rejects this up front (the num_items == 0 check in decode_variable_length_items_with_max), but nothing pinned that behavior. Pin it with a regression test using the issue's exact payload, and extend the offset_adversarial fuzz target with list-of-variable-length items types: it previously only exercised ContainerDecoder, never the list offset-table path where this class of bug lives.
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.
Context
leanEthereum/leanSpec#1175 reports that leanSpec's SSZ variable-length list decoder accepts
first_offset == 0: the element count computes to 0 while the offset/scope boundary describes one element spanning the whole input. It fails there only by accident, at the wrong layer.libssz is not affected
decode_variable_length_items_with_maxalready rejects this up front via thenum_items == 0check (crates/ssz/src/decode.rs), returningInvalidFirstOffsetbefore any offsets or element bodies are parsed.ContainerDecoderis stricter still: the first offset must equal the fixed-part length exactly.Changes
vec_of_vecs_zero_first_offset): pins the rejection using the issue's exact payload00000000aabbccdd, plus the bare00000000case.offset_adversarialonly exercisedContainerDecoder(its fields areVec<u8>, which decodes as raw bytes with no inner offset table), so the list offset-table path had no raw-bytes fuzz coverage anywhere. AddedVec<Vec<u8>>and a container holding one, matching the target's documented intent of covering zero-offset patterns.