Move progressive list checks into BeaconBlock::from_ssz_bytes - #10098
Closed
michaelsproul wants to merge 2 commits into
Closed
michaelsproul wants to merge 2 commits into
michaelsproul wants to merge 2 commits into
Conversation
Member
Author
|
I don't really like this approach. I think it's too fragile. It doesn't make it easy to check that we don't accidentally bypass the length limit. There could be cases like serde decoding or manual construction, or weird piece-wise SSZ decoding that end up skipping the length checks. I think the cleanest approach is probably going to be type-level length limits again, like: I pushed the code for execution payloads in db2d410, and even though it's slop, I think it conveys the inherent complexity and fragility of this approach. |
michaelsproul
commented
Sep 21, 2026
Comment on lines
+81
to
+107
| impl<E: EthSpec> Decode for ExecutionPayloadEnvelope<E> { | ||
| fn is_ssz_fixed_len() -> bool { | ||
| false | ||
| } | ||
|
|
||
| fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, ssz::DecodeError> { | ||
| let mut builder = ssz::SszDecoderBuilder::new(bytes); | ||
| builder.register_type::<ExecutionPayloadGloas<E>>()?; | ||
| builder.register_type::<ExecutionRequestsGloas<E>>()?; | ||
| builder.register_type::<u64>()?; | ||
| builder.register_type::<Hash256>()?; | ||
| builder.register_type::<Hash256>()?; | ||
|
|
||
| let mut decoder = builder.build()?; | ||
| let envelope = Self { | ||
| payload: decoder.decode_next()?, | ||
| execution_requests: decoder.decode_next()?, | ||
| builder_index: decoder.decode_next()?, | ||
| beacon_block_root: decoder.decode_next()?, | ||
| parent_beacon_block_root: decoder.decode_next()?, | ||
| }; | ||
| verify_execution_payload_list_lengths_post_gloas(ExecutionPayloadRef::Gloas( | ||
| &envelope.payload, | ||
| ))?; | ||
| verify_execution_request_list_lengths_post_gloas(&envelope.execution_requests)?; | ||
| Ok(envelope) | ||
| } |
Member
Author
There was a problem hiding this comment.
This is fairly yuck IMO.
Member
Author
|
Closing in favour of: |
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.
Issue Addressed
We are vulnerable to all sorts of DoS nonsense and memory amplification due to
ProgressiveList. This PR tries to take an aggressive approach to stop oversizedProgressiveLists making it out ofDecode.Proposed Changes
BeaconBlockinsideBeaconBlock::from_ssz_bytes.ExecutionPayloadEnvelopeduring decoding (warning: slop).Additional Info
Arguably one could still decode a
BeaconBlockBody{Gloas}while bypassing the length check. Putting it one level up inBeaconBlockis convenient because we already have that method, and I have checked that production decoding always goes via this codepath (we almost always decode aSignedBeaconBlock, andany_from_ssz_bytesis only used by MockBeaconNode [we should probably delete it]).Replaces: