Skip to content

fix(sizzlean): reject extra unused bytes in SSZ.deserialize - #119

Open
irajgill wants to merge 1 commit into
etheorem:mainfrom
irajgill:feat/ssz-deserialize-trailing-bytes
Open

irajgill wants to merge 1 commit into
etheorem:mainfrom
irajgill:feat/ssz-deserialize-trailing-bytes

Conversation

@irajgill

Copy link
Copy Markdown
Contributor

Summary

Fixes #118. SSZType.deserialize returns the count of bytes it consumed. SSZ.deserialize dropped that count, so a 9-byte buffer decoded as the UInt64 value 1. The SSZ spec names this case extra unused bytes and requires a reject.

The wrapper now returns .error .trailingBytes when the count differs from the buffer size. SSZ.roundtrip still closes: decode_encode already gives a count equal to the encoding size. ReprExamples pins the 9-byte case.

This is the user-surface half of decoder canonicity. The schema-level half is #81.

LICENSE (LGPL version 3)

  • I have read and accepted LICENSE (LGPL version 3), NOTICE and CLA in the root of this project.

The spec decoder returns how many bytes it consumed. The user wrapper
dropped that count, so a 9-byte buffer decoded as UInt64 1. The SSZ
spec names this case extra unused bytes and requires a reject.

Compare the count with the buffer size and return trailingBytes when
they differ. SSZ.roundtrip still closes: decode_encode already gives a
count equal to the encoding size. ReprExamples pins the 9-byte case.
@irajgill
irajgill requested a review from leolara September 25, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSZ.deserialize accepts extra bytes after a fixed-size value

1 participant