ferranbt / fastssz

Fast Ethereum2.0 SSZ encoder/decoder
MIT License
74 stars 44 forks source link

Bounds checking for generated UnmarshalSSZ method #44

Closed kasey closed 3 years ago

kasey commented 3 years ago

In the current generated code, a malformed message may include a variable length value offset pointing to a location before the end of the encoded fixed-size values. In this instance UnmarshalSSZ will unmarshal the encoded bytes without complaint, resulting in a corrupt runtime value. An example encoded Attestation value can be downloaded from: https://github.com/prysmaticlabs/ethereumapis/blob/check-variable-offset/eth/v1/testdata/invalid-offset.attestation.ssz