deserialize: validate offsets for structs, slices, lists (zeam #843)#63
Open
ch4r10t33r wants to merge 1 commit intoblockblaz:masterfrom
Open
deserialize: validate offsets for structs, slices, lists (zeam #843)#63ch4r10t33r wants to merge 1 commit intoblockblaz:masterfrom
ch4r10t33r wants to merge 1 commit intoblockblaz:masterfrom
Conversation
Malformed peer-supplied SSZ could slice past the buffer and panic in struct second pass, variable []T decode, variable arrays, and List sszDecode. - Mirror array-deserializer guards: alignment, prefix in bounds, start/end ordering. - Struct: bounds-check fixed-field reads and variable-field slices; require first var offset to match fixed-prefix length. - Union: require non-empty payload before reading selector. - utils.List: fixed-size path rejects ragged length and count > N; dynamic path bounds-checks offset prefix. Adds regression tests for struct offsets past the buffer. Closes blockblaz/zeam#843 when consumed downstream.
g11tech
approved these changes
May 8, 2026
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.
Problem
Peer-supplied SSZ with invalid offset tables could slice past the buffer and panic during
deserialize(struct variable fields, variable[]T, variable arrays, andutils.Listdecode). See zeam#843.Change
start <= end, monotonic offsets.[]T: validate first/second offsets, item count, and each subsequent offset read before slicing.start <= end, offsets within buffer, monotonicity, andindices[0] == ifor the first variable field.serialized.len >= 1before reading the selector byte.utils.List.sszDecode: fixed-size items reject ragged length andn > N; dynamic path bounds-checks the offset-prefix length before slicing.Tests / tooling
build.zig.zon:minimum_zig_version = "0.16.0"(matches CI; satisfies anyzig when present).Downstream
After merge, zeam can switch from a vendored copy back to a
build.zig.zongit+dependency on the new commit.