Skip to content

Reject CThreshold parsing when k > 255#864

Draft
sethdusek wants to merge 3 commits into
ergoplatform:developfrom
sethdusek:cthresholdfixes
Draft

Reject CThreshold parsing when k > 255#864
sethdusek wants to merge 3 commits into
ergoplatform:developfrom
sethdusek:cthresholdfixes

Conversation

@sethdusek
Copy link
Copy Markdown
Collaborator

k was cast from u16 to u8 without a bounds check, so a wire value of
k > 255 would be silently accepted with a truncated threshold (e.g.
k=300 becomes k=44).

Return a parsing error if k exceeds 255, matching
sigmastate-interpreter's require(k <= children.length <= 255) check.

LLM disclosure: I used Claude to review the parsing implementations in Rust. It's found some interesting differences so far, this is one of them. I'm currently reviewing some of the other issues it has discovered.

Depends on #863 to get CI working

sethdusek added 3 commits May 7, 2026 14:23
core2 was recently (unexpectedly) yanked. We only use it for IO traits so this isn't a big deal, we can just use no_std_io2
k was cast from u16 to u8 without a bounds check, so a value of
k > 255 would be accepted with a truncated threshold (e.g.
k=300 becomes k=44).

Return a parsing error if k exceeds 255, matching
sigmastate-interpreter's require(k <= children.length <= 255) check.
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.

1 participant