Skip to content

fix: validate integer range and address padding in AbiParameters.decode - #558

Merged
jxom merged 1 commit into
mainfrom
fix/decode-abi-integer-range
Nov 1, 2026
Merged

jxom merged 1 commit into
mainfrom
fix/decode-abi-integer-range

Conversation

@jxom

@jxom jxom commented Nov 1, 2026

Copy link
Copy Markdown
Member

Ports wevm/viem#5359 (by @haybinalim, fixes wevm/viem#5350) to Ox.

AbiParameters.decode read the full 32-byte word for intN/uintN without checking it against the declared size, and ignored the high 12 bytes of address words, so malformed data decoded to values the type can't hold (e.g. uint8 0x…0100 → 256, int8 0x…0080 → 128).

  • decodeNumber: decodes the word as a 256-bit bigint and, below 256 bits, checks it against the type's [min, max], throwing Hex.IntegerOutOfRangeError (the same error encode throws). Sizes ≤ 48 still return number.
  • decodeAddress: requires the 12 padding bytes to be zero, throwing Address.InvalidAddressError (cause Address.InvalidInputError).

This matches Solidity 0.8 abi.decode and eth_abi. Both errors were already on the adversarial-fuzz allow-list.

Tests: new cases in AbiParameters.decode.test.ts (9 fail on main, pass here, including a min/max/out-of-range sweep over every uint8…uint256/int8…int256); full core project passes apart from network-dependent tests; ABI fuzz suites and tsc -b pass.

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ox Error Error Nov 1, 2026 9:37am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T09:38:00.018716Z 2486418 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Published ox@0.0.0-pr-558-2486418 under the pr-558 dist-tag, which follows this pull request until it closes.

pnpm add ox@pr-558
pnpm add ox@0.0.0-pr-558-2486418

@jxom
jxom merged commit e7600e0 into main Nov 1, 2026
15 of 16 checks passed
@jxom
jxom deleted the fix/decode-abi-integer-range branch November 1, 2026 22:45
@github-actions github-actions Bot mentioned this pull request Nov 1, 2026

This branch had an error being deployed

1 failed deployment
Preview — 24864183 Deployed Nov 1, 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.

decodeAbiParameters accepts out-of-range integers and dirty address padding

1 participant