Skip to content

fix: validate ABI reads at each parameter head - #5572

Merged
jxom merged 1 commit into
wevm:mainfrom
yinbowen-dc:codex/fix-5566-abi-head-bounds
Nov 18, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
yinbowen-dc:codex/fix-5566-abi-head-bounds

Conversation

@yinbowen-dc

Copy link
Copy Markdown
Contributor

Fixes #5566.

Always restore the cursor to the next ABI parameter head, including when the head is at the end of the data. Nonempty reads then enforce their own bounds, while zero-width arrays and tuples remain valid. A dynamic offset into an earlier word can no longer make a missing static head reuse that earlier word.

Validation: both string and bytes regression cases fail on main; all 85 decodeAbiParameters tests pass with the fix, including existing zero-width cases. Biome passed. Production TypeScript check passed earlier for the same base; full project types need generated test-contract artifacts. A patch changeset is included.

AI assistance: prepared and tested with Codex at the account owner's request.

@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@yinbowen-dc is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ae4c8b

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

@erkancamli

Copy link
Copy Markdown
Contributor

Reproduced on 2.58.0 with the payload from the test (uint256, uint256, string, uint256 over three words, the string offset pointing back to word 0): decodeAbiParameters returns [3n, 119n, "\u0000\u0000\u0000", 119n], so the fourth value is read from word 1 instead of failing. ethers v6 rejects the same data with data out-of-bounds.

I applied the one-line change to the published build to check it does not affect valid inputs: the malformed string and bytes cases now throw PositionOutOfBoundsError, uint256[0] and an empty tuple after the last word still decode to [], and 2,000 encode/decode round trips of uint256, string, bytes, uint8[], uint256 are unchanged.

ox has the same guard in AbiParameters.decode (if (consumed < bytes.length) cursor.setPosition(consumed), src/core/AbiParameters.ts) and returns the same values for this payload on 1.8.18, so it may be worth the same change there.

@jxom
jxom merged commit cb14298 into wevm:main Nov 18, 2026
2 of 3 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 18, 2026
jxom added a commit to wevm/ox that referenced this pull request Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#729)

- Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590).
- Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572).
- Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631).
- Added blockAccessListHash and slotNumber to Block (wevm/viem#5674).
- Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635).

Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e

Co-authored-by: Amp <[email protected]>
jxom added a commit to wevm/ox that referenced this pull request Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#730)

- Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590).
- Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572).
- Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631).
- Added blockAccessListHash and slotNumber to Block (wevm/viem#5674).
- Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635).

Backport of #729.

Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e

Co-authored-by: Amp <[email protected]>
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.

decodeAbiParameters: data that ends before the head of a later static parameter decodes from a wrong position

3 participants