Skip to content

fix(rlp): reject trailing bytes and list overruns in fromRlp - #4790

Merged
jxom merged 1 commit into
mainfrom
jxom/rlp-reject-trailing-bytes
Jul 2, 2026
Merged

jxom merged 1 commit into
mainfrom
jxom/rlp-reject-trailing-bytes

Conversation

@jxom

@jxom jxom commented Jul 2, 2026

Copy link
Copy Markdown
Member

fromRlp returned after decoding a single item without asserting the cursor consumed all input, so trailing bytes were silently dropped (fromRlp('0x80deadbeef') returned '0x'). RLP payloads encode exactly one item; geth and ethers both reject leftover bytes.

Decoding now throws RlpTrailingBytesError when bytes remain after the top-level item, and RlpListBoundaryExceededError when list items consume more bytes than the list header declared (e.g. 0xc182aabb), matching geth's "element is larger than containing list" and ethers' "child data too short".

Supersedes #4778, adding dedicated error classes and the list boundary check. Thanks @spokodev for the report and initial fix, credited as co-author.

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c3fc07a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
viem Building Building Preview, Comment Jul 2, 2026 11:36pm

Request Review

@jxom
jxom merged commit e5626e3 into main Jul 2, 2026
26 checks passed
@jxom
jxom deleted the jxom/rlp-reject-trailing-bytes branch July 2, 2026 23:37
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026

This branch was successfully deployed

1 active deployment
Preview — c3fc07a6 Deployed Jul 2, 2026 by vercel[bot]
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